lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

glibc_multi: add output "static"

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.

authored by

Tim and committed by
Alyssa Ross
eaee7b7a 64949102

+11 -1
+11 -1
pkgs/development/libraries/glibc/multi.nix
··· 16 16 "out" 17 17 "bin" 18 18 "dev" 19 - ]; # TODO: no static version here (yet) 19 + "static" 20 + ]; 20 21 passthru = { 21 22 libgcc = lib.lists.filter (x: x != null) [ 22 23 (glibc64.libgcc or null) ··· 42 43 cp -rs '${glibc32.dev}'/include "$dev/" 43 44 chmod +w -R "$dev" 44 45 cp -rsf '${glibc64.dev}'/include "$dev/" 46 + 47 + mkdir -p "$static/lib" "$static/lib64" 48 + # create symlinks for files used for dynamic linking 49 + # -> removing this will cause dynamically linked programs to segfault 50 + cp -rs '${glibc32.out}'/lib/* "$static/lib" 51 + cp -rs '${glibc64.out}'/lib/* "$static/lib64" 52 + # create symlinks for files used for static linking 53 + cp -rs '${glibc32.static}'/lib/* "$static/lib" 54 + cp -rs '${glibc64.static}'/lib/* "$static/lib64" 45 55 ''