-
Notifications
You must be signed in to change notification settings - Fork 16
build: byte-reproducible releases, enforced in CI #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zvonkok
wants to merge
7
commits into
NVIDIA:main
Choose a base branch
from
zvonkok:reproducible-builds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2617ee4
build: make Cargo.toml the single source of codegen truth
zvonkok 2cb0493
build: pin the toolchain
zvonkok 4cd49e8
ci: pin the toolchain install and enforce it everywhere
zvonkok 6cc48fe
build: make release builds byte-reproducible
zvonkok 726b205
ci: verify reproducibility on every pull request
zvonkok efca419
test: gate syscall-boundary tests under miri
zvonkok bcf756e
test: panic hook tests restore state and assert the shutdown path
zvonkok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,11 @@ | ||
| # Target mechanics only; codegen policy lives in [profile.release]. | ||
| # Rustflags here override the profile and apply to every profile, | ||
| # including test builds. | ||
|
|
||
| [target.aarch64-unknown-linux-musl] | ||
| rustflags = [ | ||
| "-C", "linker=musl-gcc", | ||
| "-C", "target-feature=+crt-static", # Use static crt | ||
| "-C", "link-arg=-s", # Strip symbols | ||
| "-C", "opt-level=z", # Optimize for size | ||
| "-C", "codegen-units=1", # Enable better (though slower) optimization | ||
| "-C", "panic=abort", # Remove stack unwind code | ||
| ] | ||
|
|
||
| linker = "musl-gcc" | ||
| rustflags = ["-C", "target-feature=+crt-static"] | ||
|
|
||
| [target.x86_64-unknown-linux-musl] | ||
| rustflags = [ | ||
| "-C", "linker=musl-gcc", | ||
| "-C", "target-feature=+crt-static", # Use static crt | ||
| "-C", "link-arg=-s", # Strip symbols | ||
| "-C", "opt-level=z", # Optimize for size | ||
| "-C", "codegen-units=1", # Enable better (though slower) optimization | ||
| "-C", "panic=abort", # Remove stack unwind code | ||
| ] | ||
|
|
||
| linker = "musl-gcc" | ||
| rustflags = ["-C", "target-feature=+crt-static"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: Install pinned Rust toolchain | ||
| description: > | ||
| Installs the toolchain pinned in rust-toolchain.toml. | ||
| dtolnay/rust-toolchain only sets the rustup default, which the file | ||
| outranks, so the channel is parsed from the file to keep the install and | ||
| the pin in lockstep. | ||
|
|
||
| inputs: | ||
| targets: | ||
| description: Comma-separated target triples to install | ||
| required: false | ||
| default: "" | ||
| components: | ||
| description: Comma-separated components to install | ||
| required: false | ||
| default: "" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Read pinned toolchain | ||
| id: toolchain | ||
| shell: bash | ||
| # Fail fast on an unparseable pin. | ||
| run: | | ||
| channel=$(sed -n 's/^channel = "\(.*\)"$/\1/p' rust-toolchain.toml) | ||
| if [ -z "$channel" ]; then | ||
| echo "::error::cannot parse channel from rust-toolchain.toml" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "channel=$channel" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master 2026-06-30 | ||
| with: | ||
| toolchain: ${{ steps.toolchain.outputs.channel }} | ||
| targets: ${{ inputs.targets }} | ||
| components: ${{ inputs.components }} |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| name: Reproducible build | ||
|
|
||
| # Build the tree twice, varying the inputs a verifier cannot copy from CI | ||
| # (workspace directory, CARGO_HOME), and require identical sha256. Guards | ||
| # the dmesg <-> Rekor correlation promised in VERIFY.md and ARCHITECTURE.md. | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| double-build: | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - target: x86_64-unknown-linux-musl | ||
| runner: ubuntu-24.04 | ||
| - target: aarch64-unknown-linux-musl | ||
| runner: ubuntu-24.04-arm | ||
| runs-on: ${{ matrix.runner }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install pinned Rust toolchain | ||
| uses: ./.github/actions/rust-toolchain | ||
| with: | ||
| targets: ${{ matrix.target }} | ||
|
|
||
| - name: Install dependencies | ||
| # No apt-get update: the image index suffices; refreshing pulls | ||
| # third-party repos whose breakage fails the job. | ||
| run: sudo apt-get install -y musl-tools | ||
|
|
||
| - name: Build twice from different locations | ||
| shell: bash | ||
| # Same script the release workflow runs. | ||
| run: | | ||
| set -euxo pipefail | ||
| for build in first second-deliberately-longer-path; do | ||
| src="${RUNNER_TEMP}/${build}/src" | ||
| mkdir -p "$src" "${RUNNER_TEMP}/${build}/cargo-home" | ||
| cp -a . "$src" | ||
| (cd "$src" && CARGO_HOME="${RUNNER_TEMP}/${build}/cargo-home" \ | ||
| ./scripts/build-release.sh "${{ matrix.target }}") | ||
| done | ||
|
|
||
| - name: Require identical sha256 | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| a="${RUNNER_TEMP}/first/src/target/${{ matrix.target }}/release/NVRC" | ||
| b="${RUNNER_TEMP}/second-deliberately-longer-path/src/target/${{ matrix.target }}/release/NVRC" | ||
| sha256sum "$a" "$b" | ||
| if [ "$(sha256sum < "$a")" != "$(sha256sum < "$b")" ]; then | ||
| echo "::error::release binary is not reproducible across build locations" | ||
| # The offending path is usually visible in the strings diff. | ||
| diff <(strings "$a") <(strings "$b") | head -50 || true | ||
| exit 1 | ||
| fi |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.