Bug 1084157 - Make --enable-address-sanitizer pass the correct -fsanitize arguments to the toolchain; r=glandium
☠☠ backed out by 6c094e2b6e57 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 22 Oct 2014 08:30:05 -0400
changeset 238114 f353f95ad2935fb8065475140ab42c19161dd475
parent 238113 d971418760a5527cef3f61add4905a6f3c8c3e82
child 238115 2b1c2663f92aa2f9d51e0e43da6dd3b57da7fbe5
push id660
push userraliiev@mozilla.com
push dateWed, 18 Feb 2015 20:30:48 +0000
treeherdermozilla-release@49e493494178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1084157
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1084157 - Make --enable-address-sanitizer pass the correct -fsanitize arguments to the toolchain; r=glandium
build/unix/mozconfig.asan
configure.in
js/src/configure.in
--- a/build/unix/mozconfig.asan
+++ b/build/unix/mozconfig.asan
@@ -4,20 +4,19 @@ MOZ_AUTOMATION_L10N_CHECK=0
 . "$topsrcdir/build/mozconfig.common"
 
 # Use Clang as specified in manifest
 export CC="$topsrcdir/clang/bin/clang -fgnu89-inline"
 export CXX="$topsrcdir/clang/bin/clang++"
 export LLVM_SYMBOLIZER="$topsrcdir/clang/bin/llvm-symbolizer"
 
 # Mandatory flags for ASan
-export ASANFLAGS="-fsanitize=address -Dxmalloc=myxmalloc -fPIC"
+export ASANFLAGS="-Dxmalloc=myxmalloc -fPIC"
 export CFLAGS="$ASANFLAGS"
 export CXXFLAGS="$ASANFLAGS"
-export LDFLAGS="-fsanitize=address"
 
 # Enable ASan specific code and build workarounds
 ac_add_options --enable-address-sanitizer
 
 # Mandatory options required for ASan builds (both on Linux and Mac)
 export MOZ_DEBUG_SYMBOLS=1
 ac_add_options --enable-debug-symbols
 ac_add_options --disable-install-strip
--- a/configure.in
+++ b/configure.in
@@ -1269,17 +1269,22 @@ if test -n "$MOZ_ASAN"; then
         # Look for clang_rt.asan_dynamic-i386.dll
         MOZ_CLANG_RT_ASAN_LIB=clang_rt.asan_dynamic-i386.dll
         # We use MOZ_PATH_PROG in order to get a Windows style path.
         MOZ_PATH_PROG(MOZ_CLANG_RT_ASAN_LIB_PATH, $MOZ_CLANG_RT_ASAN_LIB)
         if test -z "$MOZ_CLANG_RT_ASAN_LIB_PATH"; then
             AC_MSG_ERROR([Couldn't find $MOZ_CLANG_RT_ASAN_LIB.  It should be available in the same location as clang-cl.])
         fi
         AC_SUBST(MOZ_CLANG_RT_ASAN_LIB_PATH)
-    fi
+    else
+        # We link through the compiler only on non-Windows.
+        LDFLAGS="$LDFLAGS -fsanitize=address"
+    fi
+    CFLAGS="$CFLAGS -fsanitize=address"
+    CXXFLAGS="$CXXFLAGS -fsanitize=address"
     AC_DEFINE(MOZ_ASAN)
     MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
 fi
 AC_SUBST(MOZ_ASAN)
 
 dnl ========================================================
 dnl = Use Memory Sanitizer
 dnl ========================================================
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -1068,16 +1068,22 @@ dnl ====================================
 dnl = Use Address Sanitizer
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
     MOZ_ASAN=1,
     MOZ_ASAN= )
 if test -n "$MOZ_ASAN"; then
     MOZ_LLVM_HACKS=1
+    if test -z "$CLANG_CL"; then
+        # We link through the compiler only on non-Windows.
+        LDFLAGS="$LDFLAGS -fsanitize=address"
+    fi
+    CFLAGS="$CFLAGS -fsanitize=address"
+    CXXFLAGS="$CXXFLAGS -fsanitize=address"
     AC_DEFINE(MOZ_ASAN)
     MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
 fi
 AC_SUBST(MOZ_ASAN)
 
 dnl ========================================================
 dnl = Use Memory Sanitizer
 dnl ========================================================