glibc: Add 2.27

+476
+101
pkgs/development/libraries/glibc/2.27.nix
···
··· 1 + { stdenv, callPackage 2 + , withLinuxHeaders ? true 3 + , installLocales ? true 4 + , profilingLibraries ? false 5 + , withGd ? false 6 + }: 7 + 8 + assert stdenv.cc.isGNU; 9 + 10 + callPackage ./common-2.27.nix { inherit stdenv; } { 11 + name = "glibc" + stdenv.lib.optionalString withGd "-gd"; 12 + 13 + inherit withLinuxHeaders profilingLibraries installLocales withGd; 14 + 15 + NIX_NO_SELF_RPATH = true; 16 + 17 + postConfigure = '' 18 + # Hack: get rid of the `-static' flag set by the bootstrap stdenv. 19 + # This has to be done *after* `configure' because it builds some 20 + # test binaries. 21 + export NIX_CFLAGS_LINK= 22 + export NIX_LDFLAGS_BEFORE= 23 + 24 + export NIX_DONT_SET_RPATH=1 25 + unset CFLAGS 26 + 27 + # Apparently --bindir is not respected. 28 + makeFlagsArray+=("bindir=$bin/bin" "sbindir=$bin/sbin" "rootsbindir=$bin/sbin") 29 + ''; 30 + 31 + # The stackprotector and fortify hardening flags are autodetected by glibc 32 + # and enabled by default if supported. Setting it for every gcc invocation 33 + # does not work. 34 + hardeningDisable = [ "stackprotector" "fortify" ]; 35 + 36 + # When building glibc from bootstrap-tools, we need libgcc_s at RPATH for 37 + # any program we run, because the gcc will have been placed at a new 38 + # store path than that determined when built (as a source for the 39 + # bootstrap-tools tarball) 40 + # Building from a proper gcc staying in the path where it was installed, 41 + # libgcc_s will not be at {gcc}/lib, and gcc's libgcc will be found without 42 + # any special hack. 43 + preInstall = '' 44 + if [ -f ${stdenv.cc.cc}/lib/libgcc_s.so.1 ]; then 45 + mkdir -p $out/lib 46 + cp ${stdenv.cc.cc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1 47 + # the .so It used to be a symlink, but now it is a script 48 + cp -a ${stdenv.cc.cc}/lib/libgcc_s.so $out/lib/libgcc_s.so 49 + fi 50 + ''; 51 + 52 + postInstall = '' 53 + if test -n "$installLocales"; then 54 + make -j''${NIX_BUILD_CORES:-1} -l''${NIX_BUILD_CORES:-1} localedata/install-locales 55 + fi 56 + 57 + test -f $out/etc/ld.so.cache && rm $out/etc/ld.so.cache 58 + 59 + if test -n "$linuxHeaders"; then 60 + # Include the Linux kernel headers in Glibc, except the `scsi' 61 + # subdirectory, which Glibc provides itself. 62 + (cd $dev/include && \ 63 + ln -sv $(ls -d $linuxHeaders/include/* | grep -v scsi\$) .) 64 + fi 65 + 66 + # Fix for NIXOS-54 (ldd not working on x86_64). Make a symlink 67 + # "lib64" to "lib". 68 + if test -n "$is64bit"; then 69 + ln -s lib $out/lib64 70 + fi 71 + 72 + # Get rid of more unnecessary stuff. 73 + rm -rf $out/var $bin/bin/sln 74 + 75 + # For some reason these aren't stripped otherwise and retain reference 76 + # to bootstrap-tools; on cross-arm this stripping would break objects. 77 + if [ -z "$crossConfig" ]; then 78 + for i in "$out"/lib/*.a; do 79 + [ "$i" = "$out/lib/libm.a" ] || strip -S "$i" 80 + done 81 + fi 82 + 83 + # Put libraries for static linking in a separate output. Note 84 + # that libc_nonshared.a and libpthread_nonshared.a are required 85 + # for dynamically-linked applications. 86 + mkdir -p $static/lib 87 + mv $out/lib/*.a $static/lib 88 + mv $static/lib/lib*_nonshared.a $out/lib 89 + # Some of *.a files are linker scripts where moving broke the paths. 90 + sed "/^GROUP/s|$out/lib/lib|$static/lib/lib|g" \ 91 + -i "$static"/lib/*.a 92 + 93 + # Work around a Nix bug: hard links across outputs cause a build failure. 94 + cp $bin/bin/getconf $bin/bin/getconf_ 95 + mv $bin/bin/getconf_ $bin/bin/getconf 96 + ''; 97 + 98 + separateDebugInfo = true; 99 + 100 + meta.description = "The GNU C Library"; 101 + }
+208
pkgs/development/libraries/glibc/common-2.27.nix
···
··· 1 + /* Build configuration used to build glibc, Info files, and locale 2 + information. */ 3 + 4 + { stdenv, lib 5 + , buildPlatform, hostPlatform 6 + , buildPackages 7 + , fetchurl 8 + , linuxHeaders ? null 9 + , gd ? null, libpng ? null 10 + , bison 11 + }: 12 + 13 + { name 14 + , withLinuxHeaders ? false 15 + , profilingLibraries ? false 16 + , installLocales ? false 17 + , withGd ? false 18 + , meta 19 + , ... 20 + } @ args: 21 + 22 + let 23 + version = "2.27"; 24 + patchSuffix = ""; 25 + sha256 = "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"; 26 + cross = if buildPlatform != hostPlatform then hostPlatform else null; 27 + in 28 + 29 + assert withLinuxHeaders -> linuxHeaders != null; 30 + assert withGd -> gd != null && libpng != null; 31 + 32 + stdenv.mkDerivation ({ 33 + inherit installLocales; 34 + linuxHeaders = if withLinuxHeaders then linuxHeaders else null; 35 + 36 + # The host/target system. 37 + crossConfig = if cross != null then cross.config else null; 38 + 39 + inherit (stdenv) is64bit; 40 + 41 + enableParallelBuilding = true; 42 + 43 + patches = 44 + [ 45 + /* Have rpcgen(1) look for cpp(1) in $PATH. */ 46 + ./rpcgen-path.patch 47 + 48 + /* Allow NixOS and Nix to handle the locale-archive. */ 49 + ./nix-locale-archive-2.27.patch 50 + 51 + /* Don't use /etc/ld.so.cache, for non-NixOS systems. */ 52 + ./dont-use-system-ld-so-cache-2.27.patch 53 + 54 + /* Don't use /etc/ld.so.preload, but /etc/ld-nix.so.preload. */ 55 + ./dont-use-system-ld-so-preload.patch 56 + 57 + /* The command "getconf CS_PATH" returns the default search path 58 + "/bin:/usr/bin", which is inappropriate on NixOS machines. This 59 + patch extends the search path by "/run/current-system/sw/bin". */ 60 + ./fix_path_attribute_in_getconf.patch 61 + 62 + /* Allow running with RHEL 6 -like kernels. The patch adds an exception 63 + for glibc to accept 2.6.32 and to tag the ELFs as 2.6.32-compatible 64 + (otherwise the loader would refuse libc). 65 + Note that glibc will fully work only on their heavily patched kernels 66 + and we lose early mismatch detection on 2.6.32. 67 + 68 + On major glibc updates we should check that the patched kernel supports 69 + all the required features. ATM it's verified up to glibc-2.26-131. 70 + # HOWTO: check glibc sources for changes in kernel requirements 71 + git log -p glibc-2.25.. sysdeps/unix/sysv/linux/x86_64/kernel-features.h sysdeps/unix/sysv/linux/kernel-features.h 72 + # get kernel sources (update the URL) 73 + mkdir tmp && cd tmp 74 + curl http://vault.centos.org/6.9/os/Source/SPackages/kernel-2.6.32-696.el6.src.rpm | rpm2cpio - | cpio -idmv 75 + tar xf linux-*.bz2 76 + # check syscall presence, for example 77 + less linux-*?/arch/x86/kernel/syscall_table_32.S 78 + */ 79 + ./allow-kernel-2.6.32.patch 80 + ] 81 + ++ lib.optional stdenv.isx86_64 ./fix-x64-abi.patch; 82 + 83 + postPatch = 84 + '' 85 + # Needed for glibc to build with the gnumake 3.82 86 + # http://comments.gmane.org/gmane.linux.lfs.support/31227 87 + sed -i 's/ot \$/ot:\n\ttouch $@\n$/' manual/Makefile 88 + 89 + # nscd needs libgcc, and we don't want it dynamically linked 90 + # because we don't want it to depend on bootstrap-tools libs. 91 + echo "LDFLAGS-nscd += -static-libgcc" >> nscd/Makefile 92 + ''; 93 + 94 + configureFlags = 95 + [ "-C" 96 + "--enable-add-ons" 97 + "--enable-obsolete-nsl" 98 + "--enable-obsolete-rpc" 99 + "--sysconfdir=/etc" 100 + "--enable-stackguard-randomization" 101 + (if withLinuxHeaders 102 + then "--with-headers=${linuxHeaders}/include" 103 + else "--without-headers") 104 + (if profilingLibraries 105 + then "--enable-profile" 106 + else "--disable-profile") 107 + ] ++ lib.optionals withLinuxHeaders [ 108 + "--enable-kernel=3.2.0" # can't get below with glibc >= 2.26 109 + ] ++ lib.optionals (cross != null) [ 110 + (if cross ? float && cross.float == "soft" then "--without-fp" else "--with-fp") 111 + ] ++ lib.optionals (cross != null) [ 112 + "--with-__thread" 113 + ] ++ lib.optionals (cross == null && stdenv.isArm) [ 114 + "--host=arm-linux-gnueabi" 115 + "--build=arm-linux-gnueabi" 116 + 117 + # To avoid linking with -lgcc_s (dynamic link) 118 + # so the glibc does not depend on its compiler store path 119 + "libc_cv_as_needed=no" 120 + ] ++ lib.optional withGd "--with-gd"; 121 + 122 + installFlags = [ "sysconfdir=$(out)/etc" ]; 123 + 124 + outputs = [ "out" "bin" "dev" "static" ]; 125 + 126 + depsBuildBuild = [ buildPackages.stdenv.cc ]; 127 + nativeBuildInputs = [ bison ]; 128 + buildInputs = lib.optionals withGd [ gd libpng ]; 129 + 130 + # Needed to install share/zoneinfo/zone.tab. Set to impure /bin/sh to 131 + # prevent a retained dependency on the bootstrap tools in the stdenv-linux 132 + # bootstrap. 133 + BASH_SHELL = "/bin/sh"; 134 + } 135 + 136 + // (removeAttrs args [ "withLinuxHeaders" "withGd" ]) // 137 + 138 + { 139 + name = name + "-${version}${patchSuffix}"; 140 + 141 + src = fetchurl { 142 + url = "mirror://gnu/glibc/glibc-${version}.tar.xz"; 143 + inherit sha256; 144 + }; 145 + 146 + # Remove absolute paths from `configure' & co.; build out-of-tree. 147 + preConfigure = '' 148 + export PWD_P=$(type -tP pwd) 149 + for i in configure io/ftwtest-sh; do 150 + # Can't use substituteInPlace here because replace hasn't been 151 + # built yet in the bootstrap. 152 + sed -i "$i" -e "s^/bin/pwd^$PWD_P^g" 153 + done 154 + 155 + mkdir ../build 156 + cd ../build 157 + 158 + configureScript="`pwd`/../$sourceRoot/configure" 159 + 160 + ${lib.optionalString (stdenv.cc.libc != null) 161 + ''makeFlags="$makeFlags BUILD_LDFLAGS=-Wl,-rpath,${stdenv.cc.libc}/lib"'' 162 + } 163 + 164 + 165 + '' + lib.optionalString (cross != null) '' 166 + sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig" 167 + 168 + cat > config.cache << "EOF" 169 + libc_cv_forced_unwind=yes 170 + libc_cv_c_cleanup=yes 171 + libc_cv_gnu89_inline=yes 172 + EOF 173 + ''; 174 + 175 + preBuild = lib.optionalString withGd "unset NIX_DONT_SET_RPATH"; 176 + 177 + meta = { 178 + homepage = http://www.gnu.org/software/libc/; 179 + description = "The GNU C Library"; 180 + 181 + longDescription = 182 + '' Any Unix-like operating system needs a C library: the library which 183 + defines the "system calls" and other basic facilities such as 184 + open, malloc, printf, exit... 185 + 186 + The GNU C library is used as the C library in the GNU system and 187 + most systems with the Linux kernel. 188 + ''; 189 + 190 + license = lib.licenses.lgpl2Plus; 191 + 192 + maintainers = [ lib.maintainers.eelco ]; 193 + platforms = lib.platforms.linux; 194 + } // meta; 195 + } 196 + 197 + // lib.optionalAttrs (cross != null) { 198 + preInstall = null; # clobber the native hook 199 + 200 + dontStrip = true; 201 + 202 + separateDebugInfo = false; # this is currently broken for crossDrv 203 + 204 + # To avoid a dependency on the build system 'bash'. 205 + preFixup = '' 206 + rm -f $bin/bin/{ldd,tzselect,catchsegv,xtrace} 207 + ''; 208 + })
+46
pkgs/development/libraries/glibc/dont-use-system-ld-so-cache-2.27.patch
···
··· 1 + diff -Naur glibc-2.27-orig/elf/ldconfig.c glibc-2.27/elf/ldconfig.c 2 + --- glibc-2.27-orig/elf/ldconfig.c 2018-02-01 11:17:18.000000000 -0500 3 + +++ glibc-2.27/elf/ldconfig.c 2018-02-17 22:43:17.232175182 -0500 4 + @@ -51,7 +51,7 @@ 5 + #endif 6 + 7 + #ifndef LD_SO_CONF 8 + -# define LD_SO_CONF SYSCONFDIR "/ld.so.conf" 9 + +# define LD_SO_CONF PREFIX "/etc/ld.so.conf" 10 + #endif 11 + 12 + /* Get libc version number. */ 13 + diff -Naur glibc-2.27-orig/elf/Makefile glibc-2.27/elf/Makefile 14 + --- glibc-2.27-orig/elf/Makefile 2018-02-01 11:17:18.000000000 -0500 15 + +++ glibc-2.27/elf/Makefile 2018-02-17 22:44:50.334006750 -0500 16 + @@ -559,13 +559,13 @@ 17 + 18 + $(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o) 19 + 20 + -SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"' 21 + -CFLAGS-ldconfig.c += $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \ 22 + +PREFIX-FLAGS := -D'PREFIX="$(prefix)"' 23 + +CFLAGS-ldconfig.c += $(PREFIX-FLAGS) -D'LIBDIR="$(libdir)"' \ 24 + -D'SLIBDIR="$(slibdir)"' 25 + libof-ldconfig = ldconfig 26 + -CFLAGS-dl-cache.c += $(SYSCONF-FLAGS) 27 + -CFLAGS-cache.c += $(SYSCONF-FLAGS) 28 + -CFLAGS-rtld.c += $(SYSCONF-FLAGS) 29 + +CFLAGS-dl-cache.c += $(PREFIX-FLAGS) 30 + +CFLAGS-cache.c += $(PREFIX-FLAGS) 31 + +CFLAGS-rtld.c += $(PREFIX-FLAGS) 32 + 33 + cpp-srcs-left := $(all-rtld-routines:=.os) 34 + lib := rtld 35 + diff -Naur glibc-2.27-orig/sysdeps/generic/dl-cache.h glibc-2.27/sysdeps/generic/dl-cache.h 36 + --- glibc-2.27-orig/sysdeps/generic/dl-cache.h 2018-02-01 11:17:18.000000000 -0500 37 + +++ glibc-2.27/sysdeps/generic/dl-cache.h 2018-02-17 22:45:20.471598816 -0500 38 + @@ -28,7 +28,7 @@ 39 + #endif 40 + 41 + #ifndef LD_SO_CACHE 42 + -# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache" 43 + +# define LD_SO_CACHE PREFIX "/etc/ld.so.cache" 44 + #endif 45 + 46 + #ifndef add_system_dir
+118
pkgs/development/libraries/glibc/nix-locale-archive-2.27.patch
···
··· 1 + diff -Naur glibc-2.27-orig/locale/loadarchive.c glibc-2.27/locale/loadarchive.c 2 + --- glibc-2.27-orig/locale/loadarchive.c 2018-02-01 11:17:18.000000000 -0500 3 + +++ glibc-2.27/locale/loadarchive.c 2018-02-17 22:32:25.680169462 -0500 4 + @@ -123,6 +123,23 @@ 5 + return MAX (namehash_end, MAX (string_end, locrectab_end)); 6 + } 7 + 8 + +static int 9 + +open_locale_archive (void) 10 + +{ 11 + + int fd = -1; 12 + + char *versioned_path = getenv ("LOCAL_ARCHIVE_2_27"); 13 + + char *path = getenv ("LOCAL_ARCHIVE"); 14 + + if (versioned_path) 15 + + fd = __open_nocancel (versioned_path, O_RDONLY|O_LARGEFILE|O_CLOEXEC); 16 + + if (path && fd < 0) 17 + + fd = __open_nocancel (path, O_RDONLY|O_LARGEFILE|O_CLOEXEC); 18 + + if (fd < 0) 19 + + fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC); 20 + + if (fd < 0) 21 + + fd = __open_nocancel ("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC); 22 + + return fd; 23 + +} 24 + + 25 + 26 + /* Find the locale *NAMEP in the locale archive, and return the 27 + internalized data structure for its CATEGORY data. If this locale has 28 + @@ -202,7 +219,7 @@ 29 + archmapped = &headmap; 30 + 31 + /* The archive has never been opened. */ 32 + - fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC); 33 + + fd = open_locale_archive (); 34 + if (fd < 0) 35 + /* Cannot open the archive, for whatever reason. */ 36 + return NULL; 37 + @@ -397,8 +414,7 @@ 38 + if (fd == -1) 39 + { 40 + struct stat64 st; 41 + - fd = __open_nocancel (archfname, 42 + - O_RDONLY|O_LARGEFILE|O_CLOEXEC); 43 + + fd = open_locale_archive (); 44 + if (fd == -1) 45 + /* Cannot open the archive, for whatever reason. */ 46 + return NULL; 47 + diff -Naur glibc-2.27-orig/locale/programs/locale.c glibc-2.27/locale/programs/locale.c 48 + --- glibc-2.27-orig/locale/programs/locale.c 2018-02-01 11:17:18.000000000 -0500 49 + +++ glibc-2.27/locale/programs/locale.c 2018-02-17 22:36:39.726293213 -0500 50 + @@ -633,6 +633,24 @@ 51 + 52 + 53 + static int 54 + +open_locale_archive (void) 55 + +{ 56 + + int fd = -1; 57 + + char *versioned_path = getenv ("LOCAL_ARCHIVE_2_27"); 58 + + char *path = getenv ("LOCAL_ARCHIVE"); 59 + + if (versioned_path) 60 + + fd = open64 (versioned_path, O_RDONLY); 61 + + if (path && fd < 0) 62 + + fd = open64 (path, O_RDONLY); 63 + + if (fd < 0) 64 + + fd = open64 (ARCHIVE_NAME, O_RDONLY); 65 + + if (fd < 0) 66 + + fd = open64 ("/usr/lib/locale/locale-archive", O_RDONLY); 67 + + return fd; 68 + +} 69 + + 70 + + 71 + +static int 72 + write_archive_locales (void **all_datap, char *linebuf) 73 + { 74 + struct stat64 st; 75 + @@ -644,7 +662,7 @@ 76 + int fd, ret = 0; 77 + uint32_t cnt; 78 + 79 + - fd = open64 (ARCHIVE_NAME, O_RDONLY); 80 + + fd = open_locale_archive (); 81 + if (fd < 0) 82 + return 0; 83 + 84 + diff -Naur glibc-2.27-orig/locale/programs/locarchive.c glibc-2.27/locale/programs/locarchive.c 85 + --- glibc-2.27-orig/locale/programs/locarchive.c 2018-02-01 11:17:18.000000000 -0500 86 + +++ glibc-2.27/locale/programs/locarchive.c 2018-02-17 22:40:51.245293975 -0500 87 + @@ -117,6 +117,22 @@ 88 + } 89 + 90 + 91 + +static int 92 + +open_locale_archive (const char * archivefname, int flags) 93 + +{ 94 + + int fd = -1; 95 + + char *versioned_path = getenv ("LOCAL_ARCHIVE_2_27"); 96 + + char *path = getenv ("LOCAL_ARCHIVE"); 97 + + if (versioned_path) 98 + + fd = open64 (versioned_path, flags); 99 + + if (path && fd < 0) 100 + + fd = open64 (path, flags); 101 + + if (fd < 0) 102 + + fd = open64 (archivefname, flags); 103 + + return fd; 104 + +} 105 + + 106 + + 107 + static void 108 + create_archive (const char *archivefname, struct locarhandle *ah) 109 + { 110 + @@ -578,7 +594,7 @@ 111 + while (1) 112 + { 113 + /* Open the archive. We must have exclusive write access. */ 114 + - fd = open64 (archivefname, readonly ? O_RDONLY : O_RDWR); 115 + + fd = open_locale_archive (archivefname, readonly ? O_RDONLY : O_RDWR); 116 + if (fd == -1) 117 + { 118 + /* Maybe the file does not yet exist? If we are opening
+3
pkgs/top-level/all-packages.nix
··· 8748 glibc = callPackage ../development/libraries/glibc { 8749 installLocales = config.glibc.locales or false; 8750 }; 8751 8752 glibc_memusage = callPackage ../development/libraries/glibc { 8753 installLocales = false;
··· 8748 glibc = callPackage ../development/libraries/glibc { 8749 installLocales = config.glibc.locales or false; 8750 }; 8751 + glibc_2_27 = callPackage ../development/libraries/glibc/2.27.nix { 8752 + installLocales = config.glibc.locales or false; 8753 + }; 8754 8755 glibc_memusage = callPackage ../development/libraries/glibc { 8756 installLocales = false;