Skip to content

Commit d1155aa

Browse files
authored
fix(ci): normalize macOS binary dependencies (#3006)
Closes #2997 Signed-off-by: Simon Scatton <sscatton@nvidia.com>
1 parent 7eed8da commit d1155aa

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

.github/actions/build-rust-binary/action.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,36 @@ runs:
7171
INPUTS_EXTRA_CARGO_FLAGS: ${{ inputs.extra-cargo-flags }}
7272
run: GIT_DIR=/nonexistent cargo auditable build --release --package "${INPUTS_PACKAGE}" --bin "${INPUTS_BINARY}" ${INPUTS_EXTRA_CARGO_FLAGS}
7373

74+
- name: Normalize Darwin dynamic binary
75+
if: endsWith(inputs.triple, '-apple-darwin')
76+
shell: bash -euo pipefail {0}
77+
env:
78+
INPUTS_BINARY: ${{ inputs.binary }}
79+
run: |
80+
binary=target/release/${INPUTS_BINARY}
81+
nix_iconv_paths=$(otool -L "$binary" | awk '$1 ~ "^/nix/store/.*/lib/libiconv\\.2\\.dylib$" { print $1 }')
82+
if [[ -n "$nix_iconv_paths" ]]; then
83+
while IFS= read -r nix_iconv_path; do
84+
install_name_tool -change "$nix_iconv_path" /usr/lib/libiconv.2.dylib "$binary"
85+
done <<< "$nix_iconv_paths"
86+
codesign --force --sign - "$binary"
87+
fi
88+
89+
- name: Verify Darwin portability
90+
if: endsWith(inputs.triple, '-apple-darwin')
91+
shell: bash -euo pipefail {0}
92+
env:
93+
INPUTS_BINARY: ${{ inputs.binary }}
94+
run: |
95+
binary=target/release/${INPUTS_BINARY}
96+
nix_dependencies=$(otool -L "$binary" | awk '$1 ~ "^/nix/store/" { print $1 }')
97+
if [[ -n "$nix_dependencies" ]]; then
98+
echo "error: $binary has non-portable Nix store dependencies:" >&2
99+
printf ' %s\n' "$nix_dependencies" >&2
100+
exit 1
101+
fi
102+
codesign --verify --verbose=2 "$binary"
103+
74104
- name: Verify ${{ inputs.binary }}
75105
shell: nix develop ${{ inputs.dev-shell }} -c bash -euo pipefail {0}
76106
env:

architecture/build.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,12 @@ The shared binary build action compiles release artifacts with `cargo auditable`
145145
Branch E2E, Release Dev, and Release Tag image jobs stage those same artifacts
146146
instead of rebuilding binaries in Docker. Each binary build scans its output with
147147
Syft and requires at least one decoded Cargo package before uploading the
148-
artifact. The CI image gains the pinned `cargo-auditable` tool through
149-
`mise install --locked` but ships no auditable OpenShell binary of its own.
148+
artifact. Darwin builds replace Nix's `libiconv` load command with the macOS
149+
system install name, ad-hoc sign the modified binary, and fail if `otool -L`
150+
reports any remaining `/nix/store` dependency. Runtime and Syft verification
151+
run after that normalization. The CI image gains the pinned `cargo-auditable`
152+
tool through `mise install --locked` but ships no auditable OpenShell binary of
153+
its own.
150154

151155
Pushed Docker images carry minimal SLSA provenance and a per-platform SPDX SBOM
152156
generated by BuildKit's default Syft scanner. The registry exporter uses OCI

0 commit comments

Comments
 (0)