[vlc-devel] [PATCH 2/2] configure: add a with-sanitizer switch
Shaleen Jain
shaleen.jain95 at gmail.com
Fri Aug 25 09:41:54 CEST 2017
On Fri, 2017-08-25 at 09:32 +0200, Thomas Guillem wrote:
>
> On Thu, Aug 24, 2017, at 14:33, Shaleen Jain wrote:
> > Add an option to compile with a set of the
> > recommended flags for the various santizers.
> >
> > Multiple comma separated sanitizers can be specified.
> >
> > This patch also disables no-undefined-symbols(-Wl,-z,defs)
> > only when this switch is used, to avoid link errors, mainly with
> > asan.
> > ---
> > configure.ac | 37 +++++++++++++++++++++++++++++++++++--
> > 1 file changed, 35 insertions(+), 2 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 9214908171..3400fd4f6c 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -1015,6 +1015,39 @@ AS_IF([test "${SYS}" != "mingw32" -a
> > "${SYS}" !=
> > "os2"], [
> > AS_IF([test "${ac_cv_c_visibility_hidden}" = "no"],
> > [VLC_RESTORE_FLAGS])
> > ])
> >
> > +dnl
> > +dnl Sanitizer flags
> > +dnl
> > +AC_ARG_WITH([sanitizer],
> > +
> > [AS_HELP_STRING([--with-
> > sanitizer=(address/memory/undefined/thread)],
> > + [build with sanitizer flags (default disabled)])],
> > + [],
> > + [with_sanitizer=no])
> > +
> > +AS_VAR_IF(with_sanitizer, no, [], [
> > + AX_CHECK_COMPILE_FLAG([-fsanitize=${with_sanitizer}], [
> > + AX_APPEND_FLAG([-fsanitize=${with_sanitizer}])
> > + AX_APPEND_FLAG([-fsanitize=${with_sanitizer}], [CXXFLAGS])
> > + AX_APPEND_FLAG([-fsanitize=${with_sanitizer}], [LDFLAGS])
> > + ], [
> > + AC_MSG_ERROR(["-fsanitize=${with_sanitizer} not
> > supported!"])
> > + ])
> > + AX_APPEND_FLAG([-g])
> > + AX_APPEND_FLAG([-g], [CXXFLAGS])
> > +
> > + AS_IF([test -z "${with_sanitizer##*address*}" ], [
> > + AX_APPEND_COMPILE_FLAGS([-fsanitize-address-use-after-scope
> > -fno-omit-frame-pointer])
> > + AX_APPEND_COMPILE_FLAGS([-fsanitize-address-use-after-scope
> > -fno-omit-frame-pointer], [CXXFLAGS])
> > + ])
> > + AS_IF([test -z "${with_sanitizer##*memory*}" ], [
> > + AX_APPEND_COMPILE_FLAGS([-fPIE -pie])
> > + AX_APPEND_COMPILE_FLAGS([-fPIE -pie], [CXXFLAGS])
> > + ])
> > + AS_IF([test -z "${with_sanitizer##*thread*}" ], [
> > + AX_APPEND_COMPILE_FLAGS([-fPIE -pie])
> > + AX_APPEND_COMPILE_FLAGS([-fPIE -pie], [CXXFLAGS])
> > + ])
> > +])
>
> Should we also force the -O1 CFLAGS ? cf.
> https://clang.llvm.org/docs/AddressSanitizer.html#usage
-O1 or higher is recommended and -O2 is currently used for all builds
when optimizations are disabled and -O3 with optimizations enabled.
>
> >
> > dnl
> > dnl Enable/disable optimizations
> > @@ -1113,7 +1146,7 @@ AC_CACHE_CHECK([if linker supports -z,defs],
> > [ac_cv_ld_z_defs], [
> > ac_cv_ld_z_defs="no"
> > ])
> > ])
> > -AS_IF([test "${ac_cv_ld_z_defs}" = "no"], [VLC_RESTORE_FLAGS])
> > +AS_IF([test "${ac_cv_ld_z_defs}" = "no" -o "x$with_sanitizer" !=
> > xno],
> > [VLC_RESTORE_FLAGS])
> >
> > dnl Check for __attribute__((packed))
> > AC_CACHE_CHECK([for __attribute__((packed))],
> > @@ -4091,7 +4124,7 @@ AC_SUBST(soliddatadir)
> > AM_CONDITIONAL(KDE_SOLID, [test "x${soliddatadir}" != "x"])
> >
> > dnl
> > -dnl Check wether we have the PROCESS_MITIGATION_IMAGE_LOAD_POLICY
> > +dnl Check wether we have the PROCESS_MITIGATION_IMAGE_LOAD_POLICY
> > dnl It should only be available when building for win10, but some
> > SDKs
> > define it unconditionnaly
> > dnl
> > if test "${SYS}" = "mingw32"; then
> > --
> > 2.14.1
> >
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
--
Regards,
Shaleen Jain
More information about the vlc-devel
mailing list