feat(odin): add opt-in hermetic Linux linking - #22
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
--@rules_odin//odin:hermetic_linkerbool_flag(defaultfalse).hermetic_clang/hermetic_toolchain_files/hermetic_sysrootattrs. A Linux target withouthermetic_clangstays on the host linker even when the flag is set.toolchains_llvm+ a sysroot themselves.--target/--sysroot/-B/-Lflags are computed in-ruleset from the target cpu constraint.How was it tested?
e2e/hermetic/workspace (bring-your-owntoolchains_llvm1.8.0 + pinned Chromium sysroots) exercises the path; CI runs it Linux-only via a new gated step incheck.yaml.e2e/smoke,e2e/failure_propagation, ande2e/hermeticall pass — confirming the flag is inert on macOS (host path) and non-hermetic targets are unaffected.pre-commit run --all-filesclean;bazel build //...clean.Checklist
check.yaml— lint + test matrix)