diff --git a/pkgs/development/libraries/glibc-2.11/builder.sh b/pkgs/development/libraries/glibc-2.11/builder.sh index 6f1b1bbbbe1..fc1ea2f83eb 100644 --- a/pkgs/development/libraries/glibc-2.11/builder.sh +++ b/pkgs/development/libraries/glibc-2.11/builder.sh @@ -3,56 +3,6 @@ export NIX_NO_SELF_RPATH=1 source $stdenv/setup -# Explicitly tell glibc to use our pwd, not /bin/pwd. -export PWD_P=$(type -tP pwd) - -# Needed to install share/zoneinfo/zone.tab. Set to impure /bin/sh to -# prevent a retained dependency on the bootstrap tools in the -# stdenv-linux bootstrap. -export BASH_SHELL=/bin/sh - - -preConfigure() { - - for i in configure io/ftwtest-sh; do - # Can't use substituteInPlace here because replace hasn't been - # built yet in the bootstrap. - sed -i "$i" -e "s^/bin/pwd^$PWD_P^g" - done - - # In the glibc 2.6/2.7 tarballs C-translit.h is a little bit older - # than C-translit.h.in, forcing Make to rebuild it unnecessarily. - # This wouldn't be problem except that it requires Perl, which we - # don't want as a dependency in the Nixpkgs bootstrap. So force - # the output file to be newer. - touch locale/C-translit.h - - if test -n "$crossConfig"; then - sed -i s/-lgcc_eh//g Makeconfig - fi - - mkdir build - cd build - - configureScript=../configure - if test -n "$crossConfig"; then - cat > config.cache << "EOF" -libc_cv_forced_unwind=yes -libc_cv_c_cleanup=yes -libc_cv_gnu89_inline=yes -EOF - export BUILD_CC=gcc - export CC="${crossConfig}-gcc" - export AR="${crossConfig}-ar" - export RANLIB="${crossConfig}-ranlib" - configureFlags="${configureFlags} --cache-file=config.cache" - - # The host stripp will destroy everything in the target binaries otherwise - dontStrip=1 - fi -} - - postConfigure() { # Hack: get rid of the `-static' flag set by the bootstrap stdenv. # This has to be done *after* `configure' because it builds some diff --git a/pkgs/development/libraries/glibc-2.11/common.nix b/pkgs/development/libraries/glibc-2.11/common.nix new file mode 100644 index 00000000000..54fe7afca1f --- /dev/null +++ b/pkgs/development/libraries/glibc-2.11/common.nix @@ -0,0 +1,154 @@ +/* Build configuration used to build glibc, Info files, and locale + information. */ + +{ name, fetchurl, stdenv, installLocales ? false +, cross ? null, gccCross ? null, kernelHeaders ? null +, profilingLibraries ? false, meta, ... }@args : + +let version = "2.11"; +in +assert (cross != null) -> (gccCross != null); + +stdenv.mkDerivation ({ + inherit kernelHeaders installLocales; + + # The host/target system. + crossConfig = if (cross != null) then cross.config else null; + + inherit (stdenv) is64bit; + + patches = [ + /* Fix for NIXPKGS-79: when doing host name lookups, when + nsswitch.conf contains a line like + + hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 + + don't return an error when mdns4_minimal can't be found. This + is a bug in Glibc: when a service can't be found, NSS should + continue to the next service unless "UNAVAIL=return" is set. + ("NOTFOUND=return" refers to the service returning a NOTFOUND + error, not the service itself not being found.) The reason is + that the "status" variable (while initialised to UNAVAIL) is + outside of the loop that iterates over the services, the + "files" service sets status to NOTFOUND. So when the call to + find "mdns4_minimal" fails, "status" will still be NOTFOUND, + and it will return instead of continuing to "dns". Thus, the + line + + hosts: mdns4_minimal [NOTFOUND=return] dns mdns4 + + does work because "status" will contain UNAVAIL after the + failure to find mdns4_minimal. */ + ./nss-skip-unavail.patch + + /* Make it possible to override the locale-archive in NixOS. */ + ./locale-override.patch + + /* Have rpcgen(1) look for cpp(1) in $PATH. */ + ./rpcgen-path.patch + + /* Make sure `nscd' et al. are linked against `libssp'. */ + ./stack-protector-link.patch + ]; + + configureFlags = [ + "-C" + "--enable-add-ons" + (if kernelHeaders != null + then "--with-headers=${kernelHeaders}/include" + else "--without-headers") + (if profilingLibraries + then "--enable-profile" + else "--disable-profile") + ] ++ stdenv.lib.optionals (cross != null) [ + "--host=${cross.config}" + "--build=${stdenv.system}" + "--with-tls" + "--enable-kernel=2.6.0" + "--without-fp" + "--with-__thread" + ] ++ (if (stdenv.system == "armv5tel-linux") then [ + "--host=arm-linux-gnueabi" + "--build=arm-linux-gnueabi" + "--without-fp" + ] else []); + + buildInputs = stdenv.lib.optionals (cross != null) [ gccCross ]; + + # Needed to install share/zoneinfo/zone.tab. Set to impure /bin/sh to + # prevent a retained dependency on the bootstrap tools in the stdenv-linux + # bootstrap. + BASH_SHELL = "/bin/sh"; +} + +// + +(if (stdenv.system == "i686-linux") + then { + # Workaround for this bug: + # http://sourceware.org/bugzilla/show_bug.cgi?id=411 + # I.e. when gcc is compiled with --with-arch=i686, then the + # preprocessor symbol `__i686' will be defined to `1'. This causes + # the symbol __i686.get_pc_thunk.dx to be mangled. + NIX_CFLAGS_COMPILE = "-U__i686"; + } + else {}) + + // + + args + + // + +{ + name = args.name + "-${version}"; + + src = fetchurl { + url = "mirror://gnu/glibc/glibc-${version}.tar.bz2"; + sha256 = "0b6nbr89qmqcvzz26ggnw7gcxhvnzbc8z299h12wqjmcix4hxwcy"; + }; + + # `fetchurl' is a function and thus should not be passed to the + # `derivation' primitive. + fetchurl = null; + + # Remove absolute paths from `configure' & co.; build out-of-tree. + preConfigure = '' + export PWD_P=$(type -tP pwd) + for i in configure io/ftwtest-sh; do + # Can't use substituteInPlace here because replace hasn't been + # built yet in the bootstrap. + sed -i "$i" -e "s^/bin/pwd^$PWD_P^g" + done + mkdir ../build + cd ../build + + configureScript="../$sourceRoot/configure" + + ${if args ? preConfigure + then args.preConfigure + else ""} + ''; + + meta = ({ + homepage = http://www.gnu.org/software/libc/; + description = "The GNU C Library"; + + longDescription = + '' Any Unix-like operating system needs a C library: the library which + defines the "system calls" and other basic facilities such as + open, malloc, printf, exit... + + The GNU C library is used as the C library in the GNU system and + most systems with the Linux kernel. + ''; + + license = "LGPLv2+"; + + maintainers = [ stdenv.lib.maintainers.ludo ]; + platforms = stdenv.lib.platforms.linux; + } + // + args.meta + ); +}) diff --git a/pkgs/development/libraries/glibc-2.11/default.nix b/pkgs/development/libraries/glibc-2.11/default.nix index 8725eae73c1..866a2370eb1 100644 --- a/pkgs/development/libraries/glibc-2.11/default.nix +++ b/pkgs/development/libraries/glibc-2.11/default.nix @@ -5,116 +5,49 @@ , gccCross ? null }: -/* FIXME: Update `locales.nix' and `info.nix'. */ -let version = "2.11"; in +let build = import ./common.nix; +in + build ({ + name = "glibc" + + stdenv.lib.optionalString (cross != null) "-${cross.config}"; -stdenv.mkDerivation rec { - name = "glibc-${version}" + - stdenv.lib.optionalString (cross != null) "-${cross.config}"; + inherit fetchurl stdenv kernelHeaders installLocales profilingLibraries + cross gccCross; - builder = ./builder.sh; + builder = ./builder.sh; - src = fetchurl { - url = "mirror://gnu/glibc/${name}.tar.bz2"; - sha256 = "0b6nbr89qmqcvzz26ggnw7gcxhvnzbc8z299h12wqjmcix4hxwcy"; - }; + preInstall = '' + ensureDir $out/lib + ln -s ${stdenv.gcc.gcc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1 + ''; - inherit kernelHeaders installLocales; - crossConfig = if (cross != null) then cross.config else null; + postInstall = '' + rm $out/lib/libgcc_s.so.1 + ''; - inherit (stdenv) is64bit; + meta.description = "The GNU C Library"; + } - patches = [ - /* Fix for NIXPKGS-79: when doing host name lookups, when - nsswitch.conf contains a line like + // - hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 + (if cross != null + then { + preConfigure = '' + sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig" - don't return an error when mdns4_minimal can't be found. This - is a bug in Glibc: when a service can't be found, NSS should - continue to the next service unless "UNAVAIL=return" is set. - ("NOTFOUND=return" refers to the service returning a NOTFOUND - error, not the service itself not being found.) The reason is - that the "status" variable (while initialised to UNAVAIL) is - outside of the loop that iterates over the services, the - "files" service sets status to NOTFOUND. So when the call to - find "mdns4_minimal" fails, "status" will still be NOTFOUND, - and it will return instead of continuing to "dns". Thus, the - line + cat > config.cache << "EOF" +libc_cv_forced_unwind=yes +libc_cv_c_cleanup=yes +libc_cv_gnu89_inline=yes +EOF + export BUILD_CC=gcc + export CC="$crossConfig-gcc" + export AR="$crossConfig-ar" + export RANLIB="$crossConfig-ranlib" - hosts: mdns4_minimal [NOTFOUND=return] dns mdns4 - - does work because "status" will contain UNAVAIL after the - failure to find mdns4_minimal. */ - ./nss-skip-unavail.patch - - /* Make it possible to override the locale-archive in NixOS. */ - ./locale-override.patch - - /* Have rpcgen(1) look for cpp(1) in $PATH. */ - ./rpcgen-path.patch - - /* Make sure `nscd' et al. are linked against `libssp'. */ - ./stack-protector-link.patch - ]; - - configureFlags = [ - "--enable-add-ons" - "--with-headers=${kernelHeaders}/include" - (if profilingLibraries then "--enable-profile" else "--disable-profile") - ] ++ stdenv.lib.optionals (cross != null) [ - "--host=${cross.config}" - "--build=${stdenv.system}" - "--with-tls" - "--enable-kernel=2.6.0" - "--without-fp" - "--with-__thread" - ] ++ (if (stdenv.system == "armv5tel-linux") then [ - "--host=arm-linux-gnueabi" - "--build=arm-linux-gnueabi" - "--without-fp" - ] else []); - - buildInputs = stdenv.lib.optionals (cross != null) [ gccCross ]; - - preInstall = '' - ensureDir $out/lib - ln -s ${stdenv.gcc.gcc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1 - ''; - - postInstall = '' - rm $out/lib/libgcc_s.so.1 - ''; - - meta = { - homepage = http://www.gnu.org/software/libc/; - description = "The GNU C Library"; - - longDescription = - '' Any Unix-like operating system needs a C library: the library which - defines the "system calls" and other basic facilities such as - open, malloc, printf, exit... - - The GNU C library is used as the C library in the GNU system and - most systems with the Linux kernel. + # The host strip will destroy everything in the target binaries + # otherwise. + dontStrip=1 ''; - - license = "LGPLv2+"; - - maintainers = [ stdenv.lib.maintainers.ludo ]; - platforms = stdenv.lib.platforms.linux; - }; -} - -// - -(if (stdenv.system == "i686-linux") - then { - # Workaround for this bug: - # http://sourceware.org/bugzilla/show_bug.cgi?id=411 - # I.e. when gcc is compiled with --with-arch=i686, then the - # preprocessor symbol `__i686' will be defined to `1'. This causes - # the symbol __i686.get_pc_thunk.dx to be mangled. - NIX_CFLAGS_COMPILE = "-U__i686"; - } - else {}) + } + else {})) diff --git a/pkgs/development/libraries/glibc-2.11/info.nix b/pkgs/development/libraries/glibc-2.11/info.nix index 2b9c0f38533..926598b3760 100644 --- a/pkgs/development/libraries/glibc-2.11/info.nix +++ b/pkgs/development/libraries/glibc-2.11/info.nix @@ -1,47 +1,25 @@ { stdenv, fetchurl, texinfo, perl }: -stdenv.mkDerivation rec { - name = "glibc-info-2.9"; - - src = fetchurl { - url = http://nixos.org/tarballs/glibc-2.9-20081208.tar.bz2; - sha256 = "0zhxbgcsl97pf349m0lz8d5ljvvzrcqc23yf08d888xlk4ms8m3h"; - }; +let build = import ./common.nix; +in + build { + name = "glibc-info"; - patches = [ - /* Support GNU Binutils 2.20 and above. */ - ./binutils-2.20.patch - ]; + inherit fetchurl stdenv; - preConfigure = '' - export PWD_P=$(type -tP pwd) - for i in configure io/ftwtest-sh; do - # Can't use substituteInPlace here because replace hasn't been - # built yet in the bootstrap. - sed -i "$i" -e "s^/bin/pwd^$PWD_P^g" - done - mkdir ../build - cd ../build - - configureScript=../$sourceRoot/configure - ''; + configureFlags = [ "--enable-add-ons" ]; - configureFlags = [ "--enable-add-ons" ]; + buildInputs = [ texinfo perl ]; - buildInputs = [ texinfo perl ]; + buildPhase = "make info"; - buildPhase = "make info"; + # I don't know why the info is not generated in 'build' + # Somehow building the info still does not work, because the final + # libc.info hasn't a Top node. + installPhase = '' + ensureDir "$out/share/info" + cp -v "../$sourceRoot/manual/"*.info* "$out/share/info" + ''; - # I don't know why the info is not generated in 'build' - # Somehow building the info still does not work, because the final - # libc.info hasn't a Top node. - installPhase = '' - ensureDir $out/share/info - cp ../$sourceRoot/manual/*.info $out/share/info - ''; - - meta = { - homepage = http://www.gnu.org/software/libc/; - description = "GNU Info manual of the GNU C Library"; - }; -} + meta.description = "GNU Info manual of the GNU C Library"; + } diff --git a/pkgs/development/libraries/glibc-2.11/locales.nix b/pkgs/development/libraries/glibc-2.11/locales.nix index 3046374ca34..64e6bd43a67 100644 --- a/pkgs/development/libraries/glibc-2.11/locales.nix +++ b/pkgs/development/libraries/glibc-2.11/locales.nix @@ -8,60 +8,35 @@ { stdenv, fetchurl, allLocales ? true, locales ? ["en_US.UTF-8/UTF-8"] }: -stdenv.mkDerivation rec { - name = "glibc-locales-2.9"; +let build = import ./common.nix; +in + build { + name = "glibc-locales"; - builder = ./localesbuilder.sh; + inherit fetchurl stdenv; + installLocales = true; - src = fetchurl { - url = http://ftp.gnu.org/gnu/glibc/glibc-2.9.tar.bz2; - sha256 = "0v53m7flx6qcx7cvrvvw6a4dx4x3y6k8nvpc4wfv5xaaqy2am2q9"; - }; + builder = ./localesbuilder.sh; - srcPorts = fetchurl { - url = http://ftp.gnu.org/gnu/glibc/glibc-ports-2.9.tar.bz2; - sha256 = "0r2sn527wxqifi63di7ns9wbjh1cainxn978w178khhy7yw9fk42"; - }; + # Awful hack: `localedef' doesn't allow the path to `locale-archive' + # to be overriden, but you *can* specify a prefix, i.e. it will use + # //lib/locale/locale-archive. So we use + # $TMPDIR as a prefix, meaning that the locale-archive is placed in + # $TMPDIR/nix/store/...-glibc-.../lib/locale/locale-archive. + buildPhase = + '' + mkdir -p $TMPDIR/"$(dirname $(readlink -f $(type -p localedef)))/../lib/locale" + make localedata/install-locales \ + LOCALEDEF="localedef --prefix=$TMPDIR" \ + localedir=$out/lib/locale \ + ${if allLocales then "" else "SUPPORTED-LOCALES=\"${toString locales}\""} + ''; - inherit (stdenv) is64bit; + installPhase = + '' + ensureDir "$out/lib/locale" + cp -v "$TMPDIR/nix/store/"*"/lib/locale/locale-archive" "$out/lib/locale" + ''; - configureFlags = [ - "--enable-add-ons" - "--without-headers" - "--disable-profile" - ] ++ (if (stdenv.system == "armv5tel-linux") then [ - "--host=arm-linux-gnueabi" - "--build=arm-linux-gnueabi" - "--without-fp" - ] else []); - - patches = [ - /* Support GNU Binutils 2.20 and above. */ - ./binutils-2.20.patch - ]; - - # Awful hack: `localedef' doesn't allow the path to `locale-archive' - # to be overriden, but you *can* specify a prefix, i.e. it will use - # //lib/locale/locale-archive. So we use - # $TMPDIR as a prefix, meaning that the locale-archive is placed in - # $TMPDIR/nix/store/...-glibc-.../lib/locale/locale-archive. - buildPhase = - '' - mkdir -p $TMPDIR/"$(dirname $(readlink -f $(type -p localedef)))/../lib/locale" - make localedata/install-locales \ - LOCALEDEF="localedef --prefix=$TMPDIR" \ - localedir=$out/lib/locale \ - ${if allLocales then "" else "SUPPORTED-LOCALES=\"${toString locales}\""} - ''; - - installPhase = - '' - ensureDir $out/lib/locale - cp $TMPDIR/nix/store/*/lib/locale/locale-archive $out/lib/locale/ - ''; - - meta = { - homepage = http://www.gnu.org/software/libc/; - description = "Locale information for the GNU C Library"; - }; -} + meta.description = "Locale information for the GNU C Library"; + } diff --git a/pkgs/development/libraries/glibc-2.11/localesbuilder.sh b/pkgs/development/libraries/glibc-2.11/localesbuilder.sh index a28f6bcbaeb..d732e208fa2 100644 --- a/pkgs/development/libraries/glibc-2.11/localesbuilder.sh +++ b/pkgs/development/libraries/glibc-2.11/localesbuilder.sh @@ -3,39 +3,6 @@ export NIX_NO_SELF_RPATH=1 source $stdenv/setup -# Explicitly tell glibc to use our pwd, not /bin/pwd. -export PWD_P=$(type -tP pwd) - -# Needed to install share/zoneinfo/zone.tab. Set to impure /bin/sh to -# prevent a retained dependency on the bootstrap tools in the -# stdenv-linux bootstrap. -export BASH_SHELL=/bin/sh - - -preConfigure() { - - for i in configure io/ftwtest-sh; do - # Can't use substituteInPlace here because replace hasn't been - # built yet in the bootstrap. - sed -i "$i" -e "s^/bin/pwd^$PWD_P^g" - done - - # In the glibc 2.6/2.7 tarballs C-translit.h is a little bit older - # than C-translit.h.in, forcing Make to rebuild it unnecessarily. - # This wouldn't be problem except that it requires Perl, which we - # don't want as a dependency in the Nixpkgs bootstrap. So force - # the output file to be newer. - touch locale/C-translit.h - - tar xvjf "$srcPorts" - - mkdir build - cd build - - configureScript=../configure -} - - postConfigure() { # Hack: get rid of the `-static' flag set by the bootstrap stdenv. # This has to be done *after* `configure' because it builds some