Bug 41142: Complete the toolchain for linux-aarch64
Merge Info
Related Issues
Backporting
Timeline
-
Immediate: patchset needed as soon as possible -
Next Minor Stable Release: patchset that needs to be verified in nightly before backport -
Eventually: patchset that needs to be verified in alpha before backport -
No Backport (preferred): patchset for the next major stable
(Optional) Justification
-
Emergency security update: patchset fixes CVEs, 0-days, etc -
Censorship event: patchset enables censorship circumvention -
Critical bug-fix: patchset fixes a bug in core-functionality -
Consistency: patchset which would make development easier if it were in both the alpha and release branches; developer tools, build system changes, etc -
Sponsor required: patchset required for sponsor -
Other: please explain
Issue Tracking
-
Link resolved issues with appropriate Release Prep issue for changelog generation
Review
Request Reviewer
-
Request review from an applications developer depending on modified system: -
NOTE: if the MR modifies multiple areas, please
/cc
all the relevant reviewers (since gitlab only allows 1 reviewer) - accessibility : henry
- android : clairehurst, dan
- build system : boklm
- extensions : ma1
- firefox internals (XUL/JS/XPCOM) : ma1
- fonts : pierov
- frontend (implementation) : henry
- frontend (review) : donuts, richard
- localization : henry, pierov
- macos : clairehurst, dan
- nightly builds : boklm
- rebases/release-prep : boklm, dan, ma1, pierov, richard
- security : ma1
- signing : boklm, richard
- updater : pierov
- misc/other : pierov, richard
-
NOTE: if the MR modifies multiple areas, please
Change Description
This MR completes the toolchain for the linux-aarch64
target. What this means in practice is it adds the linux-aarch64
target to rust
(plus some other minor changes). Some notes.
- As you know from the way
rust
is built for themacos
target (which I could see explicitly from the build script, but I believe something similar may hold forwindows
), in order to build arust
target for cross-compilation you need the sysroot of that target. This means thatrust
must be built separately for each linux arch, just like you are doing when building it separately for windows and for macos, and that it is not ano_crosscompile
project. - One issue I came across with
rust
is using--set target.aarch64-unknown-linux-gnu.linker=clang
like you are doing for all other targets fails to build the project. Specifically, while building the rust standard library for theaarch64-linux-gnu
target, the build fails complaining that binaries for the wrong architecture are being linked to. From the error message it is very clear thatclang
, which is selected as the linker for that target, was trying to use the host'sx86_64-unknown-linux-gnu-ld
internally as the linker instead ofaarch64-unknown-linux-gnu-ld
. I also found out that this issue is reproducible in more mundane contexts: if I try to cross-compile rust source code foraarch64-unknown-linux-gnu
on x86_64 using asconfig.toml
[target.aarch64-unknown-linux-gnu] linker = "clang"
-target
and so on, similar to what you are doing for themacos
target. The second one, which I found to be very effective (so much so that I've been using it since day one of cross-compilation to build the full browser) is to simply--set target.aarch64-unknown-linux-gnu.linker=aarch64-linux-gnu-gcc
based on the fact that, by default (at least when not failing to select their target likeclang
), bothgcc
andclang
callaarch64-linux-gnu-ld
as their default linker. This does not require any further dependency in the project because, again, building theaarch64-unknown-linux-gnu
rust target already requires the fulllinux-aarch64
sysroot, which is in thegcc-cross
project, so the cross-compiler is imported anyway. And it avoids a wrapper script (which to be honest I didn't even test on its own, let alone on the full browser). - In this MR you can see the cross-compilation logic fully at work. Projects which build host tools (
python
,cmake
, etc.), as well as projects which build target binaries but don't need the cross-compiler to be built (i.e.clang
), as well as projects that don't build neither host nor target (in the sense ofaarch64-linux-gnu
) binaries but are still built in containers which must not--add-architecture
(i.e.wasi-sysroot
) are marked asno_crosscompile
. On the other hand, forbinutils
(which as mentioned in the previous MR is the only project which is both compiled and cross-compiled), one needs to specify which target one wants to build. In this MR we only want the host binutils, so we must tell the other projects to only use thelinux
target when building for linux, or more specifically forlinux-cross
. This is the reason for the two target redefinitions (there will be one more infirefox
).
How Tested
Tested by building the full browsers using this linux-cross branch. With this MR you will be able to build any project for linux-aarch64
apart from firefox
, browser
, linux-packages
and release
(left for a later MR), using
./rbm/rbm build $project --target alpha --target torbrowser-linux-aarch64
Edited by boklm