Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Enforce fully static linking for Linux binaries#13

Merged
juntao merged 4 commits intomainfrom
static-linking
Feb 1, 2026
Merged

Enforce fully static linking for Linux binaries#13
juntao merged 4 commits intomainfrom
static-linking

Conversation

@juntao
Copy link
Member

@juntao juntao commented Feb 1, 2026

Summary

  • Add link-self-contained=yes flag for musl targets to ensure fully static binaries
  • Add strict CI verification that Linux binaries have no dynamic dependencies
  • CI will fail if ldd shows any libc or other dynamic dependencies

Platform behavior

  • Linux: Fully static binaries with musl libc (zero runtime dependencies, no libc)
  • macOS: Cannot be fully static due to Apple restrictions (libSystem.dylib always required)
  • Windows: Static CRT linking (MSVCRT statically linked)

Test plan

  • cargo build --release succeeds
  • cargo test --all passes
  • CI builds and verifies static linking

🤖 Generated with Claude Code

Juntao Yuan and others added 4 commits February 1, 2026 10:08
- Add link-self-contained=yes flag for musl targets
- Add strict CI verification that binaries have no dynamic dependencies
- Fail CI build if ldd shows any libc or other dynamic dependencies
- Update comments to clarify platform-specific static linking behavior

Linux binaries will have zero runtime dependencies (no libc).
macOS cannot be fully static due to Apple restrictions.
Windows uses static CRT.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The musl builds produce "static-pie linked" binaries, not "statically linked".
Update grep pattern to match both variants.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
ldd outputs "statically linked" for static-pie binaries, not
"not a dynamic executable". Update the check to match both patterns.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
ldd cannot analyze cross-compiled binaries (wrong architecture).
Accept ldd errors like "cannot execute" or "wrong ELF class" as valid
since the file command already confirmed static linking.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@juntao juntao merged commit b306385 into main Feb 1, 2026
11 checks passed
@juntao juntao deleted the static-linking branch February 1, 2026 10:29
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