Add support for packaging C toolchains managed by Nix#2698
Open
IvarWithoutBones wants to merge 1 commit into
Open
Add support for packaging C toolchains managed by Nix#2698IvarWithoutBones wants to merge 1 commit into
IvarWithoutBones wants to merge 1 commit into
Conversation
The way the Nix package manager structures C compilers is a bit different from other systems. Executables installed in $PATH are thin wrappers over the actual compiler binaries, which inject the paths to runtime dependencies like libc and the standard library headers. The wrapper being a shell script breaks the usual method of finding dependencies. `ldd` doesn't work on shell scripts, a specific script interpreter is required, and the script refers to dependencies like `coreutils` by their (unpredictable) Nix store paths. Luckily Nix provides a way to query the runtime dependencies of any file in the store, so we can simply add those to the toolchain package instead of trying to find them ourselves.
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.
The way the Nix package manager structures C compilers is a bit different from other systems. Executables installed in
$PATHare thin wrapper scripts over the actual compiler binaries, which inject the paths to runtime dependencies like libc and the standard library headers.The wrapper being a shell script breaks the usual method of finding dependencies.
ldddoesn't work on shell scripts, a specific script interpreter is required, and the script refers to dependencies likecoreutilsby their (unpredictable) Nix store paths.Luckily Nix provides a way to query the runtime dependencies of any file in the store, so we can simply add those to the toolchain package instead of trying to find them by hand. Programs like
asare included as well. I've tested distributed compilation with various (cross) compilers from Nix, which all work as expected. Rust toolchains also already worked as expected before this PR.Fixes #1684.