-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
glibc_multi: add output "static" #380756
Open
Tim-Wsm
wants to merge
1
commit into
NixOS:master
Choose a base branch
from
Tim-Wsm:glibc-multilib-static
base: master
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
glibc_multi: add output "static" #380756
Conversation
This file contains 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 change enables static compilation with glibc in a multilib setup. For building a nix shell the output can now be referenced as follows: devShells.default = pkgs.mkShell { packages = [ pkgs.glibc_multi.static ]; }; In the implementation I was forced to make two design decisions: 1. The directory `$static/lib64` has to be a "real" directory and not a symlink. Otherwise, the path to this directory is not added to $NIX_LDFLAGS, which in turn causes the files to not be visible to gcc and ld during the build process (for details see `pkgs/build-support/bintools-wrapper/setup-hook.sh` line 16). 2. The directories `$static/lib` and `$static/lib64` have to contain symlinks to both the files used for static and for dynamic linking (i.e. the outputs of `static` and `out` of the 32 and 64 bit variant of glibc). Without this, dynamic linking still works, however the resulting binaries will segfault.
58c5376
to
e7413df
Compare
|
The failing package |
Since |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
10.rebuild-darwin: 0
This PR does not cause any packages to rebuild on Darwin
10.rebuild-linux: 101-500
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.
This change enables static compilation with glibc in a multilib setup. For building a nix shell the output can now be referenced as follows:
In the implementation I was forced to make two design decisions:
$static/lib64
has to be a "real" directory and not a symlink. Otherwise, the path to this directory is not added to $NIX_LDFLAGS, which in turn causes the files to not be visible to gcc and ld during the build process (for details seepkgs/build-support/bintools-wrapper/setup-hook.sh
line 16).$static/lib
and$static/lib64
have to contain symlinks to both the files used for static and for dynamic linking (i.e. the outputs ofstatic
andout
of the 32 and 64 bit variant of glibc). Without this, dynamic linking still works, however the resulting binaries will segfault.(not part of the commit message)
I'm unsure why I've had to add the files for dynamic linking into the output for static linking to prevent the resulting binaries to segfault. However, since this solution works and does not modify/impact any other modules/packages, I'm satisfied with it.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Open issues related to this pull request
This is my second attempt at this pr. I've deleted my first attempt, because the test
tests.cc-multilib-clang
failed while runningnixpkgs-review
. However, I'm now confident, that this test does not fail due to any of the changes in this pr and have reported this as a separate issue in #380752.Snippets for manual testing
I tested the changes manually using the following setup:
hello-world.c
flake.nix
Then I've used the following commands for testing.
Add a 👍 reaction to pull requests you find important.