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"
|
ldPath="$nativePrefix/bin"
|
||||||
else
|
else
|
||||||
if test -e "$gcc/lib64"; then
|
if test -e "$gcc/lib64"; then
|
||||||
gccLDFlags="$gccLDFlags -L$gcc/lib64"
|
gccLDFlags="$gccLDFlags -L$gcc_lib/lib64"
|
||||||
fi
|
fi
|
||||||
gccLDFlags="$gccLDFlags -L$gcc/lib"
|
gccLDFlags="$gccLDFlags -L$gcc_lib/lib"
|
||||||
if [ -n "$langVhdl" ]; then
|
if [ -n "$langVhdl" ]; then
|
||||||
gccLDFlags="$gccLDFlags -L$zlib/lib"
|
gccLDFlags="$gccLDFlags -L$zlib/lib"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -40,6 +40,7 @@ stdenv.mkDerivation {
|
||||||
addFlags = ./add-flags;
|
addFlags = ./add-flags;
|
||||||
|
|
||||||
inherit nativeTools nativeLibc nativePrefix gcc;
|
inherit nativeTools nativeLibc nativePrefix gcc;
|
||||||
|
gcc_lib = gcc.lib or gcc;
|
||||||
libc = if nativeLibc then null else libc;
|
libc = if nativeLibc then null else libc;
|
||||||
libc_dev = if nativeLibc then null else libc.dev or libc;
|
libc_dev = if nativeLibc then null else libc.dev or libc;
|
||||||
libc_bin = if nativeLibc then null else libc.bin 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
|
if test "$staticCompiler" = "1"; then
|
||||||
EXTRA_LDFLAGS="-static"
|
EXTRA_LDFLAGS="-static"
|
||||||
else
|
else
|
||||||
EXTRA_LDFLAGS=""
|
EXTRA_LDFLAGS="-Wl,-rpath,$lib/lib"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# GCC interprets empty paths as ".", which we don't want.
|
# GCC interprets empty paths as ".", which we don't want.
|
||||||
if test -z "$CPATH"; then unset CPATH; fi
|
if test -z "$CPATH"; then unset CPATH; fi
|
||||||
if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
|
if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
|
||||||
|
@ -205,6 +206,10 @@ preInstall() {
|
||||||
|
|
||||||
|
|
||||||
postInstall() {
|
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
|
# Remove precompiled headers for now. They are very big and
|
||||||
# probably not very useful yet.
|
# probably not very useful yet.
|
||||||
find $out/include -name "*.gch" -exec rm -rf {} \; -prune
|
find $out/include -name "*.gch" -exec rm -rf {} \; -prune
|
||||||
|
@ -216,6 +221,7 @@ postInstall() {
|
||||||
|
|
||||||
# More dependencies with the previous gcc or some libs (gccbug stores the build command line)
|
# More dependencies with the previous gcc or some libs (gccbug stores the build command line)
|
||||||
rm -rf $out/bin/gccbug
|
rm -rf $out/bin/gccbug
|
||||||
|
|
||||||
# Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
|
# Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
|
||||||
for i in $out/libexec/gcc/*/*/*; do
|
for i in $out/libexec/gcc/*/*/*; do
|
||||||
if PREV_RPATH=`patchelf --print-rpath $i`; then
|
if PREV_RPATH=`patchelf --print-rpath $i`; then
|
||||||
|
|
|
@ -192,6 +192,10 @@ stdenv.mkDerivation ({
|
||||||
inherit langC langCC langFortran langJava langAda langGo;
|
inherit langC langCC langFortran langJava langAda langGo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
outputs = [ "out" "lib" ];
|
||||||
|
|
||||||
|
setOutputConfigureFlags = false;
|
||||||
|
|
||||||
inherit patches enableMultilib;
|
inherit patches enableMultilib;
|
||||||
|
|
||||||
libc_dev = stdenv.gcc.libc_dev;
|
libc_dev = stdenv.gcc.libc_dev;
|
||||||
|
|
|
@ -193,9 +193,9 @@ rec {
|
||||||
stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc;
|
stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc;
|
||||||
|
|
||||||
|
|
||||||
# 6) Construct a third stdenv identical to the 2nd, except that
|
# 6) Construct a third stdenv identical to the 2nd, except that this
|
||||||
# this one uses the Glibc built in step 3. It still uses
|
# one uses the Glibc built in step 3. It still uses the recent
|
||||||
# the recent binutils and rest of the bootstrap tools, including GCC.
|
# binutils and the rest of the bootstrap tools, including GCC.
|
||||||
stdenvLinuxBoot3 = stdenvBootFun {
|
stdenvLinuxBoot3 = stdenvBootFun {
|
||||||
gcc = wrapGCC {
|
gcc = wrapGCC {
|
||||||
binutils = stdenvLinuxBoot1Pkgs.binutils;
|
binutils = stdenvLinuxBoot1Pkgs.binutils;
|
||||||
|
|
|
@ -2254,6 +2254,7 @@ let
|
||||||
}));
|
}));
|
||||||
|
|
||||||
gcc46_real = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.6 {
|
gcc46_real = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.6 {
|
||||||
|
stdenv = stdenvMulti;
|
||||||
inherit noSysDirs;
|
inherit noSysDirs;
|
||||||
|
|
||||||
# bootstrapping a profiled compiler does not work in the sheevaplug:
|
# bootstrapping a profiled compiler does not work in the sheevaplug:
|
||||||
|
|
Loading…
Reference in a new issue