glibc: Split into multiple outputs

This reduces the size of closures a lot by getting rid of Glibc's
header files, static libraries and utilities.  For instance, the
closure of GNU Hello went from 41 MiB to 22 MiB.

TODO: We may want to merge back in parts of Glibc that we previously
split off (such as the info files).
This commit is contained in:
Eelco Dolstra 2013-06-11 18:39:23 +02:00
parent b9049bff6d
commit d8231a66eb
8 changed files with 32 additions and 17 deletions

View File

@ -24,7 +24,7 @@ if test -z "$nativeLibc"; then
# compile, because it uses "#include_next <limits.h>" to find the
# limits.h file in ../includes-fixed. To remedy the problem,
# another -idirafter is necessary to add that directory again.
echo "-B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
echo "-B$libc/lib/ -idirafter $libc_dev/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
echo "-L$libc/lib" > $out/nix-support/libc-ldflags
@ -85,6 +85,7 @@ doSubstitute() {
-e "s^@binutils@^$binutils^g" \
-e "s^@coreutils@^$coreutils^g" \
-e "s^@libc@^$libc^g" \
-e "s^@libc_bin@^$libc_bin^g" \
-e "s^@ld@^$ldPath/ld^g" \
< "$src" > "$dst"
}
@ -191,5 +192,5 @@ cp -p $utils $out/nix-support/utils.sh
# tools like gcov, the manpages, etc. as well (including for binutils
# and Glibc).
if test -z "$nativeTools"; then
echo $gcc $binutils $libc > $out/nix-support/propagated-user-env-packages
echo $gcc $binutils $libc $libc_bin > $out/nix-support/propagated-user-env-packages
fi

View File

@ -41,6 +41,8 @@ stdenv.mkDerivation {
inherit nativeTools nativeLibc nativePrefix 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;
binutils = if nativeTools then null else binutils;
# The wrapper scripts use 'cat', so we may need coreutils
coreutils = if nativeTools then null else coreutils;

View File

@ -25,7 +25,7 @@ if test -n "@binutils@"; then
fi
if test -n "@libc@"; then
addToSearchPath PATH @libc@/bin
addToSearchPath PATH @libc_bin@/bin
fi
if test -n "@coreutils@"; then

View File

@ -12,8 +12,10 @@ postConfigure() {
export NIX_DONT_SET_RPATH=1
unset CFLAGS
}
# Apparently --bindir is not respected.
makeFlagsArray+=("bindir=$bin/bin" "sbindir=$bin/sbin" "rootsbindir=$bin/sbin")
}
postInstall() {
if test -n "$installLocales"; then
@ -27,7 +29,7 @@ postInstall() {
if test -z "$hurdHeaders"; then
# Include the Linux kernel headers in Glibc, except the `scsi'
# subdirectory, which Glibc provides itself.
(cd $out/include && \
(cd $dev/include && \
ln -sv $(ls -d $kernelHeaders/include/* | grep -v 'scsi$') .)
fi
@ -49,6 +51,17 @@ postInstall() {
# This file, that should not remain in the glibc derivation,
# may have not been created during the preInstall
rm -f $out/lib/libgcc_s.so.1
# Put libraries for static linking in a separate output. Note
# that libc_nonshared.a and libpthread_nonshared.a are required
# for dynamically-linked applications.
mkdir -p $static/lib
mv $out/lib/*.a $static/lib
mv $static/lib/lib*_nonshared.a $out/lib
# Work around a Nix bug: hard links across outputs cause a build failure.
cp $bin/bin/getconf $bin/bin/getconf_
mv $bin/bin/getconf_ $bin/bin/getconf
}
genericBuild

View File

@ -23,6 +23,8 @@ in
builder = ./builder.sh;
outputs = [ "out" "dev" "bin" "static" ];
# When building glibc from bootstrap-tools, we need libgcc_s at RPATH for
# any program we run, because the gcc will have been placed at a new
# store path than that determined when built (as a source for the
@ -93,7 +95,7 @@ in
# To avoid a dependency on the build system 'bash'.
preFixup = ''
rm $out/bin/{ldd,tzselect,catchsegv,xtrace}
rm $bin/bin/{ldd,tzselect,catchsegv,xtrace}
'';
}
else {}))

View File

@ -1,6 +1,6 @@
{ fetchurl, stdenv, gettext }:
stdenv.mkDerivation (rec {
stdenv.mkDerivation rec {
name = "libelf-0.8.13";
src = fetchurl {
@ -10,6 +10,11 @@ stdenv.mkDerivation (rec {
doCheck = true;
# Libelf's custom NLS macros fail to determine the catalog file extension on
# Darwin, so disable NLS for now.
# FIXME: Eventually make Gettext a build input on all platforms.
configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-nls";
meta = {
description = "Libelf, an ELF object file access library";
@ -21,12 +26,3 @@ stdenv.mkDerivation (rec {
maintainers = [ stdenv.lib.maintainers.ludo ];
};
}
//
# Libelf's custom NLS macros fail to determine the catalog file extension on
# Darwin, so disable NLS for now.
# FIXME: Eventually make Gettext a build input on all platforms.
(if stdenv.isDarwin
then { configureFlags = [ "--disable-nls" ]; }
else { }))

View File

@ -7,7 +7,7 @@
# The function defaults are for easy testing.
{ system ? builtins.currentSystem
, allPackages ? import ../../top-level/all-packages.nix
, platform ? null, config }:
, platform ? null, config ? {} }:
rec {

View File

@ -3902,6 +3902,7 @@ let
}));
glibc217 = callPackage ../development/libraries/glibc/2.17 {
stdenv = stdenvMulti;
kernelHeaders = linuxHeaders;
installLocales = config.glibc.locales or false;
machHeaders = null;