Commit 3176328
committed
feat: support aarch64 hosts via a host_arch attribute
Every toolchain this module generates hardcodes
`exec_compatible_with = [linux, x86_64]` -- it is a string literal in the hub's
BUILD template, while target_compatible_with beside it is a format field. So on
an aarch64 host Bazel matches no cc toolchain at all and every C/C++ action fails
resolution, not just cross-compiles.
The binaries to fix that already exist: gcc-builds has published `-host-aarch64`
archives since 08072026, covering aarch64, armv7 and x86_64 targets for every GCC
version pinned to 08072026 or later (14.3.0, 15.2.0, 16.1.0 and 16.2.0). Only the
Starlark wiring was missing.
`host_arch` names the architecture the toolchain binaries RUN on. It defaults to
`rctx.os.arch`, so a native build on either architecture needs no configuration,
and it drives three things:
- which archive is fetched, via a host dimension on AVAILABLE_GCC_VERSIONS;
- `exec_compatible_with`, now a templated hub attribute defaulting to
`[linux, {host_arch}]`, mirroring target_compatible_with;
- the builtin include layout.
That last one was a latent bug. A NATIVE build lays libstdc++ out flat
(`include/c++/<version>`) while a CROSS build nests it under the target triple,
and the existing code keyed that on `target_arch == x86_64` -- correct only
because every published build was x86_64-hosted. It is now keyed on
`host_arch == target_arch`, which is what the archives actually do: the
aarch64-hosted aarch64 build is flat, and the aarch64-hosted x86_64 one is
nested. Getting this wrong is quiet, because a nonexistent -isystem directory is
ignored and only surfaces later as a missing <string>.
Backwards compatible. Existing entries keep their exact URLs and digests, and the
binary prefix needs no host handling because _detect_binary_prefix already probes
the extracted archive. A hand-written `gcc_versions` in the old
`{version: {target: {url, sha256}}}` shape still works and is read as
x86_64-hosted; combining it with a non-x86_64 host fails with a message saying
what to write instead.
Verified all four host/target combinations (plus aarch64-hosted armv7) resolve,
fetch the archive whose ELF machine matches their host_arch, and declare only
include directories that exist -- and that the x86_64-hosted paths are unchanged.
//tests/host_arch asserts the aarch64-hosted compiler is an ARM ELF by reading
e_machine, so it runs anywhere; it fails if pointed at the x86_64-hosted cross
toolchain. It is skipped for 12.5.0 and 13.4.0, whose releases publish no
aarch64-hosted build, as //tests/lld is for the versions built without lld.1 parent ed8c2ab commit 3176328
10 files changed
Lines changed: 432 additions & 90 deletions
File tree
- docs
- tests/host_arch
- toolchain
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
36 | 47 | | |
37 | 48 | | |
38 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments