Skip to content

Full band×arch kernel sweep + gcc-era quirk handling + tarball mirror#1

Open
lacraig2 wants to merge 5 commits into
mainfrom
band-arch-kernel-sweep
Open

Full band×arch kernel sweep + gcc-era quirk handling + tarball mirror#1
lacraig2 wants to merge 5 commits into
mainfrom
band-arch-kernel-sweep

Conversation

@lacraig2

@lacraig2 lacraig2 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What

Three pieces of work land here:

  1. Tarball mirror (mirror.nix, mirror-upload.sh) — every pinned tarball (mcm components + Bootlin SDKs) is fetched mirror-first / upstream-fallback. Inert until base is set (base = null → upstream-only, verified hash-preserving no-op). Turns upstream pins into reproducible-forever copies.

  2. Full band×arch kernel sweep (validate-sweep.nix) — builds one stock kernel per band across every kernel-capable arch (42 cells) to a vmlinux, using endianness/width-definite defconfigs (SGI Indy/Origin, Loongson, PowerMac) so a pass certifies the ABI, not just "a kernel." This turns the per-arch kernel column from sampled (5 points) to swept.

  3. gcc-era quirk handling (kernel.nix eraQuirks) — a newer gcc than a tree expects trips the tree's own -Werror; we build kernels, not lint them, so demote via KCFLAGS/HOSTCFLAGS.

Sweep result: 32/42

Band Pass Residual failures (root cause)
k6 (6.6) 11/11
k4 (5.10) 10/11 objtool under tools/ has its own -Werror (gcc-13) unreachable by HOSTCFLAGS
k3 (3.18) 9/11 ppc64: ELFv1/ELFv2 ABI; ppc64le: vdso32 invokes host gcc
k2.6 (2.6.31) 2/9 ARM-only. mips×4 page.c fn→var alias (hard gcc≥5 error); ppc/x86 subdir -Werror + x86 vDSO

The two quirk fixes recovered all three k3 dtc cells with zero regressions (the 10 failures are a strict subset of the pre-fix 13).

Headline finding

The residual 10 are four characterized root causes, not noise, and cluster by era. Modern kernels are essentially clean; the frontier is k2.6, where gcc 5.3 is era-inappropriate — it works for ARM but hits genuine source/ABI incompatibilities that a true gcc-4.x would not. This empirically validates pursuing the deferred true-gcc-4.x toolchain (mcm stable pin) for k2.6 over per-arch kernel shims — next up.

lacraig2 added 5 commits July 1, 2026 15:41
validate-sweep.nix builds one stock kernel per band across every
kernel-capable arch (42 cells) to a vmlinux, turning the per-arch kernel
column from sampled (5 points) to swept. Endianness/width-definite
defconfigs (SGI Indy/Origin, Loongson, PowerMac) so a pass certifies the
ABI, not just "a kernel". powerpcle excluded (no 32-bit PPC-LE port in
mainline Linux — that matrix cell is userland-only); k2.6 arm64 and
powerpc64le excluded (ports postdate 2.6).

kernel.nix eraQuirks: a newer gcc than a tree expects trips its own
-Werror. We build kernels, not lint them, so demote:
  - KCFLAGS=-Wno-error   (cross/target warnings: unused-but-set, alias-decl)
  - HOSTCFLAGS           (host tools: -fcommon for gcc>=10 -fno-common
                          breaking dtc's yylloc; -Wno-error for gcc>=12
                          objtool/OpenSSL-3). Note the semantics flip:
                          pre-4.19 HOSTCFLAGS OVERRIDES (k3 restates the
                          3.18 defaults), >=4.19 it APPENDS. Threaded in as
                          a single quoted token (spaced value would
                          word-split under unquoted $makeFlags — a -O2 got
                          misread as make's -Output-sync).

Sweep result: 32/42. k6 11/11, k4 10/11, k3 9/11, k2.6 2/9.
The 10 residual failures are four characterized root causes, NOT flag
noise, documented for follow-up:
  1. gcc 5.3 too new for k2.6 non-ARM: mips page.c function-to-variable
     alias is a hard error under gcc>=5; ppc/x86 -Werror defeated by
     subdir flag precedence. True fix = era-appropriate gcc-4.x.
  2. ppc64 big-endian ELFv1/ELFv2: musl toolchain is elfv2, old BE ppc64
     kernels are elfv1 (-mcall-aixdesc). Needs -mabi=elfv1 forcing.
  3. vDSO cross-propagation: ppc64le/x86 vdso sub-builds invoke host gcc.
  4. tools/ has its own -Werror (objtool) unreachable by HOSTCFLAGS.
gcc 5.3.0 hit hard, unfixable errors on stock 2.6 for most arches (mips
page.c function->variable alias is rejected outright by gcc>=5; x86 vDSO
-m elf_x86_64). Those are symptoms of the compiler being too new, so
switch the k2.6 band to a genuinely era-appropriate gcc 4.9.4 built from
source. Contrary to the "can't build ancient gcc under a modern host"
worry, gcc 4.9.4 compiles fine under host gcc 13 with five small fixes in
mk-cross-toolchain.nix, all gated to gccVer<5 so gcc>=5 cells are
byte-identical:

  1. refresh pre-musl config.sub/config.guess from nixpkgs gnu-config
     (2010s ones reject *-linux-musl* triples)
  2. gcc 4.9.4 (not mcm-blessed 4.7.4, whose in-tree mpc can't detect a
     modern mpfr); support libs pinned to the era (mpfr 3.1.4/mpc 1.0.3/
     gmp 6.1.0 — mpfr>=4 won't build against gcc 4.9)
  3. synthesize the mcm hashes/ entry from the staged tarball, so we are
     not limited to mcm's blessed component set
  4. touch staged tarballs newer than their hashes, else make fires an
     offline-forbidden wget
  5. build gcc's own C++03-era source with -std=gnu++03 (host gcc 13
     defaults to C++17; e.g. bool operator++ in reload1.c) + add `file`

The k2.6 band builds languages="c" (kernels/modules are C; gcc 4.9's
libstdc++ predates musl's _IS* ctype macros). kernel.nix gains a k2.6
quirk that strips standalone -Werror from the old tree's Makefiles (it
lands after KCFLAGS and wins on precedence), keeping -Werror-implicit-*
and -Werror=<x> intact.

Result: k2.6 2/9 -> 3/9 (armel, armhf, powerpc); gcc 4.9.4 verified to
emit correct ARM ELF (static + dynamic musl). gcc 4.9.4 is NECESSARY but
not SUFFICIENT: it removed the hard errors, but the non-ARM tail is
layered — mips (all 4) fail in the toolchain (gcc 4.9 MIPS libgcc needs
asm/unistd.h in the build sysroot; also regresses .#k26-all to 6/12),
powerpc64 hits modern-make mixed-rules + ELFv1/v2, x86_64 a percpu macro.
See README "TRUE gcc-4.x" for the remaining per-arch fixes.
gcc 4.9's MIPS libgcc unwinder (md-unwind-support.h) #includes
<asm/unistd.h>, but mcm stages kernel headers into the build sysroot too
late (after libgcc) -> "asm/unistd.h: No such file", failing all 4 MIPS
k2.6 toolchains and regressing .#k26-all.

Append a rule to litecross/Makefile (gated gccVer<5) making libgcc depend
on the kernel headers being copied into obj_sysroot first. Built as a
double-quoted Nix string so \t yields the literal tabs Makefile recipes
need. Verified: mipsel k2.6 gcc 4.9.4 toolchain builds and emits MIPS32r2
ELF; .#k26-all now builds all 12 k2.6 toolchains.

This fixes the TOOLCHAIN layer (important for MIPS module / other-version
kernel builds) but NOT the 2.6.31 MIPS kernel, which fails on SOURCE
issues that persist under gcc 4.9.4:
  - arch/mips/mm/page.c aliases a function to a variable — REJECTED BY
    GCC 4.9 TOO (correcting the earlier assumption that this was a
    gcc-5-only error; it is a kernel-source problem)
  - r4k_switch.S uses FPU opcodes (mtc1 $f30/$f31) the assembler rejects
    for the configured ISA
Both need kernel source patches, not toolchain work.

k2.6 kernel tally stays 3/9 (armel, armhf, powerpc); toolchain row now
12/12. README/TRUE-gcc-4.x section corrected accordingly.
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