diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/glibc')
15 files changed, 946 insertions, 0 deletions
diff --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..8e8e445f0173 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/common.nix @@ -0,0 +1,229 @@ +/* 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. +*/ + +{ stdenv, lib +, buildPackages +, fetchurl, fetchpatch +, linuxHeaders ? null +, gd ? null, libpng ? null +, bison +}: + +{ name +, withLinuxHeaders ? false +, profilingLibraries ? false +, withGd ? false +, meta +, ... +} @ args: + +let + version = "2.27"; + patchSuffix = ""; + sha256 = "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"; +in + +assert withLinuxHeaders -> linuxHeaders != null; +assert withGd -> gd != null && libpng != null; + +stdenv.mkDerivation ({ + inherit version; + linuxHeaders = if withLinuxHeaders then linuxHeaders else null; + + inherit (stdenv) is64bit; + + enableParallelBuilding = true; + + patches = + [ + /* Have rpcgen(1) look for cpp(1) in $PATH. */ + ./rpcgen-path.patch + + /* 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 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"; + }) + ] + ++ lib.optional stdenv.isx86_64 ./fix-x64-abi.patch + ++ lib.optional stdenv.hostPlatform.isMusl ./fix-rpc-types-musl-conflicts.patch + ++ lib.optional stdenv.buildPlatform.isDarwin ./darwin-cross-build.patch + + # Remove after upgrading to glibc 2.28+ + ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) (fetchpatch { + url = "https://sourceware.org/git/?p=glibc.git;a=patch;h=780684eb04298977bc411ebca1eadeeba4877833"; + name = "correct-pwent-parsing-issue-and-resulting-build.patch"; + sha256 = "08fja894vzaj8phwfhsfik6jj2pbji7kypy3q8pgxvsd508zdv1q"; + excludes = [ "ChangeLog" ]; + }); + + 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 + ''; + + configureFlags = + [ "-C" + "--enable-add-ons" + "--enable-obsolete-nsl" + "--enable-obsolete-rpc" + "--sysconfdir=/etc" + "--enable-stackguard-randomization" + (lib.withFeatureAs withLinuxHeaders "headers" "${linuxHeaders}/include") + (lib.enableFeature profilingLibraries "profile") + ] ++ 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.platform.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"; + + installFlags = [ "sysconfdir=$(out)/etc" ]; + + outputs = [ "out" "bin" "dev" "static" ]; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ bison ]; + buildInputs = [ linuxHeaders ] ++ lib.optionals withGd [ gd libpng ]; + + # 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"; + + passthru = { inherit version; }; +} + +// (removeAttrs args [ "withLinuxHeaders" "withGd" ]) // + +{ + name = name + "-${version}${patchSuffix}"; + + 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"'' + } + + + '' + 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 + ''; + + preBuild = lib.optionalString withGd "unset NIX_DONT_SET_RPATH"; + + doCheck = false; # fails + + meta = { + 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 = lib.licenses.lgpl2Plus; + + maintainers = [ lib.maintainers.eelco ]; + platforms = lib.platforms.linux; + } // meta; +} + +// lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) { + preInstall = null; # clobber the native hook + + # To avoid a dependency on the build system 'bash'. + preFixup = '' + rm -f $bin/bin/{ldd,tzselect,catchsegv,xtrace} + ''; +}) 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..7b224924104b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/darwin-cross-build.patch @@ -0,0 +1,103 @@ +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 +* libintl.h does not exist (and is not needed) on macOS + +--- glibc-2.27/Makefile.in 2018-02-01 17:17:18.000000000 +0100 ++++ glibc-2.27/Makefile.in 2019-02-15 17:38:27.022965553 +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.27/Makerules 2018-02-01 17:17:18.000000000 +0100 ++++ glibc-2.27/Makerules 2019-02-15 17:43:11.196039000 +0100 +@@ -915,8 +915,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 +@@ -927,7 +927,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) +@@ -943,14 +943,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 +@@ -961,7 +961,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. +@@ -1615,7 +1615,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. +--- glibc-2.27/sunrpc/rpc_main.c 2019-02-15 17:32:43.710244513 +0100 ++++ glibc-2.27/sunrpc/rpc_main.c 2019-02-15 17:23:57.139617796 +0100 +@@ -38,7 +38,9 @@ + #include <stdio.h> + #include <string.h> + #include <unistd.h> ++#ifndef __APPLE__ + #include <libintl.h> ++#endif + #include <locale.h> + #include <ctype.h> + #include <sys/types.h> +--- glibc-2.27/sunrpc/rpc_scan.c 2019-02-15 17:32:54.845490606 +0100 ++++ glibc-2.27/sunrpc/rpc_scan.c 2019-02-15 17:24:54.288066644 +0100 +@@ -37,7 +37,9 @@ + #include <stdio.h> + #include <ctype.h> + #include <string.h> ++#ifndef __APPLE__ + #include <libintl.h> ++#endif + #include "rpc_scan.h" + #include "rpc_parse.h" + #include "rpc_util.h" diff --git a/nixpkgs/pkgs/development/libraries/glibc/default.nix b/nixpkgs/pkgs/development/libraries/glibc/default.nix new file mode 100644 index 000000000000..eda71af59783 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/default.nix @@ -0,0 +1,130 @@ +{ stdenv, callPackage +, withLinuxHeaders ? true +, profilingLibraries ? false +, withGd ? false +, buildPackages +}: + +callPackage ./common.nix { inherit stdenv; } { + name = "glibc" + stdenv.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 + ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "pie"; + + NIX_CFLAGS_COMPILE = if withGd then "-Wno-error=stringop-truncation" else null; + + # 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 stdenv.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 + ${stdenv.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. + + stdenv.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..f84b1049adf8 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch @@ -0,0 +1,46 @@ +diff -Naur glibc-2.27-orig/elf/ldconfig.c glibc-2.27/elf/ldconfig.c +--- glibc-2.27-orig/elf/ldconfig.c 2018-02-01 11:17:18.000000000 -0500 ++++ glibc-2.27/elf/ldconfig.c 2018-02-17 22:43:17.232175182 -0500 +@@ -51,7 +51,7 @@ + #endif + + #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 -Naur glibc-2.27-orig/elf/Makefile glibc-2.27/elf/Makefile +--- glibc-2.27-orig/elf/Makefile 2018-02-01 11:17:18.000000000 -0500 ++++ glibc-2.27/elf/Makefile 2018-02-17 22:44:50.334006750 -0500 +@@ -559,13 +559,13 @@ + + $(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-cache.c += $(PREFIX-FLAGS) ++CFLAGS-cache.c += $(PREFIX-FLAGS) ++CFLAGS-rtld.c += $(PREFIX-FLAGS) + + cpp-srcs-left := $(all-rtld-routines:=.os) + lib := rtld +diff -Naur glibc-2.27-orig/sysdeps/generic/dl-cache.h glibc-2.27/sysdeps/generic/dl-cache.h +--- glibc-2.27-orig/sysdeps/generic/dl-cache.h 2018-02-01 11:17:18.000000000 -0500 ++++ glibc-2.27/sysdeps/generic/dl-cache.h 2018-02-17 22:45:20.471598816 -0500 +@@ -28,7 +28,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..5cb004cc870d --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/info.nix @@ -0,0 +1,23 @@ +{ callPackage, texinfo, perl }: + +callPackage ./common.nix {} { + name = "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..0dc191974155 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glibc/locales.nix @@ -0,0 +1,68 @@ +/* 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 +*/ + +{ stdenv, buildPackages, callPackage, writeText +, allLocales ? true, locales ? [ "en_US.UTF-8/UTF-8" ] +}: + +callPackage ./common.nix { inherit stdenv; } { + name = "glibc-locales"; + + builder = ./locales-builder.sh; + + outputs = [ "out" ]; + + # 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.stdenv.cc.libc.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 + '' + + stdenv.lib.optionalString (!allLocales) '' + # Check that all locales to be built are supported + echo -n '${stdenv.lib.concatMapStrings (s: s + " \\\n") locales}' \ + | sort > locales-to-build.txt + cat ../glibc-2*/localedata/SUPPORTED | grep ' \\' \ + | sort > 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/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/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); |