Skip to content

Resolve k4-x86_64 to the k3 toolchain: pre-2.31 binutils - #5

Merged
lacraig2 merged 1 commit into
mainfrom
k4-x86_64-toolchain
Aug 14, 2026
Merged

lacraig2 merged 1 commit into
mainfrom
k4-x86_64-toolchain

Conversation

@lacraig2

Copy link
Copy Markdown
Contributor

The bug

binutils 2.31 began emitting R_X86_64_PLT32 where it previously emitted R_X86_64_PC32. Linux only learned that relocation in 4.16 (b21ebf2fb4cd, "x86: Treat R_X86_64_PLT32 as R_X86_64_PC32").

So an x86_64 kernel older than 4.16, built with binutils ≥ 2.31, compiles, links, packages, and has the correct ELF class, byte order, machine and size — and does not boot. It decompresses, prints Booting the kernel., and goes silent before console init.

Bootlin's k4 x86_64 cell is 2021.11-5: gcc 10.3, binutils 2.36.1.

How it escaped

linux_builder shipped exactly this in nixdev_0.1.0's 4.10/x86_64. Every gate passed it:

  • the build succeeded
  • shape-check passed — a bzImage's shape says nothing about whether it runs
  • the patch-series gate passed — it only proves the patches apply
  • kernelsmith's own boot.nix passed — but its k4 cell boots 5.10.229, and the k4 band spans 4.x and 5.x, so the 4.x half had never been booted by anything

It surfaced three repos downstream, in penguin's integration tests (rehosting/penguin#932).

It was known here before

rehosting/embedded-toolchains — the Docker image kernelsmith replaces — hand-built an x86_64-legacy toolchain for precisely this, pinning binutils 2.30, the last release before 2.31:

FROM base AS x86_64_legacy_builder
wget .../binutils-2.30.tar.xz && ../configure --target=x86_64-linux-musl ...
wget .../gcc-6.5.0.tar.xz     && ../configure --target=x86_64-linux-musl ...

and _in_container_build.sh selected it for (x86_64, 4.10) alone. The reason was never written down, so it did not survive the port to a version-keyed resolver.

The fix

k3 is already that toolchain — gcc 6.5.0 (the same version embedded-toolchains chose) and binutils 2.27, on the same x86_64-linux-musl triple. No new cell; one resolver entry, with the reason attached:

toolchains = mcmToolchains // bootlinToolchains // {
  "k4-x86_64" = mcmToolchains."k3-x86_64";
};

Verification

before after
linux_builder 4.10/x86_64 silent, no output ok 4.10/x86_64 — reaches root-fs stage
boot.nix tests.k4-x86_64 (5.10.229) ok still ok

gcc was held constant at 6.5.0 across both 4.10 runs (a native gcc sweep at 6.5/7.5/9.5/10.5 all produced dead kernels at binutils 2.41), so the linker is the only variable that moved. 5.10's banner records the result directly:

Linux version 5.10.229 (x86_64-linux-musl-gcc (GCC) 6.5.0, GNU ld (GNU Binutils) 2.27)

Known limitation

This pins the whole k4 band for x86_64, and k4 spans 4.x and 5.x — 5.10 does not need pre-2.31 binutils and would rather have the newer toolchain. The resolver is keyed (era, arch) and cannot express "4.x needs this, 5.x needs that". boot.nix's k4-x86_64 cell is what proves this does not regress the other half; the correct answer is a finer band.

matrix.nix documents that and a related gap it exposed: eras declare binutilsVer, but only the musl-cross-make path honours it. Bootlin cells ship whatever Buildroot bundled, unrecorded — k4 declares 2.33.1 while its Bootlin x86_64 cell ships 2.36.1. For most cells that field is documentation, not a constraint. The failure mode is asymmetric: too-new gcc errors loudly at compile time, too-new binutils is silent until boot.

binutils 2.31 began emitting R_X86_64_PLT32 where it previously emitted
R_X86_64_PC32. Linux only learned that relocation in 4.16 (b21ebf2fb4cd,
"x86: Treat R_X86_64_PLT32 as R_X86_64_PC32"). An x86_64 kernel older
than 4.16, built with binutils >= 2.31, compiles, links, packages, and
has the correct ELF class, byte order, machine and size -- and does not
boot. It decompresses, prints "Booting the kernel.", and goes silent
before console init.

linux_builder shipped exactly that in nixdev_0.1.0's 4.10/x86_64. Every
gate passed it: the build, shape-check, the patch-series check, and
kernelsmith's own boot.nix -- whose k4 cell boots 5.10.229, so the 4.x
half of the band had never been booted by anything. It surfaced three
repos downstream, in penguin's integration tests.

This was known here before. rehosting/embedded-toolchains, the Docker
image kernelsmith replaces, hand-built an "x86_64-legacy" toolchain
pinning binutils 2.30 -- the last release before 2.31 -- and
_in_container_build.sh selected it for (x86_64, 4.10) alone. The reason
was never written down, so it did not survive the port to a
version-keyed resolver.

k3 is already that toolchain: gcc 6.5.0 (the same version
embedded-toolchains picked) and binutils 2.27, on the same
x86_64-linux-musl triple. So this needs no new cell, only a resolver
entry with the reason attached.

Verified: 4.10/x86_64 now boots to the root-fs stage where it was
previously silent, with gcc held constant at 6.5.0 across both -- the
linker is the only variable. 5.10.229 (boot.nix's k4-x86_64 cell) still
boots under the override, so the other half of the band does not regress.

The override applies band-wide, which is wrong in principle: 5.x does
not need pre-2.31 binutils. matrix.nix now documents that, and the
related gap that eras declare binutilsVer but only the musl-cross-make
path honours it -- Bootlin cells ship whatever Buildroot bundled,
unrecorded. Both want a finer band keyed nearer the 4.16 boundary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant