Skip to content

feat(odin): add opt-in hermetic Linux linking - #22

Merged
clappingmonkey merged 1 commit into
mainfrom
feat/hermetic-linux-linker
Jul 22, 2026
Merged

feat(odin): add opt-in hermetic Linux linking#22
clappingmonkey merged 1 commit into
mainfrom
feat/hermetic-linux-linker

Conversation

@clappingmonkey

Copy link
Copy Markdown
Owner

What does this PR do?

Odin downloads hermetically but links via a host-provided linker driver. This PR adds an opt-in mode that, on Linux x86_64/aarch64 only, points Odin's linker driver at a bring-your-own hermetic clang+lld and a pinned sysroot (ODIN_CLANG_PATH + -linker:lld + --sysroot/-B/-L), so the link uses zero host clang/ld/libc.

Design (verified against rules_go/rules_rust/toolchains_llvm best practice):

  • Gated by the --@rules_odin//odin:hermetic_linker bool_flag (default false).
  • Activated per target via the hermetic_clang / hermetic_toolchain_files / hermetic_sysroot attrs. A Linux target without hermetic_clang stays on the host linker even when the flag is set.
  • Inert on macOS/Windows — Apple's macOS SDK and Microsoft's MSVC libraries are not redistributable, so those platforms always use the host toolchain (same posture as rules_go/rules_rust/zig-cc). A single flag across a multi-OS matrix is therefore ergonomic.
  • Bring-your-own: rules_odin gains no new dependency; users wire toolchains_llvm + a sysroot themselves.
  • Per-arch --target/--sysroot/-B/-L flags are computed in-ruleset from the target cpu constraint.
  • Default (non-hermetic) behavior is completely unchanged.

How was it tested?

  • Prior CI spike proved the Linux hermetic link green on ubuntu-24.04 (x86_64) and ubuntu-24.04-arm (aarch64), all Bazel versions — the binary linked and ran with zero host clang/ld/libc.
  • New e2e/hermetic/ workspace (bring-your-own toolchains_llvm 1.8.0 + pinned Chromium sysroots) exercises the path; CI runs it Linux-only via a new gated step in check.yaml.
  • Local (macOS): e2e/smoke, e2e/failure_propagation, and e2e/hermetic all pass — confirming the flag is inert on macOS (host path) and non-hermetic targets are unaffected.
  • Reviewed by parallel code-quality + adversarial validators and a security audit; two blockers found and fixed, re-validated APPROVE.
  • pre-commit run --all-files clean; bazel build //... clean.

Checklist

  • PR title follows conventional commit format
  • CI passes (check.yaml — lint + test matrix)
  • Tests added or updated for new/changed behavior
  • Documentation updated if user-facing (docstrings, README, CONTRIBUTING.md)
  • No breaking changes (or BREAKING CHANGE section below is filled out)

Odin downloads hermetically but links via a host-provided linker
driver. This adds an opt-in mode that, on Linux x86_64/aarch64,
points Odin's linker driver (ODIN_CLANG_PATH + -linker:lld) at a
bring-your-own hermetic clang+lld and a pinned sysroot, so the link
uses zero host clang/ld/libc.

Gated by the --@rules_odin//odin:hermetic_linker build setting and
activated per target via the hermetic_clang/hermetic_toolchain_files/
hermetic_sysroot attrs. The flag is inert on macOS/Windows (their SDKs
are not redistributable, matching rules_go/rules_rust) and a Linux
target without hermetic_clang stays on the host linker — so default
behavior is unchanged and no new dependency is added to the ruleset.

Per-arch --target/--sysroot/-B/-L flags are computed in-ruleset. A new
e2e/hermetic workspace (bring-your-own toolchains_llvm + Chromium
sysroots) exercises the path in CI on Linux. Docs updated to reflect
the per-OS hermeticity reality.
@clappingmonkey
clappingmonkey merged commit aa09562 into main Jul 22, 2026
14 checks passed
@clappingmonkey
clappingmonkey deleted the feat/hermetic-linux-linker branch July 22, 2026 09:42
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