Bug 1839739 - Default to lld in more cases on Linux. r=firefox-build-system-reviewers,geckoview-reviewers,releng-reviewers,andi,gbrown,m_kato

Differential Revision: https://phabricator.services.mozilla.com/D188676
This commit is contained in:
Mike Hommey 2023-09-25 22:58:28 +00:00
Родитель f10a62a723
Коммит 5dacba3398
22 изменённых файлов: 20 добавлений и 82 удалений

Просмотреть файл

@ -10,9 +10,6 @@ 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.

Просмотреть файл

@ -15,9 +15,6 @@ 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

Просмотреть файл

@ -19,9 +19,6 @@ 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

Просмотреть файл

@ -8,8 +8,6 @@ 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

Просмотреть файл

@ -10,9 +10,6 @@ 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.

Просмотреть файл

@ -8,7 +8,6 @@ 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

Просмотреть файл

@ -14,6 +14,3 @@ 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

Просмотреть файл

@ -7,8 +7,6 @@ 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"

Просмотреть файл

@ -14,9 +14,6 @@ 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

Просмотреть файл

@ -14,9 +14,6 @@ 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

Просмотреть файл

@ -20,9 +20,6 @@ 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

Просмотреть файл

@ -1,7 +1,4 @@
. "$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

Просмотреть файл

@ -2,9 +2,6 @@
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

Просмотреть файл

@ -2,9 +2,6 @@
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

Просмотреть файл

@ -1643,15 +1643,10 @@ 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 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.
# - 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.
@template
def is_not_winnt_or_sunos(host_or_target):
@depends(host_or_target)
@ -1673,26 +1668,10 @@ 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}{|}",
default=enable_linker_default,
help="Select the linker {bfd, gold, ld64, lld, lld-*, mold}",
when=is_linker_option_enabled,
)
@ -1820,7 +1799,11 @@ def select_linker_tmpl(host_or_target):
and (
(
target.kernel != "Darwin"
and (developer_options or host_or_target_str == "host")
and (
developer_options
or host_or_target_str == "host"
or c_compiler.version >= "15.0"
)
)
or (
target.kernel == "Darwin"

Просмотреть файл

@ -13,9 +13,3 @@ 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

Просмотреть файл

@ -10,7 +10,4 @@ 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"

Просмотреть файл

@ -10,9 +10,6 @@ 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"

Просмотреть файл

@ -11,6 +11,7 @@ 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):
@ -153,7 +154,11 @@ 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", flags=[]
compiler="/usr/bin/mockcc",
language="C",
type="clang",
version=Version("16.0"),
flags=[],
)
dep = sandbox._depends[sandbox["readelf"]]
value_for_depends[(dep,)] = "/usr/bin/readelf"
@ -182,7 +187,7 @@ class TestToolkitMozConfigure(BaseConfigureTest):
self.assertEqual(get_values(mockcc, readelf), ("lld", None, None))
self.assertEqual(
get_values(mockcc, readelf, ["--enable-release"]),
("bfd", None, "legacy"),
("lld", None, None),
)
# LLD is picked by default and enabling elfhack fails because of that.
with self.assertRaises(SystemExit):
@ -219,7 +224,7 @@ class TestToolkitMozConfigure(BaseConfigureTest):
readelf = ReadElf(True)
self.assertEqual(get_values(mockcc, readelf), ("lld", PACK, None))
self.assertEqual(
get_values(mockcc, readelf, ["--enable-release"]), ("bfd", PACK, None)
get_values(mockcc, readelf, ["--enable-release"]), ("lld", PACK, None)
)
# LLD is picked by default and enabling elfhack fails because of that.
with self.assertRaises(SystemExit):

Просмотреть файл

@ -113,6 +113,7 @@ linux64-base-toolchains-clang/opt:
tooltool-downloads: public
fetches:
toolchain:
- linux64-binutils-2.31.1
- linux64-clang-base
- linux64-rust-base
- linux64-cbindgen
@ -150,6 +151,7 @@ linux64-base-toolchains-clang/debug:
tooltool-downloads: public
fetches:
toolchain:
- linux64-binutils-2.31.1
- linux64-clang-base
- linux64-rust-base
- linux64-cbindgen

Просмотреть файл

@ -10,7 +10,6 @@ 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

Просмотреть файл

@ -10,7 +10,6 @@ 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"