Skip to content

test(linux): add the scheduled >2 GiB ELF output scale gate (reld#16) - #159

Merged
zackees merged 2 commits into
mainfrom
feat/16-scale-gate
Sep 17, 2026
Merged

zackees merged 2 commits into
mainfrom
feat/16-scale-gate

Conversation

@zackees

@zackees zackees commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Closes #16. Wave 2 of #153.

Why scheduled

The per-PR Phase 2 Linux gate covers >64K sections and >64K relocations. A >2 GiB output cannot join them — the inputs alone are gigabytes — so it runs weekly from .github/workflows/scale-gate-linux.yml, and docs/plan/08-ACCEPTANCE.md section 4b now records the deferral with a link to this issue instead of leaving it as prose.

What it does

ci/scale_gate.py generates 36 × 64 MiB .rodata chunks as assembly (.fill, so the size costs an assembler rather than a compiler chewing a multi-gigabyte initializer), links them through clang --ld-path=reld, and then:

  • validates every section and segment header against the real file size, and p_filesz <= p_memsz on PT_LOAD — a truncated or wrapped field is reported as the specific field that is wrong;
  • fails if the output is at or below 2 GiB, so the gate cannot pass by not testing anything;
  • executes the binary and requires exit 42, which only its own code produces;
  • fails on a panic, a nonzero link, or a link that reports success and writes nothing;
  • records output size, wall time, peak RSS, chunk plan, runner image, and reld commit, uploaded as an artifact.

The first run found something

A C fixture does not work here. The distributed crt objects are built for the small code model, and 2 GiB of payload pushes crtbegin.o out of range before reld's layout is exercised at all:

reld: error: Failed copying from …/crtbegin.o to output file
  Failed to apply relocation of type R_X86_64_32S to section `.tm_clone_table`
  Relocation 2420131192 outside of bounds [-2147483648, 2147483648)

That is the C runtime's code model, not the linker, so the fixture is freestanding: -nostdlib -static, -mcmodel=large, and an exit syscall.

Verification

Run end-to-end locally against target/release/reld:

{
  "output_bytes": 2415922919,
  "executed": true,
  "link_wall_seconds": 0.73,
  "link_peak_rss_bytes": 138448896,
  "extra": { "sections": "10", "segments": "6" }
}

2.25 GiB of output, structurally valid, ran and exited 42.

The gate's own logic is unit tested in ci/tests/test_scale_gate.py against hand-built ELF bytes — truncated section, truncated segment, overflowed p_filesz, SHT_NOBITS correctly ignored, non-ELF input, sizing — so a validator that stops catching truncation fails on a PR rather than a week later. uv run --no-sync python -m pytest ci/tests -q: 267 passed.

🤖 Generated with Claude Code

The per-PR Phase 2 gate covers >64K sections and >64K relocations; a >2 GiB
output cannot join them because its inputs alone are gigabytes. This runs it
weekly instead, and records the deferral in docs/plan/08-ACCEPTANCE.md rather
than leaving it as prose.

`ci/scale_gate.py` builds the payload as assembly, so 2.25 GiB of `.rodata`
costs an assembler rather than a compiler chewing a multi-gigabyte initializer,
links it through clang with `--ld-path`, then validates every section and
segment offset against the real file size, executes the result, and records
peak RSS, wall time, output size, runner image, and reld commit.

The first run found why this is not a C fixture: the distributed crt objects are
built for the small code model, and 2 GiB of payload pushes `crtbegin.o`'s
`R_X86_64_32S` out of range before reld's layout is exercised at all. That is
the C runtime's code model, not the linker, so the fixture is freestanding and
exits by syscall.

Structural validation is Python rather than a `readelf` call so it names the
field that is wrong and can be unit tested without building 2 GiB. Those tests
run on every PR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…r mark

`getrusage(RUSAGE_CHILDREN)` is cumulative across every child the process has
ever reaped, so after assembling 36 sixty-four-megabyte objects it reported
whichever assembler run peaked highest rather than the link. `os.wait4` gives
the rusage of one specific child.

Measured difference on the same 2.25 GiB link: 138 MB reported before, 70 MB
actually used.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zackees
zackees merged commit edf1265 into main Sep 17, 2026
19 checks passed
@zackees
zackees deleted the feat/16-scale-gate branch September 17, 2026 22:34
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.

test(linux): add scheduled >2 GiB ELF output scale gate

1 participant