gecko-dev/build/autoconf/sanitize.m4
serge-sans-paille e198881704 Bug 1900540 - No longer require -fno-sanitize-address-globals-dead-stripping r=glandium
The related bug was fixed in rustc 1.74, and we require 1.76.

This impacts the buildid section which gets modified by asan, so we
exclude it from the asan process through an attribute.

Differential Revision: https://phabricator.services.mozilla.com/D212532
2024-06-18 06:49:32 +00:00

45 lines
1.9 KiB
Plaintext

dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_DEFUN([MOZ_CONFIG_SANITIZE], [
dnl ========================================================
dnl = Use Address Sanitizer
dnl ========================================================
if test -n "$MOZ_ASAN"; then
if test "$CC_TYPE" = clang-cl ; then
# Look for the ASan runtime binary
if test "$TARGET_CPU" = "x86_64"; then
MOZ_CLANG_RT_ASAN_LIB=clang_rt.asan_dynamic-x86_64.dll
else
MOZ_CLANG_RT_ASAN_LIB=clang_rt.asan_dynamic-i386.dll
fi
# 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)
# Suppressing errors in recompiled code.
if test "$OS_ARCH" = "WINNT"; then
CFLAGS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/asan_blacklist_win.txt $CFLAGS"
CXXFLAGS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/asan_blacklist_win.txt $CXXFLAGS"
fi
fi
ASAN_FLAG="-fsanitize=address"
CFLAGS="$ASAN_FLAG $CFLAGS"
CXXFLAGS="$ASAN_FLAG $CXXFLAGS"
if test "$CC_TYPE" != clang-cl ; then
LDFLAGS="$ASAN_FLAG -rdynamic $LDFLAGS"
fi
fi
dnl ========================================================
dnl = Test for whether the compiler is compatible with the
dnl = given sanitize options.
dnl ========================================================
AC_TRY_LINK(,,,AC_MSG_ERROR([compiler is incompatible with sanitize options]))
])