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:
Eelco Dolstra
2013-06-12 16:11:14 +02:00
parent 2cfeca153c
commit dbe432e6f4
6 changed files with 23 additions and 11 deletions
+12 -6
View File
@@ -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;