<html><head></head><body><div class="gmail_quote">Le 14 août 2017 12:48:03 GMT+03:00, Shaleen Jain <shaleen.jain95@gmail.com> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Add an option to compile with a set of the<br />recommended flags for the various santizers.<br /><br />Use AX_APPEND_COMPILE_FLAGS to maintain compatibility<br />with previous versions of gcc and clang where only a<br />subset of the flags are supported.<br /><br />This patch also disables no-undefined-symbols(-Wl,-z,defs)<br />only when this switch is used, to avoid link errors, mainly with asan.<br />---<br /> <a href="http://configure.ac">configure.ac</a>                  | 29 ++++++++++++++++-<br /> m4/ax_append_compile_flags.m4 | 68 +++++++++++++++++++++++++++++++++++++++<br /> m4/ax_append_flag.m4          | 72 +++++++++++++++++++++++++++++++++++++++++<br /> m4/ax_check_compile_flag.m4   | 75 +++++++++++++++++++++++++++++++++++++++++++<br /> m4/ax_require_defined.m4      | 38 ++++++++++++++++++++++<br /> 5 files changed, 281 insertions(+), 1 deletion(-)<br /> create mode 100644 m4/ax_append_compile_flags.m4<br /> create mode 100644 m4/ax_append_flag.m4<br /> create mode 100644 m4/ax_check_compile_flag.m4<br /> create mode 100644 m4/ax_require_defined.m4<br /><br />diff --git a/<a href="http://configure.ac">configure.ac</a> b/<a href="http://configure.ac">configure.ac</a><br />index 8487fea895..b3eebc4d08 100644<br />--- a/<a href="http://configure.ac">configure.ac</a><br />+++ b/<a href="http://configure.ac">configure.ac</a><br />@@ -1015,6 +1015,33 @@ AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "os2"], [<br />   AS_IF([test "${ac_cv_c_visibility_hidden}" = "no"], [VLC_RESTORE_FLAGS])<br /> ])<br /> <br />+dnl<br />+dnl  Sanitizer flags<br />+dnl<br />+AC_ARG_WITH([sanitizer],<br />+    [AS_HELP_STRING([--with-sanitizer=(address/memory/undefined/thread)],<br />+        [build with sanitizer flags (default disabled)])],<br />+     [],<br />+     [with_sanitizer=no])<br />+<br />+AS_VAR_IF(with_sanitizer, no, [], [<br />+    AX_CHECK_COMPILE_FLAG([-fsanitize=${with_sanitizer}], [<br />+        AX_APPEND_FLAG([-fsanitize=${with_sanitizer}])                       <br />+    ], [<br />+        AC_MSG_ERROR(["-fsanitize=${with_sanitizer} not supported!"])<br />+    ])<br />+    AX_APPEND_FLAG([-g])<br />+<br />+    AS_VAR_IF(with_sanitizer, address, [<br />+       AX_APPEND_COMPILE_FLAGS([-fsanitize-address-use-after-scope -fno-omit-frame-pointer])<br />+    ])<br />+    AS_VAR_IF(with_sanitizer, memory, [<br />+        AX_APPEND_COMPILE_FLAGS([-fPIE -pie])<br />+    ])<br />+    AS_VAR_IF(with_sanitizer, thread, [<br />+        AX_APPEND_COMPILE_FLAGS([-fPIE -pie])<br />+    ])<br />+])<br /> <br /> dnl<br /> dnl  Enable/disable optimizations<br />@@ -1115,7 +1142,7 @@ AC_CACHE_CHECK([if linker supports -z,defs], [ac_cv_ld_z_defs], [<br />     ac_cv_ld_z_defs="no"<br />   ])<br /> ])<br />-AS_IF([test "${ac_cv_ld_z_defs}" = "no"], [VLC_RESTORE_FLAGS])<br />+AS_IF([test "${ac_cv_ld_z_defs}" = "no" -o "x$with_sanitizer" != xno], [VLC_RESTORE_FLAGS])<br /> <br /> dnl Check for __attribute__((packed))<br /> AC_CACHE_CHECK([for __attribute__((packed))],<br />diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4<br />new file mode 100644<br />index 0000000000..56627670d0<br />--- /dev/null<br />+++ b/m4/ax_append_compile_flags.m4<br />@@ -0,0 +1,68 @@<br />+#<hr /><br />+#  <a href="https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html">https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html</a><br />+#<hr /><br />+#<br />+# SYNOPSIS<br />+#<br />+#   AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])<br />+#<br />+# DESCRIPTION<br />+#<br />+#   For every FLAG1, FLAG2 it is checked whether the compiler works with the<br />+#   flag.  If it does, the flag is added FLAGS-VARIABLE<br />+#<br />+#   If FLAGS-VARIABLE is not specified, the current language's flags (e.g.<br />+#   CFLAGS) is used.  During the check the flag is always added to the<br />+#   current language's flags.<br />+#<br />+#   If EXTRA-FLAGS is defined, it is added to the current language's default<br />+#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with<br />+#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to<br />+#   force the compiler to issue an error when a bad flag is given.<br />+#<br />+#   INPUT gives an alternative input source to AC_COMPILE_IFELSE.<br />+#<br />+#   NOTE: This macro depends on the AX_APPEND_FLAG and<br />+#   AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with<br />+#   AX_APPEND_LINK_FLAGS.<br />+#<br />+# LICENSE<br />+#<br />+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com><br />+#<br />+#   This program is free software: you can redistribute it and/or modify it<br />+#   under the terms of the GNU General Public License as published by the<br />+#   Free Software Foundation, either version 3 of the License, or (at your<br />+#   option) any later version.<br />+#<br />+#   This program is distributed in the hope that it will be useful, but<br />+#   WITHOUT ANY WARRANTY; without even the implied warranty of<br />+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General<br />+#   Public License for more details.<br />+#<br />+#   You should have received a copy of the GNU General Public License along<br />+#   with this program. If not, see <<a href="https://www.gnu.org/licenses">https://www.gnu.org/licenses</a>/>.<br />+#<br />+#   As a special exception, the respective Autoconf Macro's copyright owner<br />+#   gives unlimited permission to copy, distribute and modify the configure<br />+#   scripts that are the output of Autoconf when processing the Macro. You<br />+#   need not follow the terms of the GNU General Public License when using<br />+#   or distributing such scripts, even though portions of the text of the<br />+#   Macro appear in them. The GNU General Public License (GPL) does govern<br />+#   all other use of the material that constitutes the Autoconf Macro.<br />+#<br />+#   This special exception to the GPL applies to versions of the Autoconf<br />+#   Macro released by the Autoconf Archive. When you make and distribute a<br />+#   modified version of the Autoconf Macro, you may extend this special<br />+#   exception to the GPL to apply to your modified version as well.<br />+<br />+#serial 6<br />+<br />+AC_DEFUN([AX_APPEND_COMPILE_FLAGS],<br />+[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])<br />+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])<br />+for flag in $1; do<br />+  AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])<br />+done<br />+])dnl AX_APPEND_COMPILE_FLAGS<br />+<br />diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4<br />new file mode 100644<br />index 0000000000..7d3f840b84<br />--- /dev/null<br />+++ b/m4/ax_append_flag.m4<br />@@ -0,0 +1,72 @@<br />+#<hr /><br />+#      <a href="https://www.gnu.org/software/autoconf-archive/ax_append_flag.html">https://www.gnu.org/software/autoconf-archive/ax_append_flag.html</a><br />+#<hr /><br />+#<br />+# SYNOPSIS<br />+#<br />+#   AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])<br />+#<br />+# DESCRIPTION<br />+#<br />+#   FLAG is appended to the FLAGS-VARIABLE shell variable, with a space<br />+#   added in between.<br />+#<br />+#   If FLAGS-VARIABLE is not specified, the current language's flags (e.g.<br />+#   CFLAGS) is used.  FLAGS-VARIABLE is not changed if it already contains<br />+#   FLAG.  If FLAGS-VARIABLE is unset in the shell, it is set to exactly<br />+#   FLAG.<br />+#<br />+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.<br />+#<br />+# LICENSE<br />+#<br />+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de><br />+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com><br />+#<br />+#   This program is free software: you can redistribute it and/or modify it<br />+#   under the terms of the GNU General Public License as published by the<br />+#   Free Software Foundation, either version 3 of the License, or (at your<br />+#   option) any later version.<br />+#<br />+#   This program is distributed in the hope that it will be useful, but<br />+#   WITHOUT ANY WARRANTY; without even the implied warranty of<br />+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General<br />+#   Public License for more details.<br />+#<br />+#   You should have received a copy of the GNU General Public License along<br />+#   with this program. If not, see <<a href="https://www.gnu.org/licenses">https://www.gnu.org/licenses</a>/>.<br />+#<br />+#   As a special exception, the respective Autoconf Macro's copyright owner<br />+#   gives unlimited permission to copy, distribute and modify the configure<br />+#   scripts that are the output of Autoconf when processing the Macro. You<br />+#   need not follow the terms of the GNU General Public License when using<br />+#   or distributing such scripts, even though portions of the text of the<br />+#   Macro appear in them. The GNU General Public License (GPL) does govern<br />+#   all other use of the material that constitutes the Autoconf Macro.<br />+#<br />+#   This special exception to the GPL applies to versions of the Autoconf<br />+#   Macro released by the Autoconf Archive. When you make and distribute a<br />+#   modified version of the Autoconf Macro, you may extend this special<br />+#   exception to the GPL to apply to your modified version as well.<br />+<br />+#serial 7<br />+<br />+AC_DEFUN([AX_APPEND_FLAG],<br />+[dnl<br />+AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF<br />+AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])<br />+AS_VAR_SET_IF(FLAGS,[<br />+  AS_CASE([" AS_VAR_GET(FLAGS) "],<br />+    [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],<br />+    [<br />+     AS_VAR_APPEND(FLAGS,[" $1"])<br />+     AC_RUN_LOG([: FLAGS="$FLAGS"])<br />+    ])<br />+  ],<br />+  [<br />+  AS_VAR_SET(FLAGS,[$1])<br />+  AC_RUN_LOG([: FLAGS="$FLAGS"])<br />+  ])<br />+AS_VAR_POPDEF([FLAGS])dnl<br />+])dnl AX_APPEND_FLAG<br />+<br />diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4<br />new file mode 100644<br />index 0000000000..80c79114e9<br />--- /dev/null<br />+++ b/m4/ax_check_compile_flag.m4<br />@@ -0,0 +1,75 @@<br />+#<hr /><br />+#  <a href="https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html">https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html</a><br />+#<hr /><br />+#<br />+# SYNOPSIS<br />+#<br />+#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])<br />+#<br />+# DESCRIPTION<br />+#<br />+#   Check whether the given FLAG works with the current language's compiler<br />+#   or gives an error.  (Warnings, however, are ignored)<br />+#<br />+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on<br />+#   success/failure.<br />+#<br />+#   If EXTRA-FLAGS is defined, it is added to the current language's default<br />+#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with<br />+#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to<br />+#   force the compiler to issue an error when a bad flag is given.<br />+#<br />+#   INPUT gives an alternative input source to AC_COMPILE_IFELSE.<br />+#<br />+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this<br />+#   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.<br />+#<br />+# LICENSE<br />+#<br />+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de><br />+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com><br />+#<br />+#   This program is free software: you can redistribute it and/or modify it<br />+#   under the terms of the GNU General Public License as published by the<br />+#   Free Software Foundation, either version 3 of the License, or (at your<br />+#   option) any later version.<br />+#<br />+#   This program is distributed in the hope that it will be useful, but<br />+#   WITHOUT ANY WARRANTY; without even the implied warranty of<br />+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General<br />+#   Public License for more details.<br />+#<br />+#   You should have received a copy of the GNU General Public License along<br />+#   with this program. If not, see <<a href="https://www.gnu.org/licenses">https://www.gnu.org/licenses</a>/>.<br />+#<br />+#   As a special exception, the respective Autoconf Macro's copyright owner<br />+#   gives unlimited permission to copy, distribute and modify the configure<br />+#   scripts that are the output of Autoconf when processing the Macro. You<br />+#   need not follow the terms of the GNU General Public License when using<br />+#   or distributing such scripts, even though portions of the text of the<br />+#   Macro appear in them. The GNU General Public License (GPL) does govern<br />+#   all other use of the material that constitutes the Autoconf Macro.<br />+#<br />+#   This special exception to the GPL applies to versions of the Autoconf<br />+#   Macro released by the Autoconf Archive. When you make and distribute a<br />+#   modified version of the Autoconf Macro, you may extend this special<br />+#   exception to the GPL to apply to your modified version as well.<br />+<br />+#serial 5<br />+<br />+AC_DEFUN([AX_CHECK_COMPILE_FLAG],<br />+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF<br />+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl<br />+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [<br />+  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS<br />+  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"<br />+  AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],<br />+    [AS_VAR_SET(CACHEVAR,[yes])],<br />+    [AS_VAR_SET(CACHEVAR,[no])])<br />+  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])<br />+AS_VAR_IF(CACHEVAR,yes,<br />+  [m4_default([$2], :)],<br />+  [m4_default([$3], :)])<br />+AS_VAR_POPDEF([CACHEVAR])dnl<br />+])dnl AX_CHECK_COMPILE_FLAGS<br />+<br />diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4<br />new file mode 100644<br />index 0000000000..c4e9859550<br />--- /dev/null<br />+++ b/m4/ax_require_defined.m4<br />@@ -0,0 +1,38 @@<br />+#<hr /><br />+#    <a href="https://www.gnu.org/software/autoconf-archive/ax_require_defined.html">https://www.gnu.org/software/autoconf-archive/ax_require_defined.html</a><br />+#<hr /><br />+#<br />+# SYNOPSIS<br />+#<br />+#   AX_REQUIRE_DEFINED(MACRO)<br />+#<br />+# DESCRIPTION<br />+#<br />+#   AX_REQUIRE_DEFINED is a simple helper for making sure other macros have<br />+#   been defined and thus are available for use.  This avoids random issues<br />+#   where a macro isn't expanded.  Instead the configure script emits a<br />+#   non-fatal:<br />+#<br />+#     ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found<br />+#<br />+#   It's like AC_REQUIRE except it doesn't expand the required macro.<br />+#<br />+#   Here's an example:<br />+#<br />+#     AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])<br />+#<br />+# LICENSE<br />+#<br />+#   Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org><br />+#<br />+#   Copying and distribution of this file, with or without modification, are<br />+#   permitted in any medium without royalty provided the copyright notice<br />+#   and this notice are preserved. This file is offered as-is, without any<br />+#   warranty.<br />+<br />+#serial 2<br />+<br />+AC_DEFUN([AX_REQUIRE_DEFINED], [dnl<br />+  m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])<br />+])dnl AX_REQUIRE_DEFINED<br />+</pre></blockquote></div><br clear="all">Looks like a lot of duplicated functionality with existing m4 macros.<br>
-- <br>
Rémi Denis-Courmont<br>
Typed on an inconvenient virtual keyboard</body></html>