Build more linux local toolchains against the sysroot
Categories
(Firefox Build System :: Toolchains, task)
Tracking
(firefox158 fixed)
| Tracking | Status | |
|---|---|---|
| firefox158 | --- | fixed |
People
(Reporter: jcristau, Assigned: jcristau)
References
Details
Attachments
(6 external files)
Several toolchains are compiled and linked against the docker image's headers
and libraries rather than against an in-tree sysroot, so the glibc floor of
the shipped binary follows whatever image they happen to be built in. Bug
2010489 moves the toolchain tasks to a Debian 13 image and makes that visible:
| toolchain | before | deb13 | with patches |
|---|---|---|---|
| xar | 2.34 | 2.38 | 2.14 |
| mkbom | 2.34 | 2.38 | 2.14 |
| winchecksec | 2.14 | 2.34 | 2.14 |
| upx | 2.14 | 2.38 | 2.14 |
| gn | 2.18 | 2.38 | 2.18 |
| wine | 2.29 | 2.38 | (not converted, see below) |
(max GLIBC_* symbol version, from readelf -V on the real artifacts.)
These are all local-toolchain: true, so mach bootstrap hands them to
developers on arbitrary distributions, and GLIBC_2.38 excludes Ubuntu 22.04
(2.35), Debian 12 (2.36) and Rocky 9 (2.34). gn additionally broke CI:
source-test-vendor-verify-gfx runs it to re-vendor gfx/angle and failed
with
/builds/worker/fetches/gn/gn: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found
which bug 2065412 works around by moving the static-analysis-build image to
Debian 13.
Toolchains built through sysroot-aware scripts were unaffected throughout:
build-clang.py keeps clang at GLIBC_2.17 and build-rust-based-toolchain.sh
keeps the Rust tools at 2.18. The fix is to make these do the same.
The compiler is not itself the problem: build-binutils.sh uses the image's
gcc with --sysroot in CFLAGS and is unaffected. The conversions here also
switch to the fetched clang, because that is what the existing sysroot-using
scripts do (build-dmg-hfsplus.sh, build-msix-packaging.sh) and, for gn,
because the sysroot's libstdc++ has to be the one in use.
Notes on the individual conversions:
-
gnneedslinux64-toolchain-sysroot-gcc10rather than
linux64-toolchain-sysroot: it is built as C++23 and uses<concepts>and
<ranges>, which the libstdc++ 8 in the latter does not have.cctools-port
andnode-22already use the gcc10 sysroot for the same reason. The symbols
pulling in GLIBC_2.38 were the__isoc23_str*redirects glibc applies to
strtoland friends for__cplusplus >= 202302L, so older headers remove
the redirect rather than papering over it. -
xarneeds anxml2-configshim backed by pkg-config: its configure can
only locate libxml2 throughAC_PATH_PROG(xml2-config), and sysroots ship no
/usr/bin. Without it the build silently combines the host's libxml2 headers
with the sysroot's older library. -
xaralso lets us droplibzstd-devfrom the toolchain-build image, which
bug 2010574 only added because Debian 13's openssl pulls zstd into
pkg-config --static --libs libcrypto. The sysroot's openssl does not. That
also stops gcc autodetecting zstd, which was silently adding a
libzstd.so.1dependency to the gcc toolchains. The explicit
-DLLVM_ENABLE_ZSTD=OFFand--without-zstdstay, to pin autodetection
that would otherwise vary with the image's contents.Consequences of building xar against the sysroot, for the record: the
statically linked libcrypto becomes openssl 1.0.1t (xar only uses the EVP
digest functions, no TLS or certificate code); thatlibcrypto.ais not
built PIC, so the binary is no longer a PIE; and the sysroot haslzma.h
where the image did not, so xar gains lzma support and aliblzma.so.5
dependency. -
wineis deliberately left alone. Its configure probes-mabi=mson the
host compiler; gcc supports it and clang does not, and when that check fails
wine setsDLLEXT=""and switches from ELF.dll.soUnix builtins to
PE-only, which is a structural change to the artifact rather than a
portability fix. Building with gcc against the sysroot instead would lose
linux/memfd.h,linux/ntsync.handlinux/userfaultfd.h(jessie's
linux-libc-devis 3.16), silently disabling memfd-backed mappings and the
ntsync fast path. Pinning the task to the Debian 12 image would only buy
2.38 -> 2.36, still above Ubuntu 22.04's 2.35
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Comment 1•2 months ago
|
||
upx was built with the docker image's headers and libraries, so the
shipped binary's glibc floor followed the image: moving to Debian 13
took it from GLIBC_2.14 to GLIBC_2.38, which excludes Ubuntu 22.04,
Debian 12 and Rocky 9. It is a local-toolchain, so mach bootstrap hands
it to developers on arbitrary distributions.
upx links nothing externally -- UCL and zlib are vendored and built
static, and bzip2, zstd and threads are disabled in its CMakeLists --
so pointing cmake at the sysroot is enough. Follows the same pattern as
build-dmg-hfsplus.sh.
win64-upx shares the script and is unaffected: the new flags are in the
non-Msys branch.
Updated•2 months ago
|
| Assignee | ||
Comment 2•2 months ago
|
||
mkbom was built with the docker image's compiler, so the shipped
binary's glibc floor followed the image: moving to Debian 13 took it
from GLIBC_2.34 to GLIBC_2.38. It is a local-toolchain, so mach
bootstrap hands it to developers on arbitrary distributions.
bomutils assigns CXXFLAGS and LDFLAGS with = rather than ?= in its
Makefile, so overriding them on the make command line would drop its
own hardening flags. The sysroot flags go into CXX instead.
The task already fetched clang and the sysroot; it just wasn't using
them. Measured locally: GLIBC_2.38 -> GLIBC_2.14.
| Assignee | ||
Comment 3•2 months ago
|
||
winchecksec was built with the docker image's headers and libraries, so
the shipped binary's glibc floor followed the image: moving to Debian 13
took it from GLIBC_2.14 to GLIBC_2.34. It is a local-toolchain, so mach
bootstrap hands it to developers on arbitrary distributions.
The task fetched neither clang nor a sysroot, and build-winchecksec.sh
had no case for x86_64-unknown-linux-gnu, so the linux build fell
through with no cmake flags at all. Add the fetches and a linux case
mirroring build-msix-packaging.sh.
win64-winchecksec shares the script and is unaffected. Measured locally:
GLIBC_2.34 -> GLIBC_2.14, and pe-parse's -Werror block still compiles
clean under clang with the sysroot.
| Assignee | ||
Comment 4•2 months ago
|
||
gn was built with the docker image's gcc, so the shipped binary's glibc
floor followed the image: moving to Debian 13 took it from GLIBC_2.18 to
GLIBC_2.38. That broke source-test-vendor-verify-gfx, which runs gn to
re-vendor gfx/angle on the static-analysis-build image; bug 2065412
worked around it by moving that image to Debian 13, but the binary is
also a local-toolchain handed to developers on arbitrary distributions.
The symbols pulling in GLIBC_2.38 are the __isoc23_str* redirects glibc
applies to strtol and friends for __cplusplus >= 202302L, and gn is
built as C++23. Building against older headers removes the redirect
rather than papering over it.
gn needs linux64-toolchain-sysroot-gcc10 rather than
linux64-toolchain-sysroot: it uses <concepts> and <ranges>, which the
libstdc++ 8 in the latter does not have. cctools-port and node-22
already use the gcc10 sysroot for the same reason.
build/gen.py bakes CXX, CFLAGS+CXXFLAGS and LDFLAGS into build.ninja at
generation time and has no cxx-vs-cc distinction, so the environment
variables have to be set before it runs. The mac and win64 gn builds set
their own and are unaffected; build-gn-common.sh is untouched.
| Assignee | ||
Comment 5•2 months ago
|
||
xar was built with the docker image's headers and libraries even though
its task already fetched clang and a sysroot. Moving to Debian 13 took
the shipped binary from GLIBC_2.34 to GLIBC_2.38 and added a
libzstd.so.1 dependency, by way of deb13's openssl pulling zstd into
pkg-config --static --libs libcrypto. It is a local-toolchain, so mach
bootstrap hands it to developers on arbitrary distributions.
xar's configure can only locate libxml2 through xml2-config, which
sysroots do not ship because they contain no /usr/bin. Left alone it
combines the host's libxml2 headers with the sysroot's library, so pass
a small shim backed by pkg-config.
The sysroot's openssl is 1.0.1t, which does not pull in zstd, so
libzstd-dev is no longer needed in the image; bug 2010574 only added it
for xar. Dropping it also stops gcc autodetecting zstd, which was
silently adding a libzstd.so.1 dependency to the gcc toolchains. The
explicit -DLLVM_ENABLE_ZSTD=OFF and --without-zstd stay: they pin
autodetection that would otherwise vary with the image's contents.
Other consequences worth knowing:
- the statically linked libcrypto becomes the sysroot's openssl 1.0.1t.
xar only uses the EVP digest functions, no TLS or certificate code. - that libcrypto.a is not built PIC, so the binary can no longer be a
PIE. - the sysroot has lzma.h where the image did not, so xar gains lzma
support and a liblzma.so.5 dependency.
Measured locally: GLIBC_2.38 -> GLIBC_2.14, configure resolves libxml
2.9.1 with no host/sysroot split, and create/extract roundtrips pass for
sha1, sha256 and md5 with gzip, bzip2 and no compression.
Comment 6•2 months ago
|
||
was silently adding a libzstd.so.1 dependency to the gcc toolchains
Would it be possible to add a test for this?
| Assignee | ||
Comment 7•2 months ago
|
||
(In reply to Sylvestre Ledru [:Sylvestre] from comment #6)
was silently adding a libzstd.so.1 dependency to the gcc toolchains
Would it be possible to add a test for this?
You'd have to be more specific. But either way, libzstd.so.1 isn't a particularly esoteric dependency these days, so this is a note on that non-obvious change in passing more than pointing out a problem, IMO.
| Assignee | ||
Comment 11•2 months ago
|
||
The task already fetched a sysroot but never used it: build-breakpad-injector.sh
writes a mozconfig with no --with-sysroot, and the bootstrapped sysroot only
applies when bootstrap is enabled, which it isn't under MOZ_AUTOMATION. So the
build used the docker image's libstdc++ headers and the library's ABI floor
followed the image, going from GLIBCXX_3.4.29 to GLIBCXX_3.4.31 on Debian 13.
Debian 12 provides GLIBCXX_3.4.30, so the resulting libbreakpadinjector.so
could not be dlopen'd there, and every jit-test that injects it failed with
MOZ_CRASH(Failed to load library).
Use sysroot-x86_64-linux-gnu rather than linux64-toolchain-sysroot: the
injector is built as C++20 and the latter only has libstdc++ 8. That also
matches the sibling minidump-stackwalk task and ordinary Firefox builds.
The resulting library needs GLIBC_2.14 and GLIBCXX_3.4, i.e. rather better
than the GLIBC_2.34 and GLIBCXX_3.4.29 it needed before Debian 13.
| Assignee | ||
Comment 12•2 months ago
|
||
2 things:
- task that fetch gcc, which with bug 2010489 requires a newer glibc; fixed by bug 2070457 and bug 2070456
- breakpad-injector isn't built against the sysroot; would be fixed by either bug 2070456 or comment 11 here
Comment 13•2 months ago
|
||
Comment 14•2 months ago
|
||
Comment 15•2 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/ef8d1477898e
https://hg.mozilla.org/mozilla-central/rev/0247d847e764
https://hg.mozilla.org/mozilla-central/rev/f864c8fa9ebe
https://hg.mozilla.org/mozilla-central/rev/86b6471c5819
https://hg.mozilla.org/mozilla-central/rev/75ced0b58195
https://hg.mozilla.org/mozilla-central/rev/37b80b85bc44
https://hg.mozilla.org/mozilla-central/rev/cf7bf384b191
Description
•