diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/glibc')
18 files changed, 1111 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/glibc/2.33-master.patch.gz b/nixpkgs/pkgs/development/libraries/glibc/2.33-master.patch.gz new file mode 100644 index 000000000000..777e94e2b2ea --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/2.33-master.patch.gz Binary files differdiff --git a/nixpkgs/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch b/nixpkgs/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch new file mode 100644 index 000000000000..ce18b874c427 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch @@ -0,0 +1,39 @@ +diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure +index cace758c01..38fe7fe0b0 100644 +--- a/sysdeps/unix/sysv/linux/configure ++++ b/sysdeps/unix/sysv/linux/configure +@@ -69,7 +69,7 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel header at least $minimum_kernel" >&5 + $as_echo_n "checking for kernel header at least $minimum_kernel... " >&6; } + decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`; +-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`; ++abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #include <linux/version.h> +diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac +index 13abda0a51..6abc12eaed 100644 +--- a/sysdeps/unix/sysv/linux/configure.ac ++++ b/sysdeps/unix/sysv/linux/configure.ac +@@ -50,7 +50,7 @@ fi + AC_MSG_CHECKING(for kernel header at least $minimum_kernel) + changequote(,)dnl + decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`; +-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`; ++abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`; + changequote([,])dnl + AC_TRY_COMPILE([#include <linux/version.h> + #if LINUX_VERSION_CODE < $decnum +diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h +index 823cd8224d..482caaeeec 100644 +--- a/sysdeps/unix/sysv/linux/dl-osinfo.h ++++ b/sysdeps/unix/sysv/linux/dl-osinfo.h +@@ -39,7 +39,7 @@ + GLRO(dl_osversion) = version; \ + \ + /* Now we can test with the required version. */ \ +- if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION) \ ++ if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION && version != 0x020620) \ + /* Not sufficent. */ \ + FATAL ("FATAL: kernel too old\n"); \ + } \ diff --git a/nixpkgs/pkgs/development/libraries/glibc/common.nix b/nixpkgs/pkgs/development/libraries/glibc/common.nix new file mode 100644 index 000000000000..ffec9972d287 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/common.nix @@ -0,0 +1,291 @@ +/* Build configuration used to build glibc, Info files, and locale + information. + + Note that this derivation has multiple outputs and does not respect the + standard convention of putting the executables into the first output. The + first output is `lib` so that the libraries provided by this derivation + can be accessed directly, e.g. + + "${pkgs.glibc}/lib/ld-linux-x86_64.so.2" + + The executables are put into `bin` output and need to be referenced via + the `bin` attribute of the main package, e.g. + + "${pkgs.glibc.bin}/bin/ldd". + + The executables provided by glibc typically include `ldd`, `locale`, `iconv` + but the exact set depends on the library version and the configuration. +*/ + +# Note: this package is used for bootstrapping fetchurl, and thus +# cannot use fetchpatch! All mutable patches (generated by GitHub or +# cgit) that are needed here should be included directly in Nixpkgs as +# files. + +{ stdenv, lib +, buildPackages +, fetchurl +, linuxHeaders ? null +, gd ? null, libpng ? null +, libidn2 +, bison +, python3Minimal +}: + +{ pname +, withLinuxHeaders ? false +, profilingLibraries ? false +, withGd ? false +, meta +, extraBuildInputs ? [] +, extraNativeBuildInputs ? [] +, ... +} @ args: + +let + version = "2.33"; + patchSuffix = "-117"; + sha256 = "sha256-LiVWAA4QXb1X8Layoy/yzxc73k8Nhd/8z9i35RoGd/8="; +in + +assert withLinuxHeaders -> linuxHeaders != null; +assert withGd -> gd != null && libpng != null; + +stdenv.mkDerivation ({ + version = version + patchSuffix; + linuxHeaders = if withLinuxHeaders then linuxHeaders else null; + + inherit (stdenv) is64bit; + + enableParallelBuilding = true; + + patches = + [ + /* No tarballs for stable upstream branch, only https://sourceware.org/git/glibc.git and using git would complicate bootstrapping. + $ git fetch --all -p && git checkout origin/release/2.33/master && git describe + glibc-2.33-117-g55446dd8a2 + $ git show --minimal --reverse glibc-2.33.. | gzip -9n --rsyncable - > 2.33-master.patch.gz + + To compare the archive contents zdiff can be used. + $ zdiff -u 2.33-master.patch.gz ../nixpkgs/pkgs/development/libraries/glibc/2.33-master.patch.gz + */ + ./2.33-master.patch.gz + + /* Allow NixOS and Nix to handle the locale-archive. */ + ./nix-locale-archive.patch + + /* Don't use /etc/ld.so.cache, for non-NixOS systems. */ + ./dont-use-system-ld-so-cache.patch + + /* Don't use /etc/ld.so.preload, but /etc/ld-nix.so.preload. */ + ./dont-use-system-ld-so-preload.patch + + /* The command "getconf CS_PATH" returns the default search path + "/bin:/usr/bin", which is inappropriate on NixOS machines. This + patch extends the search path by "/run/current-system/sw/bin". */ + ./fix_path_attribute_in_getconf.patch + + /* Allow running with RHEL 6 -like kernels. The patch adds an exception + for glibc to accept 2.6.32 and to tag the ELFs as 2.6.32-compatible + (otherwise the loader would refuse libc). + Note that glibc will fully work only on their heavily patched kernels + and we lose early mismatch detection on 2.6.32. + + On major glibc updates we should check that the patched kernel supports + all the required features. ATM it's verified up to glibc-2.26-131. + # HOWTO: check glibc sources for changes in kernel requirements + git log -p glibc-2.25.. sysdeps/unix/sysv/linux/x86_64/kernel-features.h sysdeps/unix/sysv/linux/kernel-features.h + # get kernel sources (update the URL) + mkdir tmp && cd tmp + curl http://vault.centos.org/6.9/os/Source/SPackages/kernel-2.6.32-696.el6.src.rpm | rpm2cpio - | cpio -idmv + tar xf linux-*.bz2 + # check syscall presence, for example + less linux-*?/arch/x86/kernel/syscall_table_32.S + */ + ./allow-kernel-2.6.32.patch + + /* Provide a fallback for missing prlimit64 syscall on RHEL 6 -like + kernels. + + This patch is maintained by @veprbl. If it gives you trouble, feel + free to ping me, I'd be happy to help. + */ + (fetchurl { + url = "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/patches/glibc-reinstate-prlimit64-fallback.patch?id=eab07e78b691ae7866267fc04d31c7c3ad6b0eeb"; + sha256 = "091bk3kyrx1gc380gryrxjzgcmh1ajcj8s2rjhp2d2yzd5mpd5ps"; + }) + + /* Provide utf-8 locales by default, so we can use it in stdenv without depending on our large locale-archive. */ + (fetchurl { + url = "https://salsa.debian.org/glibc-team/glibc/raw/49767c9f7de4828220b691b29de0baf60d8a54ec/debian/patches/localedata/locale-C.diff"; + sha256 = "0irj60hs2i91ilwg5w7sqrxb695c93xg0ik7yhhq9irprd7fidn4"; + }) + + ./fix-x64-abi.patch + + /* https://github.com/NixOS/nixpkgs/pull/137601 */ + ./nix-nss-open-files.patch + ] + ++ lib.optional stdenv.hostPlatform.isMusl ./fix-rpc-types-musl-conflicts.patch + ++ lib.optional stdenv.buildPlatform.isDarwin ./darwin-cross-build.patch; + + postPatch = + '' + # Needed for glibc to build with the gnumake 3.82 + # http://comments.gmane.org/gmane.linux.lfs.support/31227 + sed -i 's/ot \$/ot:\n\ttouch $@\n$/' manual/Makefile + + # nscd needs libgcc, and we don't want it dynamically linked + # because we don't want it to depend on bootstrap-tools libs. + echo "LDFLAGS-nscd += -static-libgcc" >> nscd/Makefile + '' + # FIXME: find a solution for infinite recursion in cross builds. + # For now it's hopefully acceptable that IDN from libc doesn't reliably work. + + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' + + # Ensure that libidn2 is found. + patch -p 1 <<EOF + --- a/inet/idna.c + +++ b/inet/idna.c + @@ -25,1 +25,1 @@ + -#define LIBIDN2_SONAME "libidn2.so.0" + +#define LIBIDN2_SONAME "${lib.getLib libidn2}/lib/libidn2.so.0" + EOF + ''; + + configureFlags = + [ "-C" + "--enable-add-ons" + "--sysconfdir=/etc" + "--enable-stackguard-randomization" + "--enable-bind-now" + (lib.withFeatureAs withLinuxHeaders "headers" "${linuxHeaders}/include") + (lib.enableFeature profilingLibraries "profile") + ] ++ lib.optionals (stdenv.hostPlatform.isx86 || stdenv.hostPlatform.isAarch64) [ + # This feature is currently supported on + # i386, x86_64 and x32 with binutils 2.29 or later, + # and on aarch64 with binutils 2.30 or later. + # https://sourceware.org/glibc/wiki/PortStatus + "--enable-static-pie" + ] ++ lib.optionals withLinuxHeaders [ + "--enable-kernel=3.2.0" # can't get below with glibc >= 2.26 + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + (lib.flip lib.withFeature "fp" + (stdenv.hostPlatform.gcc.float or (stdenv.hostPlatform.parsed.abi.float or "hard") == "soft")) + "--with-__thread" + ] ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform && stdenv.hostPlatform.isAarch32) [ + "--host=arm-linux-gnueabi" + "--build=arm-linux-gnueabi" + + # To avoid linking with -lgcc_s (dynamic link) + # so the glibc does not depend on its compiler store path + "libc_cv_as_needed=no" + ] ++ lib.optional withGd "--with-gd"; + + makeFlags = [ + "OBJCOPY=${stdenv.cc.targetPrefix}objcopy" + ]; + + installFlags = [ "sysconfdir=$(out)/etc" ]; + + outputs = [ "out" "bin" "dev" "static" ]; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ bison python3Minimal ] ++ extraNativeBuildInputs; + buildInputs = [ linuxHeaders ] ++ lib.optionals withGd [ gd libpng ] ++ extraBuildInputs; + + # 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"; + + # Used by libgcc, elf-header, and others to determine ABI + passthru = { inherit version; minorRelease = version; }; +} + +// (removeAttrs args [ "withLinuxHeaders" "withGd" ]) // + +{ + src = fetchurl { + url = "mirror://gnu/glibc/glibc-${version}.tar.xz"; + inherit sha256; + }; + + # 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="`pwd`/../$sourceRoot/configure" + + ${lib.optionalString (stdenv.cc.libc != null) + ''makeFlags="$makeFlags BUILD_LDFLAGS=-Wl,-rpath,${stdenv.cc.libc}/lib OBJDUMP=${stdenv.cc.bintools.bintools}/bin/objdump"'' + } + + + '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig" + + cat > config.cache << "EOF" + libc_cv_forced_unwind=yes + libc_cv_c_cleanup=yes + libc_cv_gnu89_inline=yes + EOF + + # ./configure has logic like + # + # AR=`$CC -print-prog-name=ar` + # + # This searches various directories in the gcc and its wrapper. In nixpkgs, + # this returns the bare string "ar", which is build ar. This can result as + # a build failure with the following message: + # + # libc_pic.a: error adding symbols: archive has no index; run ranlib to add one + # + # (Observed cross compiling from aarch64-linux -> armv7l-linux). + # + # Nixpkgs passes a correct value for AR and friends, so to use the correct + # set of tools, we only need to delete this special handling. + sed -i \ + -e '/^AR=/d' \ + -e '/^AS=/d' \ + -e '/^LD=/d' \ + -e '/^OBJCOPY=/d' \ + -e '/^OBJDUMP=/d' \ + $configureScript + ''; + + preBuild = lib.optionalString withGd "unset NIX_DONT_SET_RPATH"; + + doCheck = false; # fails + + meta = with lib; { + homepage = "https://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 = licenses.lgpl2Plus; + + maintainers = with maintainers; [ eelco ma27 ]; + platforms = platforms.linux; + } // meta; +} + +// lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) { + preInstall = null; # clobber the native hook +}) diff --git a/nixpkgs/pkgs/development/libraries/glibc/darwin-cross-build.patch b/nixpkgs/pkgs/development/libraries/glibc/darwin-cross-build.patch new file mode 100644 index 000000000000..b746e6369a07 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/darwin-cross-build.patch @@ -0,0 +1,77 @@ +enable cross-compilation of glibc on Darwin (build=Darwin, host=Linux) +* increase ulimit for open files: macOS default of 256 is too low for glibc build system +* use host version of ar, which is given by environment variable +* build system uses stamp.os and stamp.oS files, which only differ in case; + this fails on macOS, so replace .oS with .o_S +--- glibc-2.32/Makefile.in 2018-02-01 17:17:18.000000000 +0100 ++++ glibc-2.32/Makefile.in 2020-12-27 18:21:30.000000000 +0100 +@@ -6,9 +6,11 @@ + .PHONY: all install bench + + all .DEFAULT: +- $(MAKE) -r PARALLELMFLAGS="$(PARALLELMFLAGS)" -C $(srcdir) objdir=`pwd` $@ ++ ulimit -n 1024; \ ++ $(MAKE) -r AR=$$AR PARALLELMFLAGS="$(PARALLELMFLAGS)" -C $(srcdir) objdir=`pwd` $@ + + install: ++ ulimit -n 1024; \ + LC_ALL=C; export LC_ALL; \ + $(MAKE) -r PARALLELMFLAGS="$(PARALLELMFLAGS)" -C $(srcdir) objdir=`pwd` $@ + +--- glibc-2.32/Makerules 2018-02-01 17:17:18.000000000 +0100 ++++ glibc-2.32/Makerules 2020-12-27 18:21:30.000000000 +0100 +@@ -847,8 +847,8 @@ + ifndef objects + + # Create the stamp$o files to keep the parent makefile happy. +-subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o) +-$(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o): ++subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$(subst .oS,.o_S,$o)) ++$(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$(subst .oS,.o_S,$o)): + $(make-target-directory) + rm -f $@; > $@ + else +@@ -859,7 +859,7 @@ + # The parent will then actually add them all to the archive in the + # archive rule, below. + define o-iterator-doit +-$(objpfx)stamp$o: $(o-objects); $$(do-stamp) ++$(objpfx)stamp$(subst .oS,.o_S,$o): $(o-objects); $$(do-stamp) + endef + define do-stamp + $(make-target-directory) +@@ -875,14 +875,14 @@ + # on the stamp files built above. + define o-iterator-doit + $(common-objpfx)$(patsubst %,$(libtype$o),c): \ +- $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib) ++ $(subdirs-stamp-o) $(common-objpfx)stamp$(subst .oS,.o_S,$o); $$(do-makelib) + endef + define do-makelib + cd $(common-objdir) && \ + $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)` + endef + subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%) +-subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps)) ++subdirs-stamp-o = $(subst %,$(subst .oS,.o_S,$o),$(subdirs-stamps)) + ifndef subdir + $(subdirs-stamps): subdir_lib; + endif +@@ -893,7 +893,7 @@ + # This makes all the object files. + .PHONY: objects objs libobjs extra-objs + objects objs: libobjs extra-objs +-libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o) ++libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$(subst .oS,.o_S,$o)) + extra-objs: $(addprefix $(objpfx),$(extra-objs)) + + # Canned sequence for building an extra library archive. +@@ -1499,7 +1499,7 @@ + $(rmobjs) + define rmobjs + $(foreach o,$(object-suffixes-for-libc), +--rm -f $(objpfx)stamp$o $(o-objects)) ++-rm -f $(objpfx)stamp$(subst .oS,.o_S,$o) $(o-objects)) + endef + + # Also remove the dependencies and generated source files. diff --git a/nixpkgs/pkgs/development/libraries/glibc/default.nix b/nixpkgs/pkgs/development/libraries/glibc/default.nix new file mode 100644 index 000000000000..caaacfe4f436 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/default.nix @@ -0,0 +1,150 @@ +{ lib, stdenv, callPackage +, withLinuxHeaders ? true +, profilingLibraries ? false +, withGd ? false +, buildPackages +}: + +let + gdCflags = [ + "-Wno-error=stringop-truncation" + "-Wno-error=missing-attributes" + "-Wno-error=array-bounds" + ]; +in + +callPackage ./common.nix { inherit stdenv; } { + pname = "glibc" + lib.optionalString withGd "-gd"; + + inherit withLinuxHeaders profilingLibraries withGd; + + # Note: + # Things you write here override, and do not add to, + # the values in `common.nix`. + # (For example, if you define `patches = [...]` here, it will + # override the patches in `common.nix`.) + + NIX_NO_SELF_RPATH = true; + + postConfigure = '' + # Hack: get rid of the `-static' flag set by the bootstrap stdenv. + # This has to be done *after* `configure' because it builds some + # test binaries. + export NIX_CFLAGS_LINK= + export NIX_LDFLAGS_BEFORE= + + export NIX_DONT_SET_RPATH=1 + unset CFLAGS + + # Apparently --bindir is not respected. + makeFlagsArray+=("bindir=$bin/bin" "sbindir=$bin/sbin" "rootsbindir=$bin/sbin") + ''; + + # The stackprotector and fortify hardening flags are autodetected by glibc + # and enabled by default if supported. Setting it for every gcc invocation + # does not work. + hardeningDisable = [ "stackprotector" "fortify" ] + # XXX: Not actually musl-speciic but since only musl enables pie by default, + # limit rebuilds by only disabling pie w/musl + ++ lib.optional stdenv.hostPlatform.isMusl "pie"; + + NIX_CFLAGS_COMPILE = lib.concatStringsSep " " + (builtins.concatLists [ + (lib.optionals withGd gdCflags) + # Fix -Werror build failure when building glibc with musl with GCC >= 8, see: + # https://github.com/NixOS/nixpkgs/pull/68244#issuecomment-544307798 + (lib.optional stdenv.hostPlatform.isMusl "-Wno-error=attribute-alias") + (lib.optionals ((stdenv.hostPlatform != stdenv.buildPlatform) || stdenv.hostPlatform.isMusl) [ + # Ignore "error: '__EI___errno_location' specifies less restrictive attributes than its target '__errno_location'" + # New warning as of GCC 9 + # Same for musl: https://github.com/NixOS/nixpkgs/issues/78805 + "-Wno-error=missing-attributes" + ]) + ]); + + # 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 + # bootstrap-tools tarball) + # Building from a proper gcc staying in the path where it was installed, + # libgcc_s will not be at {gcc}/lib, and gcc's libgcc will be found without + # any special hack. + preInstall = '' + if [ -f ${stdenv.cc.cc}/lib/libgcc_s.so.1 ]; then + mkdir -p $out/lib + cp ${stdenv.cc.cc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1 + # the .so It used to be a symlink, but now it is a script + cp -a ${stdenv.cc.cc}/lib/libgcc_s.so $out/lib/libgcc_s.so + fi + ''; + + postInstall = (if stdenv.hostPlatform == stdenv.buildPlatform then '' + echo SUPPORTED-LOCALES=C.UTF-8/UTF-8 > ../glibc-2*/localedata/SUPPORTED + make -j''${NIX_BUILD_CORES:-1} -l''${NIX_BUILD_CORES:-1} localedata/install-locales + '' else lib.optionalString stdenv.buildPlatform.isLinux '' + # This is based on http://www.linuxfromscratch.org/lfs/view/development/chapter06/glibc.html + # Instead of using their patch to build a build-native localedef, + # we simply use the one from buildPackages + pushd ../glibc-2*/localedata + export I18NPATH=$PWD GCONV_PATH=$PWD/../iconvdata + mkdir -p $NIX_BUILD_TOP/${buildPackages.glibc}/lib/locale + ${lib.getBin buildPackages.glibc}/bin/localedef \ + --alias-file=../intl/locale.alias \ + -i locales/C \ + -f charmaps/UTF-8 \ + --prefix $NIX_BUILD_TOP \ + ${if stdenv.hostPlatform.parsed.cpu.significantByte.name == "littleEndian" then + "--little-endian" + else + "--big-endian"} \ + C.UTF-8 + cp -r $NIX_BUILD_TOP/${buildPackages.glibc}/lib/locale $out/lib + popd + '') + '' + + test -f $out/etc/ld.so.cache && rm $out/etc/ld.so.cache + + if test -n "$linuxHeaders"; then + # Include the Linux kernel headers in Glibc, except the `scsi' + # subdirectory, which Glibc provides itself. + (cd $dev/include && \ + ln -sv $(ls -d $linuxHeaders/include/* | grep -v scsi\$) .) + fi + + # Fix for NIXOS-54 (ldd not working on x86_64). Make a symlink + # "lib64" to "lib". + if test -n "$is64bit"; then + ln -s lib $out/lib64 + fi + + # Get rid of more unnecessary stuff. + rm -rf $out/var $bin/bin/sln + '' + # For some reason these aren't stripped otherwise and retain reference + # to bootstrap-tools; on cross-arm this stripping would break objects. + + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' + + for i in "$out"/lib/*.a; do + [ "$i" = "$out/lib/libm.a" ] || $STRIP -S "$i" + done + '' + '' + + # 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 + # Some of *.a files are linker scripts where moving broke the paths. + sed "/^GROUP/s|$out/lib/lib|$static/lib/lib|g" \ + -i "$static"/lib/*.a + + # 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 + ''; + + separateDebugInfo = true; + + meta.description = "The GNU C Library"; + } diff --git a/nixpkgs/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch b/nixpkgs/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch new file mode 100644 index 000000000000..0e0315aca270 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch @@ -0,0 +1,64 @@ +diff --git a/elf/Makefile b/elf/Makefile +index 5d666b1b..a5017e9c 100644 +--- a/elf/Makefile ++++ b/elf/Makefile +@@ -669,14 +669,14 @@ $(objpfx)sln: $(sln-modules:%=$(objpfx)%.o) + + $(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o) + +-SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"' +-CFLAGS-ldconfig.c += $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \ ++PREFIX-FLAGS := -D'PREFIX="$(prefix)"' ++CFLAGS-ldconfig.c += $(PREFIX-FLAGS) -D'LIBDIR="$(libdir)"' \ + -D'SLIBDIR="$(slibdir)"' + libof-ldconfig = ldconfig +-CFLAGS-dl-cache.c += $(SYSCONF-FLAGS) +-CFLAGS-cache.c += $(SYSCONF-FLAGS) +-CFLAGS-rtld.c += $(SYSCONF-FLAGS) +-CFLAGS-dl-usage.c += $(SYSCONF-FLAGS) \ ++CFLAGS-dl-cache.c += $(PREFIX-FLAGS) ++CFLAGS-cache.c += $(PREFIX-FLAGS) ++CFLAGS-rtld.c += $(PREFIX-FLAGS) ++CFLAGS-dl-usage.c += $(PREFIX-FLAGS) \ + -D'RTLD="$(rtlddir)/$(rtld-installed-name)"' + + cpp-srcs-left := $(all-rtld-routines:=.os) +diff --git a/elf/dl-diagnostics.c b/elf/dl-diagnostics.c +index bef224b3..8e166b12 100644 +--- a/elf/dl-diagnostics.c ++++ b/elf/dl-diagnostics.c +@@ -205,7 +205,7 @@ print_paths (void) + { + _dl_diagnostics_print_labeled_string ("path.prefix", PREFIX); + _dl_diagnostics_print_labeled_string ("path.rtld", RTLD); +- _dl_diagnostics_print_labeled_string ("path.sysconfdir", SYSCONFDIR); ++ _dl_diagnostics_print_labeled_string ("path.sysconfdir", PREFIX "/etc"); + + unsigned int index = 0; + static const char *system_dirs = SYSTEM_DIRS "\0"; +diff --git a/elf/ldconfig.c b/elf/ldconfig.c +index 28ed637a..6f07b79a 100644 +--- a/elf/ldconfig.c ++++ b/elf/ldconfig.c +@@ -57,7 +57,7 @@ + #define TLS_HWCAP_BIT 63 + + #ifndef LD_SO_CONF +-# define LD_SO_CONF SYSCONFDIR "/ld.so.conf" ++# define LD_SO_CONF PREFIX "/etc/ld.so.conf" + #endif + + /* Get libc version number. */ +diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h +index 964d50a4..2224d651 100644 +--- a/sysdeps/generic/dl-cache.h ++++ b/sysdeps/generic/dl-cache.h +@@ -35,7 +35,7 @@ + #endif + + #ifndef LD_SO_CACHE +-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache" ++# define LD_SO_CACHE PREFIX "/etc/ld.so.cache" + #endif + + #ifndef add_system_dir diff --git a/nixpkgs/pkgs/development/libraries/glibc/dont-use-system-ld-so-preload.patch b/nixpkgs/pkgs/development/libraries/glibc/dont-use-system-ld-so-preload.patch new file mode 100644 index 000000000000..894e2a11cf87 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/dont-use-system-ld-so-preload.patch @@ -0,0 +1,12 @@ +diff -ru glibc-2.20-orig/elf/rtld.c glibc-2.20/elf/rtld.c +--- glibc-2.20-orig/elf/rtld.c 2014-09-07 10:09:09.000000000 +0200 ++++ glibc-2.20/elf/rtld.c 2014-10-27 11:32:25.203043157 +0100 +@@ -1513,7 +1513,7 @@ + open(). So we do this first. If it succeeds we do almost twice + the work but this does not matter, since it is not for production + use. */ +- static const char preload_file[] = "/etc/ld.so.preload"; ++ static const char preload_file[] = "/etc/ld-nix.so.preload"; + if (__glibc_unlikely (__access (preload_file, R_OK) == 0)) + { + /* Read the contents of the file. */ diff --git a/nixpkgs/pkgs/development/libraries/glibc/fix-rpc-types-musl-conflicts.patch b/nixpkgs/pkgs/development/libraries/glibc/fix-rpc-types-musl-conflicts.patch new file mode 100644 index 000000000000..19f8bfc7cce8 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/fix-rpc-types-musl-conflicts.patch @@ -0,0 +1,38 @@ +@@ -, +, @@ +--- + sunrpc/rpc/types.h | 22 ++++++---------------- + 1 file changed, 6 insertions(+), 16 deletions(-) +--- a/sunrpc/rpc/types.h ++++ a/sunrpc/rpc/types.h +@@ -69,24 +69,14 @@ typedef unsigned long rpcport_t; + #include <sys/types.h> + #endif + +-#if defined __APPLE_CC__ || defined __FreeBSD__ +-# define __u_char_defined +-# define __daddr_t_defined +-#endif +- +-#ifndef __u_char_defined +-typedef __u_char u_char; +-typedef __u_short u_short; +-typedef __u_int u_int; +-typedef __u_long u_long; +-typedef __quad_t quad_t; +-typedef __u_quad_t u_quad_t; +-typedef __fsid_t fsid_t; ++/* IMPORTANT NOTE: This has been modified to build against the musl C ++ * library and it probably now ONLY builds with the musl C library. ++ * ++ * See: https://sourceware.org/bugzilla/show_bug.cgi?id=21604 ++ */ + # define __u_char_defined +-#endif + #ifndef __daddr_t_defined +-typedef __daddr_t daddr_t; +-typedef __caddr_t caddr_t; ++typedef int daddr_t; + # define __daddr_t_defined + #endif + +-- diff --git a/nixpkgs/pkgs/development/libraries/glibc/fix-x64-abi.patch b/nixpkgs/pkgs/development/libraries/glibc/fix-x64-abi.patch new file mode 100644 index 000000000000..1d60dcd7988b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/fix-x64-abi.patch @@ -0,0 +1,35 @@ +From 3288c6da64add3b4561b8c10fff522027caea01c Mon Sep 17 00:00:00 2001 +From: Nicholas Miell <nmiell@gmail.com> +Date: Sat, 17 Jun 2017 18:21:07 -0700 +Subject: [PATCH] Align the stack on entry to __tls_get_addr() + +Old versions of gcc (4 & 5) didn't align the stack according to the +AMD64 psABI when calling __tls_get_addr(). Apparently new versions of +gcc (7) got much more aggressive about vectorizing and generating MOVAPS +instructions, which means old binaries built with the buggy versions of +gcc are much more likely to crash when using versions of glibc built +using gcc 7. + +For example, a large number of Linux games built using the Unity game +engine and available for purchase on Steam. +--- + elf/dl-tls.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/elf/dl-tls.c b/elf/dl-tls.c +index 5aba33b3fa..3f3cb917de 100644 +--- a/elf/dl-tls.c ++++ b/elf/dl-tls.c +@@ -827,6 +827,10 @@ rtld_hidden_proto (__tls_get_addr) + rtld_hidden_def (__tls_get_addr) + #endif + ++#ifdef __x86_64__ ++/* Old versions of gcc didn't align the stack. */ ++__attribute__((force_align_arg_pointer)) ++#endif + /* The generic dynamic and local dynamic model cannot be used in + statically linked applications. */ + void * +-- +2.13.0 diff --git a/nixpkgs/pkgs/development/libraries/glibc/fix_path_attribute_in_getconf.patch b/nixpkgs/pkgs/development/libraries/glibc/fix_path_attribute_in_getconf.patch new file mode 100644 index 000000000000..714e49db5607 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/fix_path_attribute_in_getconf.patch @@ -0,0 +1,6 @@ +diff -ubr glibc-2.17-orig/sysdeps/unix/confstr.h glibc-2.17/sysdeps/unix/confstr.h +--- glibc-2.17-orig/sysdeps/unix/confstr.h 2013-06-03 22:01:44.829726968 +0200 ++++ glibc-2.17/sysdeps/unix/confstr.h 2013-06-03 22:04:39.469376740 +0200 +@@ -1 +1 @@ +-#define CS_PATH "/bin:/usr/bin" ++#define CS_PATH "/run/current-system/sw/bin:/bin:/usr/bin" diff --git a/nixpkgs/pkgs/development/libraries/glibc/info.nix b/nixpkgs/pkgs/development/libraries/glibc/info.nix new file mode 100644 index 000000000000..7c4f3f63bf1c --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/info.nix @@ -0,0 +1,23 @@ +{ callPackage, texinfo, perl }: + +callPackage ./common.nix {} { + pname = "glibc-info"; + + outputs = [ "out" ]; + + configureFlags = [ "--enable-add-ons" ]; + + buildInputs = [ texinfo perl ]; + + 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 = '' + mkdir -p "$out/share/info" + cp -v "manual/"*.info* "$out/share/info" + ''; + + meta.description = "GNU Info manual of the GNU C Library"; +} diff --git a/nixpkgs/pkgs/development/libraries/glibc/locales-builder.sh b/nixpkgs/pkgs/development/libraries/glibc/locales-builder.sh new file mode 100644 index 000000000000..d732e208fa22 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/locales-builder.sh @@ -0,0 +1,17 @@ +# Glibc cannot have itself in its RPATH. +export NIX_NO_SELF_RPATH=1 + +source $stdenv/setup + +postConfigure() { + # Hack: get rid of the `-static' flag set by the bootstrap stdenv. + # This has to be done *after* `configure' because it builds some + # test binaries. + export NIX_CFLAGS_LINK= + export NIX_LDFLAGS_BEFORE= + + export NIX_DONT_SET_RPATH=1 + unset CFLAGS +} + +genericBuild diff --git a/nixpkgs/pkgs/development/libraries/glibc/locales.nix b/nixpkgs/pkgs/development/libraries/glibc/locales.nix new file mode 100644 index 000000000000..bada8b3f31f7 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/locales.nix @@ -0,0 +1,70 @@ +/* This function builds just the `lib/locale/locale-archive' file from + Glibc and nothing else. If `allLocales' is true, all supported + locales are included; otherwise, just the locales listed in + `locales'. See localedata/SUPPORTED in the Glibc source tree for + the list of all supported locales: + https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/SUPPORTED +*/ + +{ lib, stdenv, buildPackages, callPackage, writeText, glibc +, allLocales ? true, locales ? [ "en_US.UTF-8/UTF-8" ] +}: + +callPackage ./common.nix { inherit stdenv; } { + pname = "glibc-locales"; + + builder = ./locales-builder.sh; + + outputs = [ "out" ]; + + extraNativeBuildInputs = [ glibc ]; + + # 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 + # <prefix>/<path-to-glibc>/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/"${buildPackages.glibc.out}/lib/locale" + + echo 'C.UTF-8/UTF-8 \' >> ../glibc-2*/localedata/SUPPORTED + + # Hack to allow building of the locales (needed since glibc-2.12) + sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --prefix='$TMPDIR',' ../glibc-2*/localedata/Makefile + '' + + lib.optionalString (!allLocales) '' + # Check that all locales to be built are supported + echo -n '${lib.concatMapStrings (s: s + " \\\n") locales}' \ + | sort -u > locales-to-build.txt + cat ../glibc-2*/localedata/SUPPORTED | grep ' \\' \ + | sort -u > locales-supported.txt + comm -13 locales-supported.txt locales-to-build.txt \ + > locales-unsupported.txt + if [[ $(wc -c locales-unsupported.txt) != "0 locales-unsupported.txt" ]]; then + cat locales-supported.txt + echo "Error: unsupported locales detected:" + cat locales-unsupported.txt + echo "You should choose from the list above the error." + false + fi + + echo SUPPORTED-LOCALES='${toString locales}' > ../glibc-2*/localedata/SUPPORTED + '' + '' + make localedata/install-locales \ + localedir=$out/lib/locale \ + ''; + + installPhase = + '' + mkdir -p "$out/lib/locale" + cp -v "$TMPDIR/$NIX_STORE/"*"/lib/locale/locale-archive" "$out/lib/locale" + ''; + + setupHook = writeText "locales-setup-hook.sh" + '' + export LOCALE_ARCHIVE=@out@/lib/locale/locale-archive + ''; + + meta.description = "Locale information for the GNU C Library"; +} diff --git a/nixpkgs/pkgs/development/libraries/glibc/mtrace.nix b/nixpkgs/pkgs/development/libraries/glibc/mtrace.nix new file mode 100644 index 000000000000..fed24aff2796 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/mtrace.nix @@ -0,0 +1,38 @@ +{ glibc, perl }: + +# Small wrapper which only exposes `mtrace(3)` from `glibc`. This can't be placed +# into `glibc` itself because it depends on Perl which would mean that the final +# `glibc` inside a stdenv bootstrap has a dependency `glibc -> perl -> bootstrap tools`, +# so this is now in its own package that isn't used for bootstrapping. +# +# `glibc` needs to be overridden here because it's still needed to `./configure` the source in order +# to have a build environment where we can call the needed make target. + +glibc.overrideAttrs ({ meta ? {}, ... }: { + pname = "glibc-mtrace"; + + buildPhase = '' + runHook preBuild + + mkdir malloc + make -C ../glibc-${glibc.minorRelease}/malloc objdir=`pwd` `pwd`/malloc/mtrace; + + runHook postBuild + ''; + + installPhase = '' + mkdir -p $out/bin + mv malloc/mtrace $out/bin/ + ''; + + # Perl interpreter used for `mtrace`. + buildInputs = [ perl ]; + + # Reset a few things declared by `pkgs.glibc`. + outputs = [ "out" ]; + separateDebugInfo = false; + + meta = meta // { + description = "Perl script used to interpret and provide human readable output of the trace log contained in the file mtracedata, whose contents were produced by mtrace(3)."; + }; +}) diff --git a/nixpkgs/pkgs/development/libraries/glibc/multi.nix b/nixpkgs/pkgs/development/libraries/glibc/multi.nix new file mode 100644 index 000000000000..5d3626b95cc0 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/multi.nix @@ -0,0 +1,28 @@ +{ runCommand, glibc, glibc32 +}: + +let + nameVersion = builtins.parseDrvName glibc.name; + glibc64 = glibc; +in +runCommand "${nameVersion.name}-multi-${nameVersion.version}" + { outputs = [ "bin" "dev" "out"]; } # TODO: no static version here (yet) + '' + mkdir -p "$out/lib" + ln -s '${glibc64.out}'/lib/* "$out/lib" + ln -s '${glibc32.out}/lib' "$out/lib/32" + ln -s lib "$out/lib64" + + # fixing ldd RLTDLIST + mkdir -p "$bin/bin" + cp -s '${glibc64.bin}'/bin/* "$bin/bin/" + rm "$bin/bin/ldd" + sed -e "s|^RTLDLIST=.*$|RTLDLIST=\"$out/lib/ld-linux-x86-64.so.2 $out/lib/32/ld-linux.so.2\"|g" \ + '${glibc64.bin}/bin/ldd' > "$bin/bin/ldd" + chmod +x "$bin/bin/ldd" + + mkdir "$dev" + cp -rs '${glibc32.dev}'/include "$dev/" + chmod +w -R "$dev" + cp -rsf '${glibc64.dev}'/include "$dev/" + '' diff --git a/nixpkgs/pkgs/development/libraries/glibc/nix-locale-archive.patch b/nixpkgs/pkgs/development/libraries/glibc/nix-locale-archive.patch new file mode 100644 index 000000000000..39312951fcf9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/nix-locale-archive.patch @@ -0,0 +1,118 @@ +diff -Naur glibc-2.27-orig/locale/loadarchive.c glibc-2.27/locale/loadarchive.c +--- glibc-2.27-orig/locale/loadarchive.c 2018-02-01 11:17:18.000000000 -0500 ++++ glibc-2.27/locale/loadarchive.c 2018-02-17 22:32:25.680169462 -0500 +@@ -123,6 +123,23 @@ + return MAX (namehash_end, MAX (string_end, locrectab_end)); + } + ++static int ++open_locale_archive (void) ++{ ++ int fd = -1; ++ char *versioned_path = getenv ("LOCALE_ARCHIVE_2_27"); ++ char *path = getenv ("LOCALE_ARCHIVE"); ++ if (versioned_path) ++ fd = __open_nocancel (versioned_path, O_RDONLY|O_LARGEFILE|O_CLOEXEC); ++ if (path && fd < 0) ++ fd = __open_nocancel (path, O_RDONLY|O_LARGEFILE|O_CLOEXEC); ++ if (fd < 0) ++ fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC); ++ if (fd < 0) ++ fd = __open_nocancel ("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC); ++ return fd; ++} ++ + + /* Find the locale *NAMEP in the locale archive, and return the + internalized data structure for its CATEGORY data. If this locale has +@@ -202,7 +219,7 @@ + archmapped = &headmap; + + /* The archive has never been opened. */ +- fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC); ++ fd = open_locale_archive (); + if (fd < 0) + /* Cannot open the archive, for whatever reason. */ + return NULL; +@@ -397,8 +414,7 @@ + if (fd == -1) + { + struct stat64 st; +- fd = __open_nocancel (archfname, +- O_RDONLY|O_LARGEFILE|O_CLOEXEC); ++ fd = open_locale_archive (); + if (fd == -1) + /* Cannot open the archive, for whatever reason. */ + return NULL; +diff -Naur glibc-2.27-orig/locale/programs/locale.c glibc-2.27/locale/programs/locale.c +--- glibc-2.27-orig/locale/programs/locale.c 2018-02-01 11:17:18.000000000 -0500 ++++ glibc-2.27/locale/programs/locale.c 2018-02-17 22:36:39.726293213 -0500 +@@ -633,6 +633,24 @@ + + + static int ++open_locale_archive (void) ++{ ++ int fd = -1; ++ char *versioned_path = getenv ("LOCALE_ARCHIVE_2_27"); ++ char *path = getenv ("LOCALE_ARCHIVE"); ++ if (versioned_path) ++ fd = open64 (versioned_path, O_RDONLY); ++ if (path && fd < 0) ++ fd = open64 (path, O_RDONLY); ++ if (fd < 0) ++ fd = open64 (ARCHIVE_NAME, O_RDONLY); ++ if (fd < 0) ++ fd = open64 ("/usr/lib/locale/locale-archive", O_RDONLY); ++ return fd; ++} ++ ++ ++static int + write_archive_locales (void **all_datap, char *linebuf) + { + struct stat64 st; +@@ -644,7 +662,7 @@ + int fd, ret = 0; + uint32_t cnt; + +- fd = open64 (ARCHIVE_NAME, O_RDONLY); ++ fd = open_locale_archive (); + if (fd < 0) + return 0; + +diff -Naur glibc-2.27-orig/locale/programs/locarchive.c glibc-2.27/locale/programs/locarchive.c +--- glibc-2.27-orig/locale/programs/locarchive.c 2018-02-01 11:17:18.000000000 -0500 ++++ glibc-2.27/locale/programs/locarchive.c 2018-02-17 22:40:51.245293975 -0500 +@@ -117,6 +117,22 @@ + } + + ++static int ++open_locale_archive (const char * archivefname, int flags) ++{ ++ int fd = -1; ++ char *versioned_path = getenv ("LOCALE_ARCHIVE_2_27"); ++ char *path = getenv ("LOCALE_ARCHIVE"); ++ if (versioned_path) ++ fd = open64 (versioned_path, flags); ++ if (path && fd < 0) ++ fd = open64 (path, flags); ++ if (fd < 0) ++ fd = open64 (archivefname, flags); ++ return fd; ++} ++ ++ + static void + create_archive (const char *archivefname, struct locarhandle *ah) + { +@@ -578,7 +594,7 @@ + while (1) + { + /* Open the archive. We must have exclusive write access. */ +- fd = open64 (archivefname, readonly ? O_RDONLY : O_RDWR); ++ fd = open_locale_archive (archivefname, readonly ? O_RDONLY : O_RDWR); + if (fd == -1) + { + /* Maybe the file does not yet exist? If we are opening diff --git a/nixpkgs/pkgs/development/libraries/glibc/nix-nss-open-files.patch b/nixpkgs/pkgs/development/libraries/glibc/nix-nss-open-files.patch new file mode 100644 index 000000000000..9a515c4662e2 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/nix-nss-open-files.patch @@ -0,0 +1,51 @@ +diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c +index 1db9e46127..3a567e0224 100644 +--- a/nss/nss_files/files-XXX.c ++++ b/nss/nss_files/files-XXX.c +@@ -75,8 +75,20 @@ internal_setent (FILE **stream) + + if (*stream == NULL) + { +- *stream = __nss_files_fopen (DATAFILE); +- ++ const char *file = DATAFILE; ++ ++ #ifdef NIX_DATAFILE ++ // use the Nix environment variable such as `NIX_ETC_PROTOCOLS` ++ char *path = secure_getenv (NIX_DATAFILE); ++ ++ // if the environment variable is set, then read from the /nix/store entry instead ++ if (path && path[0]) { ++ file = path; ++ } ++ #endif ++ ++ *stream = __nss_files_fopen (file); ++ + if (*stream == NULL) + status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL; + } +diff --git a/nss/nss_files/files-proto.c b/nss/nss_files/files-proto.c +index c30bedc0aa..b321e68d3c 100644 +--- a/nss/nss_files/files-proto.c ++++ b/nss/nss_files/files-proto.c +@@ -23,6 +23,7 @@ NSS_DECLARE_MODULE_FUNCTIONS (files) + + #define ENTNAME protoent + #define DATABASE "protocols" ++#define NIX_DATAFILE "NIX_ETC_PROTOCOLS" + + struct protoent_data {}; + +diff --git a/nss/nss_files/files-service.c b/nss/nss_files/files-service.c +index bfc2590699..0bff36aee5 100644 +--- a/nss/nss_files/files-service.c ++++ b/nss/nss_files/files-service.c +@@ -24,6 +24,7 @@ NSS_DECLARE_MODULE_FUNCTIONS (files) + + #define ENTNAME servent + #define DATABASE "services" ++#define NIX_DATAFILE "NIX_ETC_SERVICES" + + struct servent_data {}; + diff --git a/nixpkgs/pkgs/development/libraries/glibc/rpcgen-path.patch b/nixpkgs/pkgs/development/libraries/glibc/rpcgen-path.patch new file mode 100644 index 000000000000..3349449d9163 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/rpcgen-path.patch @@ -0,0 +1,54 @@ +diff -ru glibc-2.18-orig/sunrpc/rpc_main.c glibc-2.18/sunrpc/rpc_main.c +--- glibc-2.18-orig/sunrpc/rpc_main.c 2013-08-11 00:52:55.000000000 +0200 ++++ glibc-2.18/sunrpc/rpc_main.c 2013-11-15 12:04:48.041006977 +0100 +@@ -78,7 +78,7 @@ + + static const char *svcclosetime = "120"; + static int cppDefined; /* explicit path for C preprocessor */ +-static const char *CPP = "/lib/cpp"; ++static const char *CPP = "cpp"; + static const char CPPFLAGS[] = "-C"; + static char *pathbuf; + static int cpp_pid; +@@ -107,7 +107,6 @@ + static void open_output (const char *infile, const char *outfile); + static void add_warning (void); + static void clear_args (void); +-static void find_cpp (void); + static void open_input (const char *infile, const char *define); + static int check_nettype (const char *name, const char *list_to_check[]); + static void c_output (const char *infile, const char *define, +@@ -322,25 +321,6 @@ + argcount = FIXEDARGS; + } + +-/* make sure that a CPP exists */ +-static void +-find_cpp (void) +-{ +- struct stat64 buf; +- +- if (stat64 (CPP, &buf) == 0) +- return; +- +- if (cppDefined) /* user specified cpp but it does not exist */ +- { +- fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP); +- crash (); +- } +- +- /* fall back to system CPP */ +- CPP = "cpp"; +-} +- + /* + * Open input file with given define for C-preprocessor + */ +@@ -359,7 +339,6 @@ + switch (cpp_pid) + { + case 0: +- find_cpp (); + putarg (0, CPP); + putarg (1, CPPFLAGS); + addarg (define); |