gcc: provide a $libgcc/$target/lib -> $libgcc/lib symlink
The primary reason for the layout change is for `gcc.libgcc` to match closer `gcc.lib` layout. That way we allow `$STRIP_FOR_TARGET` to strip `libgcc_s.so.1` file moved to $libgcc output. Otherwise `$STRIP` (for host) fails to do it and leaves debug strings like references to headers in it and bloats HOST closure with BUILD inputs. The change shrinks `aarch64-multiplatform-musl.coreutils` closure from 50MB down to 10MB: Before: $ nix path-info -rsSh $(nix-build -A pkgs.pkgsCross.aarch64-multiplatform-musl.coreutils) |& unnix /<<NIX>>/xgcc-13.2.0-libgcc 155.8K 155.8K /<<NIX>>/musl-aarch64-unknown-linux-musl-1.2.3 3.8M 3.8M /<<NIX>>/libunistring-1.1 1.7M 1.7M /<<NIX>>/libidn2-2.3.7 352.7K 2.1M /<<NIX>>/glibc-2.39-52 28.7M 31.0M /<<NIX>>/bash-5.2p26 1.5M 32.5M /<<NIX>>/musl-aarch64-unknown-linux-musl-1.2.3-bin 69.4K 3.8M /<<NIX>>/linux-headers-6.7 6.2M 6.2M /<<NIX>>/musl-aarch64-unknown-linux-musl-1.2.3-dev 550.2K 43.1M /<<NIX>>/aarch64-unknown-linux-musl-gcc-13.2.0-libgcc 579.7K 43.6M /<<NIX>>/aarch64-unknown-linux-musl-gcc-13.2.0-lib 3.8M 47.4M /<<NIX>>/gmp-with-cxx-aarch64-unknown-linux-musl-6.3.0 653.4K 48.1M /<<NIX>>/attr-aarch64-unknown-linux-musl-2.5.2 73.8K 3.8M /<<NIX>>/acl-aarch64-unknown-linux-musl-2.3.2 156.4K 4.0M /<<NIX>>/coreutils-aarch64-unknown-linux-musl-9.5 1.6M 49.9M After: $ nix path-info -rsSh $(nix-build -A pkgs.pkgsCross.aarch64-multiplatform-musl.coreutils) |& unnix /<<NIX>>/musl-aarch64-unknown-linux-musl-1.2.3 3.8M 3.8M /<<NIX>>/aarch64-unknown-linux-musl-gcc-13.2.0-libgcc 147.9K 147.9K /<<NIX>>/aarch64-unknown-linux-musl-gcc-13.2.0-lib 3.8M 7.7M /<<NIX>>/gmp-with-cxx-aarch64-unknown-linux-musl-6.3.0 653.4K 8.4M /<<NIX>>/attr-aarch64-unknown-linux-musl-2.5.2 73.8K 3.8M /<<NIX>>/acl-aarch64-unknown-linux-musl-2.3.2 156.4K 4.0M /<<NIX>>/coreutils-aarch64-unknown-linux-musl-9.5 1.6M 10.1M
This commit is contained in:
parent
fcfad390d0
commit
c682f2b491
@ -84,21 +84,20 @@ in
|
||||
rm -f $out/lib/libgcc_s.so*
|
||||
''
|
||||
|
||||
# TODO(amjoseph): remove the `libgcc_s.so` symlinks below and replace them
|
||||
# with a `-L${gccForLibs.libgcc}/lib` in cc-wrapper's
|
||||
# `$out/nix-support/cc-flags`. See also:
|
||||
# - https://github.com/NixOS/nixpkgs/pull/209870#discussion_r1130614895
|
||||
# - https://github.com/NixOS/nixpkgs/pull/209870#discussion_r1130635982
|
||||
# - https://github.com/NixOS/nixpkgs/commit/404155c6acfa59456aebe6156b22fe385e7dec6f
|
||||
#
|
||||
# move `libgcc_s.so` into its own output, `$libgcc`
|
||||
# We maintain $libgcc/lib/$target/ structure to make sure target
|
||||
# strip runs over libgcc_s.so and remove debug references to headers:
|
||||
# https://github.com/NixOS/nixpkgs/issues/316114
|
||||
+ lib.optionalString enableLibGccOutput (''
|
||||
# move libgcc from lib to its own output (libgcc)
|
||||
mkdir -p $libgcc/lib
|
||||
mv $lib/${targetPlatformSlash}lib/libgcc_s.so $libgcc/lib/
|
||||
mv $lib/${targetPlatformSlash}lib/libgcc_s.so.${libgcc_s-version-major} $libgcc/lib/
|
||||
ln -s $libgcc/lib/libgcc_s.so $lib/${targetPlatformSlash}lib/
|
||||
ln -s $libgcc/lib/libgcc_s.so.${libgcc_s-version-major} $lib/${targetPlatformSlash}lib/
|
||||
mkdir -p $libgcc/${targetPlatformSlash}lib
|
||||
mv $lib/${targetPlatformSlash}lib/libgcc_s.so $libgcc/${targetPlatformSlash}lib/
|
||||
mv $lib/${targetPlatformSlash}lib/libgcc_s.so.${libgcc_s-version-major} $libgcc/${targetPlatformSlash}lib/
|
||||
ln -s $libgcc/${targetPlatformSlash}lib/libgcc_s.so $lib/${targetPlatformSlash}lib/
|
||||
ln -s $libgcc/${targetPlatformSlash}lib/libgcc_s.so.${libgcc_s-version-major} $lib/${targetPlatformSlash}lib/
|
||||
''
|
||||
+ lib.optionalString (targetPlatformSlash != "") ''
|
||||
ln -s ${targetPlatformSlash}lib $libgcc/lib
|
||||
''
|
||||
#
|
||||
# Nixpkgs ordinarily turns dynamic linking into pseudo-static linking:
|
||||
|
Loading…
Reference in New Issue
Block a user