mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 07:13:23 +01:00
gcc: Put runtime libraries in a separate output
GCC provides a number of libraries that are used by programs built by GCC, in particular libgcc_s.so and libstdc++.so. This caused programs that used these libraries to have a runtime dependency on all of GCC (~77 MiB). Now they only depend on the "lib" output of GCC (~1.6 MiB). With this and previous multiple-output improvements, closure sizes are reduced a lot: hello: 41 MiB -> 22 MiB patchelf: 118 MiB -> 23 MiB pan: 364 MiB -> 90 MiB
This commit is contained in:
parent
2cfeca153c
commit
dbe432e6f4
6 changed files with 23 additions and 11 deletions
|
@ -39,9 +39,9 @@ if test -n "$nativeTools"; then
|
|||
ldPath="$nativePrefix/bin"
|
||||
else
|
||||
if test -e "$gcc/lib64"; then
|
||||
gccLDFlags="$gccLDFlags -L$gcc/lib64"
|
||||
gccLDFlags="$gccLDFlags -L$gcc_lib/lib64"
|
||||
fi
|
||||
gccLDFlags="$gccLDFlags -L$gcc/lib"
|
||||
gccLDFlags="$gccLDFlags -L$gcc_lib/lib"
|
||||
if [ -n "$langVhdl" ]; then
|
||||
gccLDFlags="$gccLDFlags -L$zlib/lib"
|
||||
fi
|
||||
|
|
|
@ -40,6 +40,7 @@ stdenv.mkDerivation {
|
|||
addFlags = ./add-flags;
|
||||
|
||||
inherit nativeTools nativeLibc nativePrefix gcc;
|
||||
gcc_lib = gcc.lib or gcc;
|
||||
libc = if nativeLibc then null else libc;
|
||||
libc_dev = if nativeLibc then null else libc.dev or libc;
|
||||
libc_bin = if nativeLibc then null else libc.bin or libc;
|
||||
|
|
|
@ -8,9 +8,10 @@ mkdir $NIX_FIXINC_DUMMY
|
|||
if test "$staticCompiler" = "1"; then
|
||||
EXTRA_LDFLAGS="-static"
|
||||
else
|
||||
EXTRA_LDFLAGS=""
|
||||
EXTRA_LDFLAGS="-Wl,-rpath,$lib/lib"
|
||||
fi
|
||||
|
||||
|
||||
# GCC interprets empty paths as ".", which we don't want.
|
||||
if test -z "$CPATH"; then unset CPATH; fi
|
||||
if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
|
||||
|
@ -33,7 +34,7 @@ if test "$noSysDirs" = "1"; then
|
|||
|
||||
# The path to the Glibc binaries such as `crti.o'.
|
||||
glibc_libdir="$(cat $NIX_GCC/nix-support/orig-libc)/lib"
|
||||
|
||||
|
||||
else
|
||||
# Hack: support impure environments.
|
||||
extraFlags="-isystem /usr/include"
|
||||
|
@ -50,10 +51,10 @@ if test "$noSysDirs" = "1"; then
|
|||
# bootstrap compiler are optimized and (optionally) contain
|
||||
# debugging information (info "(gccinstall) Building").
|
||||
if test -n "$dontStrip"; then
|
||||
extraFlags="-O2 -g $extraFlags"
|
||||
extraFlags="-O2 -g $extraFlags"
|
||||
else
|
||||
# Don't pass `-g' at all; this saves space while building.
|
||||
extraFlags="-O2 $extraFlags"
|
||||
# Don't pass `-g' at all; this saves space while building.
|
||||
extraFlags="-O2 $extraFlags"
|
||||
fi
|
||||
|
||||
EXTRA_FLAGS="$extraFlags"
|
||||
|
@ -205,6 +206,10 @@ preInstall() {
|
|||
|
||||
|
||||
postInstall() {
|
||||
# Move runtime libraries to $lib.
|
||||
mkdir -p $lib/lib
|
||||
mv -v $out/lib/lib*.so $out/lib/lib*.so.*[0-9] $lib/lib/
|
||||
|
||||
# Remove precompiled headers for now. They are very big and
|
||||
# probably not very useful yet.
|
||||
find $out/include -name "*.gch" -exec rm -rf {} \; -prune
|
||||
|
@ -213,9 +218,10 @@ postInstall() {
|
|||
# previous gcc.
|
||||
rm -rf $out/libexec/gcc/*/*/install-tools
|
||||
rm -rf $out/lib/gcc/*/*/install-tools
|
||||
|
||||
|
||||
# More dependencies with the previous gcc or some libs (gccbug stores the build command line)
|
||||
rm -rf $out/bin/gccbug
|
||||
|
||||
# Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
|
||||
for i in $out/libexec/gcc/*/*/*; do
|
||||
if PREV_RPATH=`patchelf --print-rpath $i`; then
|
||||
|
|
|
@ -192,6 +192,10 @@ stdenv.mkDerivation ({
|
|||
inherit langC langCC langFortran langJava langAda langGo;
|
||||
};
|
||||
|
||||
outputs = [ "out" "lib" ];
|
||||
|
||||
setOutputConfigureFlags = false;
|
||||
|
||||
inherit patches enableMultilib;
|
||||
|
||||
libc_dev = stdenv.gcc.libc_dev;
|
||||
|
|
|
@ -193,9 +193,9 @@ rec {
|
|||
stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc;
|
||||
|
||||
|
||||
# 6) Construct a third stdenv identical to the 2nd, except that
|
||||
# this one uses the Glibc built in step 3. It still uses
|
||||
# the recent binutils and rest of the bootstrap tools, including GCC.
|
||||
# 6) Construct a third stdenv identical to the 2nd, except that this
|
||||
# one uses the Glibc built in step 3. It still uses the recent
|
||||
# binutils and the rest of the bootstrap tools, including GCC.
|
||||
stdenvLinuxBoot3 = stdenvBootFun {
|
||||
gcc = wrapGCC {
|
||||
binutils = stdenvLinuxBoot1Pkgs.binutils;
|
||||
|
|
|
@ -2254,6 +2254,7 @@ let
|
|||
}));
|
||||
|
||||
gcc46_real = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.6 {
|
||||
stdenv = stdenvMulti;
|
||||
inherit noSysDirs;
|
||||
|
||||
# bootstrapping a profiled compiler does not work in the sheevaplug:
|
||||
|
|
Loading…
Reference in a new issue