Backed out 3 changesets (bug 1900540, bug 1896414) for causing Gtest failures.

Backed out changeset b1e69d42bb91 (bug 1896414)
Backed out changeset 2740e0cb1ac8 (bug 1896414)
Backed out changeset 073d686a1233 (bug 1900540)
This commit is contained in:
Iulian Moraru 2024-06-11 22:40:58 +03:00
parent b00dfe1db6
commit 5944e49dc4
9 changed files with 68 additions and 84 deletions

1
aclocal.m4 vendored
View File

@ -12,6 +12,7 @@ builtin(include, build/autoconf/mozheader.m4)dnl
builtin(include, build/autoconf/compiler-opts.m4)dnl builtin(include, build/autoconf/compiler-opts.m4)dnl
builtin(include, build/autoconf/arch.m4)dnl builtin(include, build/autoconf/arch.m4)dnl
builtin(include, build/autoconf/clang-plugin.m4)dnl builtin(include, build/autoconf/clang-plugin.m4)dnl
builtin(include, build/autoconf/sanitize.m4)dnl
MOZ_PROG_CHECKMSYS() MOZ_PROG_CHECKMSYS()

View File

@ -0,0 +1,51 @@
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_FLAGS="-fsanitize=address"
if test "$OS_TARGET" = Linux; then
# -fno-sanitize-address-globals-dead-stripping is used to work around
# https://github.com/rust-lang/rust/issues/113404
# It forces clang not to use __asan_register_elf_globals/__asan_globals_registered,
# avoiding the conflict with rust.
ASAN_FLAGS="$ASAN_FLAGS -fno-sanitize-address-globals-dead-stripping"
fi
CFLAGS="$ASAN_FLAGS $CFLAGS"
CXXFLAGS="$ASAN_FLAGS $CXXFLAGS"
if test "$CC_TYPE" != clang-cl ; then
LDFLAGS="-fsanitize=address -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]))
])

View File

@ -2428,86 +2428,6 @@ def asan():
return True return True
with only_when(asan):
option(
env="MOZ_CLANG_RT_ASAN_LIB_PATH",
nargs=1,
help="Path to clang runtime asan library",
)
@depends(
c_compiler,
target,
"MOZ_CLANG_RT_ASAN_LIB_PATH",
)
@imports("os")
@imports("glob")
def clang_rt_asan_lib_path(c_compiler, target, clang_rt_asan_lib):
if clang_rt_asan_lib:
if os.path.exists(clang_rt_asan_lib[0]):
return clang_rt_asan_lib[0]
else:
die(
f"Specified MOZ_CLANG_RT_ASAN_LIB_PATH value '{clang_rt_asan_lib}' doesn't exist. "
)
# Look for the ASan runtime binary
if c_compiler.type == "clang-cl":
cpu = {"x86": "i386"}.get(target.cpu, target.cpu)
clang_rt_asan_lib = f"clang_rt.asan_dynamic-{target.cpu}.dll"
subdir = "windows"
elif target.os == "Android":
cpu = {"x86": "i686"}.get(target.cpu, target.cpu)
clang_rt_asan_lib = f"libclang_rt.asan-{cpu}-android.so"
subdir = "linux"
else:
return
search_path = os.path.join(
os.path.dirname(c_compiler.compiler),
"..",
"lib",
"clang",
"*",
"lib",
subdir,
clang_rt_asan_lib,
)
if candidates := glob.glob(search_path):
return candidates[0]
die(
f"Couldn't find {clang_rt_asan_lib}. "
f"It should be available in the same location as {c_compiler.type}."
)
set_config("MOZ_CLANG_RT_ASAN_LIB_PATH", clang_rt_asan_lib_path)
@depends(
c_compiler,
target,
compilation_flags,
linker_flags,
build_environment,
when=asan,
)
def asan_flags(c_compiler, target, compilation_flags, linker_flags, build_env):
if c_compiler.type == "clang-cl":
# Suppressing errors in recompiled code.
if target.os == "WINNT":
flag = f"-fsanitize-blacklist={build_env.topsrcdir}/build/sanitizers/asan_blacklist_win.txt"
compilation_flags.cflags.append(flag)
compilation_flags.cxxflags.append(flag)
asan_flag = "-fsanitize=address"
compilation_flags.cflags.append(asan_flag)
compilation_flags.cxxflags.append(asan_flag)
if c_compiler.type != "clang-cl":
linker_flags.ldflags.extend([asan_flag, "-rdynamic"])
add_old_configure_assignment("MOZ_ASAN", asan) add_old_configure_assignment("MOZ_ASAN", asan)
set_define("MOZ_ASAN", True, when=asan) set_define("MOZ_ASAN", True, when=asan)
set_config("MOZ_ASAN", True, when=asan) set_config("MOZ_ASAN", True, when=asan)
@ -2712,7 +2632,6 @@ any_ubsan = ubsan | ub_signed_overflow_san | ub_unsigned_overflow_san
set_define("MOZ_UBSAN", True, when=any_ubsan) set_define("MOZ_UBSAN", True, when=any_ubsan)
set_config("MOZ_UBSAN", any_ubsan) set_config("MOZ_UBSAN", any_ubsan)
# Security Hardening # Security Hardening
# ============================================================== # ==============================================================

View File

@ -7,6 +7,7 @@ if [ -d "$MOZ_FETCHES_DIR/clang" ]; then
export MOZ_COPY_PDBS=1 export MOZ_COPY_PDBS=1
export LLVM_SYMBOLIZER="$MOZ_FETCHES_DIR/llvm-symbolizer/bin/llvm-symbolizer.exe" export LLVM_SYMBOLIZER="$MOZ_FETCHES_DIR/llvm-symbolizer/bin/llvm-symbolizer.exe"
export MOZ_CLANG_RT_ASAN_LIB_PATH="${CLANG_LIB_DIR}/clang_rt.asan_dynamic-x86_64.dll"
fi fi
# Enable ASan specific code and build workarounds # Enable ASan specific code and build workarounds

1
js/src/aclocal.m4 vendored
View File

@ -12,6 +12,7 @@ builtin(include, ../../build/autoconf/mozheader.m4)dnl
builtin(include, ../../build/autoconf/compiler-opts.m4)dnl builtin(include, ../../build/autoconf/compiler-opts.m4)dnl
builtin(include, ../../build/autoconf/arch.m4)dnl builtin(include, ../../build/autoconf/arch.m4)dnl
builtin(include, ../../build/autoconf/clang-plugin.m4)dnl builtin(include, ../../build/autoconf/clang-plugin.m4)dnl
builtin(include, ../../build/autoconf/sanitize.m4)dnl
define([__MOZ_AC_INIT_PREPARE], defn([AC_INIT_PREPARE])) define([__MOZ_AC_INIT_PREPARE], defn([AC_INIT_PREPARE]))
define([AC_INIT_PREPARE], define([AC_INIT_PREPARE],

View File

@ -168,6 +168,8 @@ dnl Configure platform-specific CPU architecture compiler options.
dnl ============================================================== dnl ==============================================================
MOZ_ARCH_OPTS MOZ_ARCH_OPTS
MOZ_CONFIG_SANITIZE
dnl ======================================================== dnl ========================================================
dnl GNU specific defaults dnl GNU specific defaults
dnl ======================================================== dnl ========================================================

View File

@ -17,9 +17,8 @@
* 2) They implement this functionality *safely*, without invoking signed * 2) They implement this functionality *safely*, without invoking signed
* integer overflow that has undefined behavior in C++. * integer overflow that has undefined behavior in C++.
* 3) They play nice with compiler-based integer-overflow sanitizers (see * 3) They play nice with compiler-based integer-overflow sanitizers (see
* build/moz.configure/toolchain.configure), that in appropriately * build/autoconf/sanitize.m4), that in appropriately configured builds
* configured builds verify at runtime that integral arithmetic doesn't * verify at runtime that integral arithmetic doesn't overflow.
* overflow.
*/ */
#ifndef mozilla_WrappingOperations_h #ifndef mozilla_WrappingOperations_h

View File

@ -18,6 +18,12 @@ unset ENABLE_CLANG_PLUGIN
# We don't have a native LLVM_SYMBOLIZER yet # We don't have a native LLVM_SYMBOLIZER yet
unset LLVM_SYMBOLIZER unset LLVM_SYMBOLIZER
# Add the path to the clang_rt used, so it can be packaged with the build.
if [ -d "$MOZ_FETCHES_DIR/clang" ]; then
CLANG_LIB_DIR="$(cd $MOZ_FETCHES_DIR/clang/lib/clang/*/lib/linux && pwd)"
export MOZ_CLANG_RT_ASAN_LIB_PATH="${CLANG_LIB_DIR}/libclang_rt.asan-x86_64-android.so"
fi
# Package js shell. # Package js shell.
export MOZ_PACKAGE_JSSHELL=1 export MOZ_PACKAGE_JSSHELL=1

View File

@ -168,6 +168,10 @@ if test "$COMPILE_ENVIRONMENT"; then
MOZ_ARCH_OPTS MOZ_ARCH_OPTS
fi # COMPILE_ENVIRONMENT fi # COMPILE_ENVIRONMENT
if test -n "$COMPILE_ENVIRONMENT"; then
MOZ_CONFIG_SANITIZE
fi
dnl ======================================================== dnl ========================================================
dnl GNU specific defaults dnl GNU specific defaults
dnl ======================================================== dnl ========================================================