From c8c7e83a777fb8e250057945a3f685710dc1a6a5 Mon Sep 17 00:00:00 2001 From: Cosmin Sabou Date: Wed, 4 Oct 2023 03:34:26 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1854047, bug 1839739) for causing build bustages. CLOSED TREE Backed out changeset 3fb508020251 (bug 1854047) Backed out changeset 056fe66a8b3f (bug 1839739) --- .../config/mozconfigs/linux32/debug-fuzzing | 3 + .../mozconfigs/linux32/nightly-fuzzing-asan | 3 + .../mozconfigs/linux64/asan-fuzzing-ccov | 3 + browser/config/mozconfigs/linux64/debug-asan | 2 + .../config/mozconfigs/linux64/debug-fuzzing | 3 + .../mozconfigs/linux64/debug-fuzzing-noopt | 1 + .../config/mozconfigs/linux64/fuzzing-ccov | 3 + .../config/mozconfigs/linux64/nightly-asan | 2 + .../mozconfigs/linux64/nightly-fuzzing-asan | 3 + .../linux64/nightly-fuzzing-asan-noopt | 3 + .../linux64/nightly-fuzzing-asan-nyx | 3 + .../config/mozconfigs/linux64/tsan-fuzzing | 3 + .../config/mozconfigs/macosx64/debug-fuzzing | 3 + .../mozconfigs/macosx64/nightly-fuzzing-asan | 3 + build/moz.configure/toolchain.configure | 37 +++++++--- build/unix/mozconfig.linux | 6 ++ .../config/mozconfigs/android-arm/debug | 3 + .../mozconfigs/android-arm/debug-searchfox | 3 + .../configure/test_toolkit_moz_configure.py | 72 +++++++------------ .../ci/build/linux-base-toolchains.yml | 2 - .../scripts/misc/build-breakpad-injector.sh | 1 + taskcluster/scripts/misc/build-mar-tools.sh | 1 + toolkit/moz.configure | 11 ++- 23 files changed, 113 insertions(+), 61 deletions(-) diff --git a/browser/config/mozconfigs/linux32/debug-fuzzing b/browser/config/mozconfigs/linux32/debug-fuzzing index 1c1fcaccc8f9..ca18dea3845d 100644 --- a/browser/config/mozconfigs/linux32/debug-fuzzing +++ b/browser/config/mozconfigs/linux32/debug-fuzzing @@ -10,6 +10,9 @@ export MOZ_PACKAGE_JSSHELL=1 ac_add_options --enable-fuzzing unset MOZ_STDCXX_COMPAT +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + # Even in fuzzing builds without sanitizers, the UBSan runtime is pulled # in as a dependency to allow libFuzzer to have rudimentary stacks. # Hence we need to disable jemalloc until bug 1435148 is fully resolved. diff --git a/browser/config/mozconfigs/linux32/nightly-fuzzing-asan b/browser/config/mozconfigs/linux32/nightly-fuzzing-asan index 87eb7c6d8128..68b5e8e7f3eb 100644 --- a/browser/config/mozconfigs/linux32/nightly-fuzzing-asan +++ b/browser/config/mozconfigs/linux32/nightly-fuzzing-asan @@ -15,6 +15,9 @@ ac_add_options --enable-valgrind ac_add_options --enable-fuzzing unset MOZ_STDCXX_COMPAT +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + # Piggybacking UBSan for now since only a small subset of checks are enabled. # A new build can be created when appropriate. ac_add_options --enable-undefined-sanitizer diff --git a/browser/config/mozconfigs/linux64/asan-fuzzing-ccov b/browser/config/mozconfigs/linux64/asan-fuzzing-ccov index d074a98c55ac..21a6c7755d64 100644 --- a/browser/config/mozconfigs/linux64/asan-fuzzing-ccov +++ b/browser/config/mozconfigs/linux64/asan-fuzzing-ccov @@ -19,6 +19,9 @@ export CFLAGS="$CFLAGS --coverage" export CXXFLAGS="$CXXFLAGS --coverage" export LDFLAGS="$LDFLAGS --coverage -Wl,--compress-debug-sections=zlib" +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + ac_add_options --enable-fuzzing unset MOZ_STDCXX_COMPAT diff --git a/browser/config/mozconfigs/linux64/debug-asan b/browser/config/mozconfigs/linux64/debug-asan index f4f08643b1ed..d952ffdf4009 100644 --- a/browser/config/mozconfigs/linux64/debug-asan +++ b/browser/config/mozconfigs/linux64/debug-asan @@ -8,6 +8,8 @@ ac_add_options --enable-valgrind . $topsrcdir/build/unix/mozconfig.asan +ac_add_options --enable-linker=lld + # Build with fuzzing support, so this build can also be used # to analyze fuzzing bugs with rr. ac_add_options --enable-fuzzing diff --git a/browser/config/mozconfigs/linux64/debug-fuzzing b/browser/config/mozconfigs/linux64/debug-fuzzing index c1b737cbb271..e857c7ee7ea8 100644 --- a/browser/config/mozconfigs/linux64/debug-fuzzing +++ b/browser/config/mozconfigs/linux64/debug-fuzzing @@ -10,6 +10,9 @@ export MOZ_PACKAGE_JSSHELL=1 ac_add_options --enable-fuzzing unset MOZ_STDCXX_COMPAT +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + # Even in fuzzing builds without sanitizers, the UBSan runtime is pulled # in as a dependency to allow libFuzzer to have rudimentary stacks. # Hence we need to disable jemalloc until bug 1435148 is fully resolved. diff --git a/browser/config/mozconfigs/linux64/debug-fuzzing-noopt b/browser/config/mozconfigs/linux64/debug-fuzzing-noopt index a3c94adfe1a8..3a7a978650b4 100644 --- a/browser/config/mozconfigs/linux64/debug-fuzzing-noopt +++ b/browser/config/mozconfigs/linux64/debug-fuzzing-noopt @@ -8,6 +8,7 @@ export LLVM_SYMBOLIZER="$MOZ_FETCHES_DIR/llvm-symbolizer/bin/llvm-symbolizer" export MOZ_PACKAGE_JSSHELL=1 ac_add_options --enable-fuzzing +ac_add_options --enable-linker=lld unset MOZ_STDCXX_COMPAT # Even in fuzzing builds without sanitizers, the UBSan runtime is pulled diff --git a/browser/config/mozconfigs/linux64/fuzzing-ccov b/browser/config/mozconfigs/linux64/fuzzing-ccov index bd6d45d01fbc..002d9cd75eac 100644 --- a/browser/config/mozconfigs/linux64/fuzzing-ccov +++ b/browser/config/mozconfigs/linux64/fuzzing-ccov @@ -14,3 +14,6 @@ ac_add_options --enable-fuzzing # on libFuzzer to provide stacks both in the browser fuzzing case as # well as for libFuzzer targets. See also bug 1649062. ac_add_options --disable-crashreporter + +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld diff --git a/browser/config/mozconfigs/linux64/nightly-asan b/browser/config/mozconfigs/linux64/nightly-asan index 03416c580a33..3e91fdf5f42e 100644 --- a/browser/config/mozconfigs/linux64/nightly-asan +++ b/browser/config/mozconfigs/linux64/nightly-asan @@ -7,6 +7,8 @@ ac_add_options --enable-valgrind . $topsrcdir/build/unix/mozconfig.asan +ac_add_options --enable-linker=lld + # Enable ASan for rust code. This is done for specific build tasks rather than # globally in mozconfig.asan because it requires an unstable -Z flag. export RUSTFLAGS="$RUSTFLAGS -Zsanitizer=address" diff --git a/browser/config/mozconfigs/linux64/nightly-fuzzing-asan b/browser/config/mozconfigs/linux64/nightly-fuzzing-asan index 114ced3ad6c0..92b2e5eac3c1 100644 --- a/browser/config/mozconfigs/linux64/nightly-fuzzing-asan +++ b/browser/config/mozconfigs/linux64/nightly-fuzzing-asan @@ -14,6 +14,9 @@ ac_add_options --enable-valgrind # globally in mozconfig.asan because it requires an unstable -Z flag. export RUSTFLAGS="$RUSTFLAGS -Zsanitizer=address" +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + ac_add_options --enable-fuzzing unset MOZ_STDCXX_COMPAT diff --git a/browser/config/mozconfigs/linux64/nightly-fuzzing-asan-noopt b/browser/config/mozconfigs/linux64/nightly-fuzzing-asan-noopt index 4743405afc88..6424ff0396af 100644 --- a/browser/config/mozconfigs/linux64/nightly-fuzzing-asan-noopt +++ b/browser/config/mozconfigs/linux64/nightly-fuzzing-asan-noopt @@ -14,6 +14,9 @@ ac_add_options --enable-valgrind # globally in mozconfig.asan because it requires an unstable -Z flag. export RUSTFLAGS="$RUSTFLAGS -Zsanitizer=address" +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + ac_add_options --enable-fuzzing unset MOZ_STDCXX_COMPAT diff --git a/browser/config/mozconfigs/linux64/nightly-fuzzing-asan-nyx b/browser/config/mozconfigs/linux64/nightly-fuzzing-asan-nyx index e970ce2576f6..852b22d6bb45 100644 --- a/browser/config/mozconfigs/linux64/nightly-fuzzing-asan-nyx +++ b/browser/config/mozconfigs/linux64/nightly-fuzzing-asan-nyx @@ -20,6 +20,9 @@ ac_add_options --enable-valgrind # globally in mozconfig.asan because it requires an unstable -Z flag. export RUSTFLAGS="$RUSTFLAGS -Zsanitizer=address" +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + ac_add_options --enable-snapshot-fuzzing unset MOZ_STDCXX_COMPAT diff --git a/browser/config/mozconfigs/linux64/tsan-fuzzing b/browser/config/mozconfigs/linux64/tsan-fuzzing index c7da44cd2c24..54821a26cdf2 100644 --- a/browser/config/mozconfigs/linux64/tsan-fuzzing +++ b/browser/config/mozconfigs/linux64/tsan-fuzzing @@ -1,4 +1,7 @@ . "$topsrcdir/browser/config/mozconfigs/linux64/tsan" +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + ac_add_options --enable-fuzzing unset MOZ_STDCXX_COMPAT diff --git a/browser/config/mozconfigs/macosx64/debug-fuzzing b/browser/config/mozconfigs/macosx64/debug-fuzzing index 7a852d435030..a1f60d03d3e8 100644 --- a/browser/config/mozconfigs/macosx64/debug-fuzzing +++ b/browser/config/mozconfigs/macosx64/debug-fuzzing @@ -2,6 +2,9 @@ ac_add_options --enable-fuzzing +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + # Need this to prevent name conflicts with the normal nightly build packages export MOZ_PKG_SPECIAL=fuzzing diff --git a/browser/config/mozconfigs/macosx64/nightly-fuzzing-asan b/browser/config/mozconfigs/macosx64/nightly-fuzzing-asan index 2b6ea4f61f59..08a52adfa39c 100644 --- a/browser/config/mozconfigs/macosx64/nightly-fuzzing-asan +++ b/browser/config/mozconfigs/macosx64/nightly-fuzzing-asan @@ -2,6 +2,9 @@ ac_add_options --enable-fuzzing +# gold or lld is required for libFuzzer to work properly +ac_add_options --enable-linker=lld + # Piggybacking UBSan for now since only a small subset of checks are enabled. # A new build can be created when appropriate. ac_add_options --enable-undefined-sanitizer diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index 96a0300b08fd..a10b1a10b744 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -1643,10 +1643,15 @@ set_config("CXX_IS_ICECREAM", cxx_is_icecream) # - otherwise the linker is ld64, either from XCode on macOS, or from cctools-ports when # cross-compiling. # For other OSes: -# - on local developer builds: lld if present and the compiler is clang. Otherwise gold -# is used if present otherwise, whatever the compiler uses by default. -# - on release/official builds: whatever the compiler uses by default, except when the -# compiler is clang, in which case lld is preferred when it's new enough. +# - on local developer builds: lld is used if present and the compiler is clang. Otherwise +# gold is used if present, otherwise, BFD ld is used. +# - on release/official builds: whatever the compiler uses by default, except on Android +# (see enable_linker_default below). Usually what the compiler uses by default is BFD +# ld, except with the Android NDK compiler, where the default varies depending on the +# NDK version. The default also varies by platform and clang version. +# lld is not used by default on Linux and Android because it introduces layout changes +# that prevent elfhack from working. See e.g. +# https://bugzilla.mozilla.org/show_bug.cgi?id=1563654#c2. @template def is_not_winnt_or_sunos(host_or_target): @depends(host_or_target) @@ -1668,10 +1673,26 @@ def enable_gold(value): die("--disable-gold is deprecated, use --enable-linker=something_else instead") +@depends(target, developer_options) +def enable_linker_default(target, developer_options): + # Recent versions of clang default to lld when targetting Android, but we don't + # want that as the default for non developer builds (see above). + # So we want to force the default to whatever it was with older versions of clang, + # but with caveats/workarounds: + # - x86-64 gold has bugs in how it lays out .note.* sections. See bug 1573820. + # - x86-32 gold has a bug when assembly files are built. See bug 1651699. + # That leaves us with aarch64 and armv7, which respectively defaulted to + # bfd and gold. + # On developer builds, select_linker will pick lld if it's not the default. + if target.os == "Android" and not developer_options: + return "bfd" if target.cpu in ("x86", "x86_64", "aarch64") else "gold" + + option( "--enable-linker", nargs=1, - help="Select the linker {bfd, gold, ld64, lld, lld-*, mold}", + help="Select the linker {bfd, gold, ld64, lld, lld-*, mold}{|}", + default=enable_linker_default, when=is_linker_option_enabled, ) @@ -1799,11 +1820,7 @@ def select_linker_tmpl(host_or_target): and ( ( target.kernel != "Darwin" - and ( - developer_options - or host_or_target_str == "host" - or c_compiler.version >= "15.0" - ) + and (developer_options or host_or_target_str == "host") ) or ( target.kernel == "Darwin" diff --git a/build/unix/mozconfig.linux b/build/unix/mozconfig.linux index b63cebe59e31..177d48c23ee4 100644 --- a/build/unix/mozconfig.linux +++ b/build/unix/mozconfig.linux @@ -13,3 +13,9 @@ x11) esac export MOZ_NO_PIE_COMPAT=1 + +if [ -z "$USE_ARTIFACT" -a -z "$TASKCLUSTER_PGO_PROFILE_USE" -a -z "$FORCE_GCC" ]; then + # Use LLD on most builds, for faster builds, but not on shippable ones because we + # want to keep elfhack there, which is incompatible. + ac_add_options --enable-linker=lld +fi diff --git a/mobile/android/config/mozconfigs/android-arm/debug b/mobile/android/config/mozconfigs/android-arm/debug index bcf9cad4c40a..baa329094470 100644 --- a/mobile/android/config/mozconfigs/android-arm/debug +++ b/mobile/android/config/mozconfigs/android-arm/debug @@ -10,4 +10,7 @@ export MOZILLA_OFFICIAL=1 ac_add_options --with-branding=mobile/android/branding/nightly +# Workaround gold bug (see bug 1807993) +ac_add_options --enable-linker=lld + . "$topsrcdir/mobile/android/config/mozconfigs/common.override" diff --git a/mobile/android/config/mozconfigs/android-arm/debug-searchfox b/mobile/android/config/mozconfigs/android-arm/debug-searchfox index 2b3e3ffed4f9..2eb225991766 100644 --- a/mobile/android/config/mozconfigs/android-arm/debug-searchfox +++ b/mobile/android/config/mozconfigs/android-arm/debug-searchfox @@ -10,6 +10,9 @@ export MOZILLA_OFFICIAL=1 ac_add_options --with-branding=mobile/android/branding/nightly +# Workaround gold bug (see bug 1807993) +ac_add_options --enable-linker=lld + ac_add_options --enable-mozsearch-plugin . "$topsrcdir/mobile/android/config/mozconfigs/common.override" diff --git a/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py b/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py index 7d20c0a49e0a..34a2a40f038f 100644 --- a/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py +++ b/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py @@ -11,7 +11,6 @@ from test_toolchain_helpers import CompilerResult from common import BaseConfigureTest from mozbuild.configure.options import InvalidOptionError -from mozbuild.configure.util import Version class TestToolkitMozConfigure(BaseConfigureTest): @@ -154,11 +153,7 @@ class TestToolkitMozConfigure(BaseConfigureTest): # Trick the sandbox into not running too much dep = sandbox._depends[sandbox["c_compiler"]] value_for_depends[(dep,)] = CompilerResult( - compiler="/usr/bin/mockcc", - language="C", - type="clang", - version=Version("16.0"), - flags=[], + compiler="/usr/bin/mockcc", language="C", type="clang", flags=[] ) dep = sandbox._depends[sandbox["readelf"]] value_for_depends[(dep,)] = "/usr/bin/readelf" @@ -170,33 +165,11 @@ class TestToolkitMozConfigure(BaseConfigureTest): ) PACK = ["-Wl,-z,pack-relative-relocs"] - # The typical case with a bootstrap build: linker supports pack-relative-relocs, - # but glibc is old and doesn't. - mockcc = MockCC(True, False) - readelf = ReadElf(True) - self.assertEqual(get_values(mockcc, readelf), ("lld", None, "relr")) - self.assertEqual( - get_values(mockcc, readelf, ["--enable-release"]), ("lld", None, "relr") - ) - self.assertEqual( - get_values(mockcc, readelf, ["--enable-elf-hack"]), ("lld", None, "relr") - ) - self.assertEqual( - get_values(mockcc, readelf, ["--enable-elf-hack=relr"]), - ("lld", None, "relr"), - ) - # LLD is picked by default and enabling elfhack fails because of that. - with self.assertRaises(SystemExit): - get_values(mockcc, readelf, ["--enable-elf-hack=legacy"]) - # If we force to use BFD ld, it works. - self.assertEqual( - get_values( - mockcc, readelf, ["--enable-elf-hack=legacy", "--enable-linker=bfd"] - ), - ("bfd", None, "legacy"), - ) - for mockcc, readelf in ( + # The typical case with a bootstrap build: linker supports pack-relative-relocs, + # but glibc is old and doesn't. We won't use pack-relative-relocs, and will use + # elfhack on release builds, or when explicitly enabled. + (MockCC(True, False), ReadElf(True)), # Linker doesn't support pack-relative-relocs. Glibc is old. (MockCC(False, False), ReadElf(False)), # Linker doesn't support pack-relative-relocs. Glibc is new. @@ -209,15 +182,23 @@ class TestToolkitMozConfigure(BaseConfigureTest): self.assertEqual(get_values(mockcc, readelf), ("lld", None, None)) self.assertEqual( get_values(mockcc, readelf, ["--enable-release"]), - ("lld", None, None), + ("bfd", None, "legacy"), ) + # LLD is picked by default and enabling elfhack fails because of that. with self.assertRaises(SystemExit): get_values(mockcc, readelf, ["--enable-elf-hack"]) - with self.assertRaises(SystemExit): - get_values(mockcc, readelf, ["--enable-elf-hack=relr"]) - # LLD is picked by default and enabling elfhack fails because of that. with self.assertRaises(SystemExit): get_values(mockcc, readelf, ["--enable-elf-hack=legacy"]) + if readelf.with_relr: + # Explicitly enabling relrhack works because pack-relative-relocs are supported. + self.assertEqual( + get_values(mockcc, readelf, ["--enable-elf-hack=relr"]), + ("lld", None, "relr"), + ) + else: + # relrhack doesn't work without pack-relative-relocs support. + with self.assertRaises(SystemExit): + get_values(mockcc, readelf, ["--enable-elf-hack=relr"]) # If we force to use BFD ld, it works. self.assertEqual( get_values( @@ -238,23 +219,17 @@ class TestToolkitMozConfigure(BaseConfigureTest): readelf = ReadElf(True) self.assertEqual(get_values(mockcc, readelf), ("lld", PACK, None)) self.assertEqual( - get_values(mockcc, readelf, ["--enable-release"]), ("lld", PACK, None) - ) - self.assertEqual( - get_values(mockcc, readelf, ["--enable-elf-hack"]), - ("lld", None, "relr"), - ) - self.assertEqual( - get_values(mockcc, readelf, ["--enable-elf-hack=relr"]), - ("lld", None, "relr"), + get_values(mockcc, readelf, ["--enable-release"]), ("bfd", PACK, None) ) # LLD is picked by default and enabling elfhack fails because of that. + with self.assertRaises(SystemExit): + get_values(mockcc, readelf, ["--enable-elf-hack"]) with self.assertRaises(SystemExit): get_values(mockcc, readelf, ["--enable-elf-hack=legacy"]) # If we force to use BFD ld, it works. self.assertEqual( get_values(mockcc, readelf, ["--enable-elf-hack", "--enable-linker=bfd"]), - ("bfd", None, "relr"), + ("bfd", None, "legacy"), ) self.assertEqual( get_values( @@ -262,6 +237,11 @@ class TestToolkitMozConfigure(BaseConfigureTest): ), ("bfd", None, "legacy"), ) + # Explicitly enabling relrhack works because pack-relative-relocs are supported. + self.assertEqual( + get_values(mockcc, readelf, ["--enable-elf-hack=relr"]), + ("lld", None, "relr"), + ) if __name__ == "__main__": diff --git a/taskcluster/ci/build/linux-base-toolchains.yml b/taskcluster/ci/build/linux-base-toolchains.yml index 2d9c908860c4..9e63e54d8a50 100644 --- a/taskcluster/ci/build/linux-base-toolchains.yml +++ b/taskcluster/ci/build/linux-base-toolchains.yml @@ -115,7 +115,6 @@ linux64-base-toolchains-clang/opt: tooltool-downloads: public fetches: toolchain: - - linux64-binutils-2.31.1 - linux64-clang-base - linux64-rust-base - linux64-cbindgen @@ -154,7 +153,6 @@ linux64-base-toolchains-clang/debug: tooltool-downloads: public fetches: toolchain: - - linux64-binutils-2.31.1 - linux64-clang-base - linux64-rust-base - linux64-cbindgen diff --git a/taskcluster/scripts/misc/build-breakpad-injector.sh b/taskcluster/scripts/misc/build-breakpad-injector.sh index 245dae32644d..ecd53e13d1ca 100755 --- a/taskcluster/scripts/misc/build-breakpad-injector.sh +++ b/taskcluster/scripts/misc/build-breakpad-injector.sh @@ -10,6 +10,7 @@ cd $GECKO_PATH export MOZ_OBJDIR=obj-injector echo ac_add_options --enable-project=tools/crashreporter/injector > .mozconfig +echo ac_add_options --enable-linker=lld >> .mozconfig INJECTOR=libbreakpadinjector.so diff --git a/taskcluster/scripts/misc/build-mar-tools.sh b/taskcluster/scripts/misc/build-mar-tools.sh index e80a160e4860..1a813dd77252 100755 --- a/taskcluster/scripts/misc/build-mar-tools.sh +++ b/taskcluster/scripts/misc/build-mar-tools.sh @@ -10,6 +10,7 @@ cd $GECKO_PATH export MOZ_OBJDIR=obj-mar echo ac_add_options --enable-project=tools/update-packaging > .mozconfig +echo ac_add_options --enable-linker=lld >> .mozconfig TOOLCHAINS="clang" diff --git a/toolkit/moz.configure b/toolkit/moz.configure index 6da321515d9a..8f59ba1674f6 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -1498,9 +1498,14 @@ with only_when("--enable-compile-environment"): if enable and enable != ("relr",): return enable - @depends("--enable-elf-hack", when=has_elfhack) - def may_enable_relrhack(enable): - if enable and enable != ("legacy",): + @depends("--enable-elf-hack", "MOZ_AUTOMATION", when=has_elfhack) + def may_enable_relrhack(enable, automation): + # For now, only enable relrhack when explicitly given with + # --enable-elf-hack=relr. On automation, we automatically + # enable it when possible. + if automation and enable and enable != ("legacy",): + return enable + if enable == ("relr",): return enable @depends(