summary refs log tree commit diff
path: root/pkgs/development/compilers/gcc/4.6
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-06-12 16:11:14 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-06-12 16:11:14 +0200
commitdbe432e6f4502fc7b4e290d1b3356083bd93b099 (patch)
tree1cf404f51c52c717a4b5b004f91ab882860f4346 /pkgs/development/compilers/gcc/4.6
parent2cfeca153cd9418d91c301e182caee1d3f6262e7 (diff)
downloadnixlib-dbe432e6f4502fc7b4e290d1b3356083bd93b099.tar
nixlib-dbe432e6f4502fc7b4e290d1b3356083bd93b099.tar.gz
nixlib-dbe432e6f4502fc7b4e290d1b3356083bd93b099.tar.bz2
nixlib-dbe432e6f4502fc7b4e290d1b3356083bd93b099.tar.lz
nixlib-dbe432e6f4502fc7b4e290d1b3356083bd93b099.tar.xz
nixlib-dbe432e6f4502fc7b4e290d1b3356083bd93b099.tar.zst
nixlib-dbe432e6f4502fc7b4e290d1b3356083bd93b099.zip
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
Diffstat (limited to 'pkgs/development/compilers/gcc/4.6')
-rw-r--r--pkgs/development/compilers/gcc/4.6/builder.sh18
-rw-r--r--pkgs/development/compilers/gcc/4.6/default.nix4
2 files changed, 16 insertions, 6 deletions
diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh
index 19dfb9c1bae6..e207b21f4a8c 100644
--- a/pkgs/development/compilers/gcc/4.6/builder.sh
+++ b/pkgs/development/compilers/gcc/4.6/builder.sh
@@ -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
diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix
index af6e9ab0ee19..476ddaa84091 100644
--- a/pkgs/development/compilers/gcc/4.6/default.nix
+++ b/pkgs/development/compilers/gcc/4.6/default.nix
@@ -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;