push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,134 @@
From e207c3dbcff1d3d09c60eec99b6fec2a698b01bd Mon Sep 17 00:00:00 2001
From: Bernardo Meurer <bernardo@meurer.org>
Date: Fri, 22 Jul 2022 22:11:07 -0700
Subject: [PATCH] Revert "Remove all usage of @BASH@ or ${BASH} in installed
files, and hardcode /bin/bash instead"
We need the ability to override to use `/bin/sh` here to avoid having
some bootstrap tools in a final build product.
This reverts commit 5188a9d0265cc6f7235a8af1d31ab02e4a24853d.
Co-authored-by: Maximilian Bosch <maximilian@mbosch.me>
---
debug/Makefile | 5 +++--
debug/xtrace.sh | 2 +-
elf/Makefile | 4 +++-
elf/ldd.bash.in | 2 +-
elf/sotruss.sh | 2 +-
malloc/Makefile | 5 +++--
malloc/memusage.sh | 2 +-
timezone/Makefile | 3 ++-
8 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/debug/Makefile b/debug/Makefile
index 3903cc97a3..b041acca71 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -343,8 +343,9 @@ $(objpfx)pcprofiledump: $(objpfx)pcprofiledump.o
$(objpfx)xtrace: xtrace.sh
rm -f $@.new
- sed -e 's|@VERSION@|$(version)|' -e 's|@SLIBDIR@|$(sLIBdir)|' \
- -e 's|@BINDIR@|$(bindir)|' -e 's|@PKGVERSION@|$(PKGVERSION)|' \
+ sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
+ -e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' \
+ -e 's|@PKGVERSION@|$(PKGVERSION)|' \
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
&& rm -f $@ && mv $@.new $@ && chmod +x $@
diff --git a/debug/xtrace.sh b/debug/xtrace.sh
index 77ec1d84df..5614404a71 100755
--- a/debug/xtrace.sh
+++ b/debug/xtrace.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#! @BASH@
# Copyright (C) 1999-2024 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
diff --git a/elf/Makefile b/elf/Makefile
index 5d78b659ce..a2145d7b64 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -249,7 +249,8 @@ $(objpfx)sotruss-lib.so: $(common-objpfx)libc.so $(objpfx)ld.so \
$(common-objpfx)libc_nonshared.a
$(objpfx)sotruss: sotruss.sh $(common-objpfx)config.make
- sed -e 's%@VERSION@%$(version)%g' \
+ sed -e 's%@BASH@%$(BASH)%g' \
+ -e 's%@VERSION@%$(version)%g' \
-e 's%@TEXTDOMAINDIR@%$(localedir)%g' \
-e 's%@PREFIX@%$(prefix)%g' \
-e 's|@PKGVERSION@|$(PKGVERSION)|g' \
@@ -1392,6 +1393,7 @@ ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
-e 's%@VERSION@%$(version)%g' \
-e 's|@PKGVERSION@|$(PKGVERSION)|g' \
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
+ -e 's%@BASH@%$(BASH)%g' \
-e 's%@TEXTDOMAINDIR@%$(localedir)%g'
ifeq ($(ldd-rewrite-script),no)
diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in
index d6b640df66..46111670cd 100644
--- a/elf/ldd.bash.in
+++ b/elf/ldd.bash.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#! @BASH@
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
diff --git a/elf/sotruss.sh b/elf/sotruss.sh
index ac1a83984e..2bf17c518e 100755
--- a/elf/sotruss.sh
+++ b/elf/sotruss.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#! @BASH@
# Copyright (C) 2011-2024 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
diff --git a/malloc/Makefile b/malloc/Makefile
index c83ade5f10..8dd9174b79 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -312,8 +312,9 @@ $(objpfx)mtrace: mtrace.pl
$(objpfx)memusage: memusage.sh
rm -f $@.new
- sed -e 's|@VERSION@|$(version)|' -e 's|@SLIBDIR@|$(sLIBdir)|' \
- -e 's|@BINDIR@|$(bindir)|' -e 's|@PKGVERSION@|$(PKGVERSION)|' \
+ sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
+ -e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' \
+ -e 's|@PKGVERSION@|$(PKGVERSION)|' \
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
&& rm -f $@ && mv $@.new $@ && chmod +x $@
diff --git a/malloc/memusage.sh b/malloc/memusage.sh
index d2d9d17ea8..2e7efc9049 100755
--- a/malloc/memusage.sh
+++ b/malloc/memusage.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#! @BASH@
# Copyright (C) 1999-2024 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
diff --git a/timezone/Makefile b/timezone/Makefile
index d7acb387ba..c8e203ea3a 100644
--- a/timezone/Makefile
+++ b/timezone/Makefile
@@ -132,7 +132,8 @@ $(testdata)/XT5: testdata/gen-XT5.sh
mv $@.tmp $@
$(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
- sed -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
+ sed -e 's|/bin/bash|$(BASH)|' \
+ -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
-e '/TZVERSION=/s|see_Makefile|"$(version)"|' \
-e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \
-e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \
--
2.42.0

View File

@@ -0,0 +1,37 @@
From 44d0a3a9bd8c6fe59f6ccb44206a50a900bfcf4a Mon Sep 17 00:00:00 2001
From: Connor Baker <connor.baker@tweag.io>
Date: Tue, 31 Oct 2023 14:30:24 +0000
Subject: [PATCH] aarch64/math-vector.h: add NVCC include guard
---
sysdeps/aarch64/fpu/bits/math-vector.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sysdeps/aarch64/fpu/bits/math-vector.h b/sysdeps/aarch64/fpu/bits/math-vector.h
index 7c200599c1..583a426494 100644
--- a/sysdeps/aarch64/fpu/bits/math-vector.h
+++ b/sysdeps/aarch64/fpu/bits/math-vector.h
@@ -25,17 +25,17 @@
/* Get default empty definitions for simd declarations. */
#include <bits/libm-simd-decl-stubs.h>
-#if __GNUC_PREREQ(9, 0)
+#if __GNUC_PREREQ(9, 0) && !defined(__CUDACC__)
# define __ADVSIMD_VEC_MATH_SUPPORTED
typedef __Float32x4_t __f32x4_t;
typedef __Float64x2_t __f64x2_t;
-#elif __glibc_clang_prereq(8, 0)
+#elif __glibc_clang_prereq(8, 0) && !defined(__CUDACC__)
# define __ADVSIMD_VEC_MATH_SUPPORTED
typedef __attribute__ ((__neon_vector_type__ (4))) float __f32x4_t;
typedef __attribute__ ((__neon_vector_type__ (2))) double __f64x2_t;
#endif
-#if __GNUC_PREREQ(10, 0) || __glibc_clang_prereq(11, 0)
+#if (__GNUC_PREREQ(10, 0) || __glibc_clang_prereq(11, 0)) && !defined(__CUDACC__)
# define __SVE_VEC_MATH_SUPPORTED
typedef __SVFloat32_t __sv_f32_t;
typedef __SVFloat64_t __sv_f64_t;
--
2.42.0

View File

@@ -0,0 +1,49 @@
Revert 55d63e731253de82e96ed4ddca2e294076cd0bc5
--- b/sysdeps/x86/cpu-features.c
+++ a/sysdeps/x86/cpu-features.c
@@ -110,7 +110,7 @@
if (!CPU_FEATURES_CPU_P (cpu_features, RTM_ALWAYS_ABORT))
CPU_FEATURE_SET_ACTIVE (cpu_features, RTM);
+#if CET_ENABLED
-#if CET_ENABLED && 0
CPU_FEATURE_SET_ACTIVE (cpu_features, IBT);
CPU_FEATURE_SET_ACTIVE (cpu_features, SHSTK);
#endif
reverted:
--- b/sysdeps/x86/cpu-tunables.c
+++ a/sysdeps/x86/cpu-tunables.c
@@ -35,17 +35,6 @@
break; \
}
-#define CHECK_GLIBC_IFUNC_CPU_BOTH(f, cpu_features, name, len) \
- _Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \
- if (tunable_str_comma_strcmp_cte (&f, #name)) \
- { \
- if (f.disable) \
- CPU_FEATURE_UNSET (cpu_features, name) \
- else \
- CPU_FEATURE_SET_ACTIVE (cpu_features, name) \
- break; \
- }
-
/* Disable a preferred feature NAME. We don't enable a preferred feature
which isn't available. */
#define CHECK_GLIBC_IFUNC_PREFERRED_OFF(f, cpu_features, name, len) \
@@ -142,13 +131,11 @@
}
break;
case 5:
- {
- CHECK_GLIBC_IFUNC_CPU_BOTH (n, cpu_features, SHSTK, 5);
- }
if (n.disable)
{
CHECK_GLIBC_IFUNC_CPU_OFF (n, cpu_features, LZCNT, 5);
CHECK_GLIBC_IFUNC_CPU_OFF (n, cpu_features, MOVBE, 5);
+ CHECK_GLIBC_IFUNC_CPU_OFF (n, cpu_features, SHSTK, 5);
CHECK_GLIBC_IFUNC_CPU_OFF (n, cpu_features, SSSE3, 5);
CHECK_GLIBC_IFUNC_CPU_OFF (n, cpu_features, XSAVE, 5);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,364 @@
/*
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,
enableCET ? false,
enableCETRuntimeDefault ? false,
extraBuildInputs ? [ ],
extraNativeBuildInputs ? [ ],
...
}@args:
let
version = "2.40";
patchSuffix = "-66";
sha256 = "sha256-GaiQF16SY9dI9ieZPeb0sa+c0h4D8IDkv7Oh+sECBaI=";
in
assert withLinuxHeaders -> linuxHeaders != null;
assert withGd -> gd != null && libpng != null;
assert enableCET == false -> !enableCETRuntimeDefault;
stdenv.mkDerivation (
{
version = version + patchSuffix;
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.40/master && git describe
glibc-2.40-142-g2eb180377b
$ git show --minimal --reverse glibc-2.40.. ':!ADVISORIES' > 2.40-master.patch
To compare the archive contents zdiff can be used.
$ diff -u 2.40-master.patch ../nixpkgs/pkgs/development/libraries/glibc/2.40-master.patch
Please note that each commit has changes to the file ADVISORIES excluded since
that conflicts with the directory advisories/ making cross-builds from
hosts with case-insensitive file-systems impossible.
*/
./2.40-master.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
./fix-x64-abi.patch
# https://github.com/NixOS/nixpkgs/pull/137601
./nix-nss-open-files.patch
./0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch
/*
Patch derived from archlinux,
https://gitlab.archlinux.org/archlinux/packaging/packages/glibc/-/blob/e54d98e2d1aae4930ecad9404ef12234922d9dfd/reenable_DT_HASH.patch
See also https://github.com/ValveSoftware/Proton/issues/6051
& https://github.com/NixOS/nixpkgs/pull/188492#issuecomment-1233802991
*/
./reenable_DT_HASH.patch
]
/*
NVCC does not support ARM intrinsics. Since <math.h> is pulled in by almost
every HPC piece of software, without this patch CUDA compilation on ARM
is effectively broken. See
https://forums.developer.nvidia.com/t/nvcc-fails-to-build-with-arm-neon-instructions-cpp-vs-cu/248355/2.
*/
++ (
let
isAarch64 = stdenv.buildPlatform.isAarch64 || stdenv.hostPlatform.isAarch64;
isLinux = stdenv.buildPlatform.isLinux || stdenv.hostPlatform.isLinux;
in
# Remove certain defines when __CUDACC__ is defined (i.e. we're building with a CUDA compiler)
lib.optional (isAarch64 && isLinux) ./0001-aarch64-math-vector.h-add-NVCC-include-guard.patch
)
# Modify certain defines to be compatible with musl
++ lib.optional stdenv.hostPlatform.isMusl ./fix-rpc-types-musl-conflicts.patch
# Enable cross-compilation of glibc on Darwin (build=Darwin, host=Linux)
++ lib.optional stdenv.buildPlatform.isDarwin ./darwin-cross-build.patch
# Reverts this patch: https://sourceware.org/git/?p=glibc.git;a=commit;h=55d63e731253de82e96ed4ddca2e294076cd0bc5
# This revert enables [CET] (Control-flow Enforcement Technology) by default
# [CET]: https://en.wikipedia.org/wiki/Control-flow_integrity#Intel_Control-flow_Enforcement_Technology
++ lib.optional enableCETRuntimeDefault ./2.39-revert-cet-default-disable.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
# Ensure that `__nss_files_fopen` can still be wrapped by `libredirect`.
sed -i -e '/libc_hidden_def (__nss_files_fopen)/d' nss/nss_files_fopen.c
sed -i -e '/libc_hidden_proto (__nss_files_fopen)/d' include/nss_files.h
''
# 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
''
# For some reason, with gcc-15 build fails with the following error:
#
# zic.c:3767:1: note: did you mean to specify it after ')' following function parameters?
# zic.c:3781:1: error: standard 'reproducible' attribute can only be applied to function declarators or type specifiers with function type []
+ ''
for path in timezone/zic.c timezone/zdump.c ; do
substituteInPlace $path --replace-fail "ATTRIBUTE_REPRODUCIBLE" ""
done
'';
configureFlags = [
"-C"
"--enable-add-ons"
"--sysconfdir=/etc"
"--enable-stack-protector=strong"
"--enable-bind-now"
(lib.withFeatureAs withLinuxHeaders "headers" "${linuxHeaders}/include")
(lib.enableFeature profilingLibraries "profile")
"--enable-fortify-source"
]
++ 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 (enableCET != false) [
# Enable Intel Control-flow Enforcement Technology (CET) support
"--enable-cet${if builtins.isString enableCET then "=${enableCET}" else ""}"
]
++ lib.optionals withLinuxHeaders [
"--enable-kernel=3.10.0" # RHEL 7 and derivatives, seems oldest still supported kernel
]
++ 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 =
(args.makeFlags or [ ])
++ [ "OBJCOPY=${stdenv.cc.targetPrefix}objcopy" ]
++ lib.optionals (stdenv.cc.libc != null) [
"BUILD_LDFLAGS=-Wl,-rpath,${stdenv.cc.libc}/lib"
"OBJDUMP=${stdenv.cc.bintools.bintools}/bin/objdump"
];
postInstall = (args.postInstall or "") + ''
moveToOutput bin/getent $getent
'';
installFlags = [ "sysconfdir=$(out)/etc" ];
# out as the first output is an exception exclusive to glibc
# getent is its own output, not kept in bin, since many things
# depend on getent but not on the locale generation tools in the bin
# output. This saves a couple of megabytes of closure size in many cases.
outputs = [
"out"
"bin"
"dev"
"static"
"getent"
];
strictDeps = true;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
bison
python3Minimal
]
++ extraNativeBuildInputs;
buildInputs = [
linuxHeaders
]
++ lib.optionals withGd [
gd
libpng
]
++ extraBuildInputs;
env = {
linuxHeaders = lib.optionalString withLinuxHeaders linuxHeaders;
inherit (stdenv.hostPlatform) is64bit;
# 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"
"linuxHeaders"
"withGd"
"enableCET"
"postInstall"
"makeFlags"
])
//
{
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.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 = "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; [
ma27
connorbaker
];
platforms = platforms.linux;
}
// (args.meta or { });
}
)

View File

@@ -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.

View File

@@ -0,0 +1,221 @@
{
lib,
stdenv,
callPackage,
withLinuxHeaders ? true,
linuxHeaders ? null,
profilingLibraries ? false,
withGd ? false,
enableCET ? if stdenv.hostPlatform.isx86_64 then "permissive" else false,
enableCETRuntimeDefault ? false,
pkgsBuildBuild,
libgcc,
}:
let
gdCflags = [
"-Wno-error=stringop-truncation"
"-Wno-error=missing-attributes"
"-Wno-error=array-bounds"
];
in
(callPackage ./common.nix { inherit stdenv linuxHeaders; } {
inherit
withLinuxHeaders
withGd
profilingLibraries
enableCET
enableCETRuntimeDefault
;
pname =
"glibc"
+ lib.optionalString withGd "-gd"
+ lib.optionalString (stdenv.cc.isGNU && libgcc == null) "-nolibgcc";
}).overrideAttrs
(previousAttrs: {
# 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` -- so instead you should
# write `patches = (previousAttrs.patches or []) ++ [ ... ]`.
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 pie, 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 = [
"fortify"
"pie"
"stackprotector"
"strictflexarrays3"
];
env = (previousAttrs.env or { }) // {
NIX_CFLAGS_COMPILE =
(previousAttrs.env.NIX_CFLAGS_COMPILE or "")
+ 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"
])
(lib.optionals (stdenv.hostPlatform.isPower64) [
# Do not complain about the Processor Specific ABI (i.e. the
# choice to use IEEE-standard `long double`). We pass this
# flag in order to mute a `-Werror=psabi` passed by glibc;
# hopefully future glibc releases will not pass that flag.
"-Wno-error=psabi"
])
]
);
};
# glibc needs to `dlopen()` `libgcc_s.so` but does not link
# against it. Furthermore, glibc doesn't use the ordinary
# `dlopen()` call to do this; instead it uses one which ignores
# most paths:
#
# https://sourceware.org/legacy-ml/libc-help/2013-11/msg00026.html
#
# In order to get it to not ignore `libgcc_s.so`, we have to add its path to
# `user-defined-trusted-dirs`:
#
# https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/Makefile;h=b509b3eada1fb77bf81e2a0ca5740b94ad185764#l1355
#
# Conveniently, this will also inform Nix of the fact that glibc depends on
# gcc.libgcc, since the path will be embedded in the resulting binary.
#
makeFlags =
(previousAttrs.makeFlags or [ ])
++ lib.optionals (libgcc != null) [
"user-defined-trusted-dirs=${libgcc}/lib"
];
postInstall =
previousAttrs.postInstall
+ (
if stdenv.buildPlatform.canExecute stdenv.hostPlatform then
''
echo SUPPORTED-LOCALES=C.UTF-8/UTF-8 > ../glibc-2*/localedata/SUPPORTED
# Don't install C.utf-8 into the archive, but into $out/lib/locale: on non-NixOS
# systems with an empty /usr/lib/locale/locale-archive, glibc would fall back to
# $libdir/locale/C.utf-8 instead of the locale archive of pkgs.glibc. See also #347965.
make -j''${NIX_BUILD_CORES:-1} localedata/install-locale-files
''
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 pkgsBuildBuild.
#
# Note that we can't use pkgsBuildHost (aka buildPackages) here, because
# that will cause an eval-time infinite recursion: "buildPackages.glibc
# depended on buildPackages.libgcc, which, since it's GCC, depends on the
# target's bintools, which depend on the target's glibc, which, again,
# depends on buildPackages.glibc, causing an infinute recursion when
# evaluating buildPackages.glibc when glibc hasn't come from stdenv
# (e.g. on musl)." https://github.com/NixOS/nixpkgs/pull/259964
''
pushd ../glibc-2*/localedata
export I18NPATH=$PWD GCONV_PATH=$PWD/../iconvdata
mkdir -p $NIX_BUILD_TOP/${pkgsBuildBuild.glibc}/lib/locale
${lib.getBin pkgsBuildBuild.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/${pkgsBuildBuild.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
# Backwards-compatibility to fix e.g.
# "configure: error: Pthreads are required to build libgomp" during `gcc`-build
# because it's not actually needed anymore to link against `pthreads` since
# it's now part of `libc.so.6` itself, but the gcc build breaks if
# this doesn't work.
ln -sf $out/lib/libpthread.so.0 $out/lib/libpthread.so
ln -sf $out/lib/librt.so.1 $out/lib/librt.so
ln -sf $out/lib/libdl.so.2 $out/lib/libdl.so
test -f $out/lib/libutil.so.1 && ln -sf $out/lib/libutil.so.1 $out/lib/libutil.so
touch $out/lib/libpthread.a
# 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
# If libutil.so.1 is missing, libutil.a is required.
test -f $out/lib/libutil.so.1 || mv $static/lib/libutil.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;
passthru =
(previousAttrs.passthru or { })
// lib.optionalAttrs (libgcc != null) {
inherit libgcc;
};
meta = (previousAttrs.meta or { }) // {
description = "GNU C Library";
};
})

View File

@@ -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

View File

@@ -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. */

View File

@@ -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
--

View File

@@ -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

View File

@@ -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"

View File

@@ -0,0 +1,30 @@
{
callPackage,
texinfo,
perl,
}:
callPackage ./common.nix { } {
pname = "glibc-info";
outputs = [ "out" ];
configureFlags = [ "--enable-add-ons" ];
extraNativeBuildInputs = [
texinfo
perl
];
buildFlags = [ "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";
}

View File

@@ -0,0 +1,15 @@
# Glibc cannot have itself in its RPATH.
export NIX_NO_SELF_RPATH=1
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

View File

@@ -0,0 +1,101 @@
/*
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" ],
linuxHeaders,
withLinuxHeaders ? !stdenv.cc.isGNU,
}:
(callPackage ./common.nix
({ inherit stdenv; } // lib.optionalAttrs withLinuxHeaders { inherit linuxHeaders; })
{
pname = "glibc-locales";
extraNativeBuildInputs = [ glibc ];
inherit withLinuxHeaders;
}
).overrideAttrs
(
finalAttrs: previousAttrs: {
builder = ./locales-builder.sh;
outputs = [ "out" ];
LOCALEDEF_FLAGS = [
(if stdenv.hostPlatform.isLittleEndian then "--little-endian" else "--big-endian")
];
preBuild =
(previousAttrs.preBuild or "")
+ ''
# 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.
LOCALEDEF_FLAGS+=" --prefix=$TMPDIR"
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 $(LOCALEDEF_FLAGS),' ../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
'';
# Current `nixpkgs` way of building locales is not compatible with
# parallel install. `locale-archive` is updated in parallel with
# multiple `localedef` processes and causes non-deterministic result:
# https://github.com/NixOS/nixpkgs/issues/245360
enableParallelBuilding = false;
makeFlags = (previousAttrs.makeFlags or [ ]) ++ [
"localedata/install-locales"
"localedir=${placeholder "out"}/lib/locale"
];
installPhase = ''
mkdir -p "$out/lib/locale" "$out/share/i18n"
cp -v "$TMPDIR/$NIX_STORE/"*"/lib/locale/locale-archive" "$out/lib/locale"
cp -v ../glibc-2*/localedata/SUPPORTED "$out/share/i18n/SUPPORTED"
'';
setupHook = writeText "locales-setup-hook.sh" ''
export LOCALE_ARCHIVE=@out@/lib/locale/locale-archive
'';
meta.description = "Locale information for the GNU C Library";
}
)

View File

@@ -0,0 +1,41 @@
{ 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 (oldAttrs: {
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 checked during configure
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ perl ];
# Perl shebang used for `mtrace`.
buildInputs = oldAttrs.buildInputs ++ [ perl ];
# Reset a few things declared by `pkgs.glibc`.
outputs = [ "out" ];
separateDebugInfo = false;
meta = oldAttrs.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)";
mainProgram = "mtrace";
};
})

View File

@@ -0,0 +1,55 @@
{
lib,
runCommand,
glibc,
glibc32,
}:
let
nameVersion = builtins.parseDrvName glibc.name;
glibc64 = glibc;
in
runCommand "${nameVersion.name}-multi-${nameVersion.version}"
# out as the first output is an exception exclusive to glibc
{
outputs = [
"out"
"bin"
"dev"
"static"
];
passthru = {
libgcc = lib.lists.filter (x: x != null) [
(glibc64.libgcc or null)
(glibc32.libgcc or null)
];
};
}
''
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/"
mkdir -p "$static/lib" "$static/lib64"
# create symlinks for files used for dynamic linking
# -> removing this will cause dynamically linked programs to segfault
cp -rs '${glibc32.out}'/lib/* "$static/lib"
cp -rs '${glibc64.out}'/lib/* "$static/lib64"
# create symlinks for files used for static linking
cp -rs '${glibc32.static}'/lib/* "$static/lib"
cp -rs '${glibc64.static}'/lib/* "$static/lib64"
''

View File

@@ -0,0 +1,125 @@
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index 452e3eb6e3..e2016a8aab 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -123,6 +123,25 @@ calculate_head_size (const struct locarhead *h)
return MAX (namehash_end, MAX (string_end, locrectab_end));
}
+static int
+open_locale_archive (void)
+{
+ int fd = -1;
+ char *versioned_path = secure_getenv ("LOCALE_ARCHIVE_2_27");
+ char *path = secure_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("/run/current-system/sw/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ if (fd < 0)
+ fd = __open_nocancel ("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ if (fd < 0)
+ fd = __open_nocancel (archfname, 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 +221,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
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 +416,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (fd == -1)
{
struct __stat64_t64 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 --git a/locale/programs/locale.c b/locale/programs/locale.c
index c7ee1874e8..af20fbac3e 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -632,6 +632,26 @@ nameentcmp (const void *a, const void *b)
}
+static int
+open_locale_archive (void)
+{
+ int fd = -1;
+ char *versioned_path = secure_getenv ("LOCALE_ARCHIVE_2_27");
+ char *path = secure_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 ("/run/current-system/sw/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ if (fd < 0)
+ fd = open64 ("/usr/lib/locale/locale-archive", O_RDONLY);
+ if (fd < 0)
+ fd = open64 (ARCHIVE_NAME, O_RDONLY);
+ return fd;
+}
+
+
static int
write_archive_locales (void **all_datap, char *linebuf)
{
@@ -644,7 +664,7 @@ write_archive_locales (void **all_datap, char *linebuf)
int fd, ret = 0;
uint32_t cnt;
- fd = open64 (ARCHIVE_NAME, O_RDONLY);
+ fd = open_locale_archive ();
if (fd < 0)
return 0;
diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
index 8d79a1b6d1..93118c52e3 100644
--- a/locale/programs/locarchive.c
+++ b/locale/programs/locarchive.c
@@ -116,6 +116,22 @@ prepare_address_space (int fd, size_t total, size_t *reserved, int *xflags,
}
+static int
+open_locale_archive (const char * archivefname, int flags)
+{
+ int fd = -1;
+ char *versioned_path = secure_getenv ("LOCALE_ARCHIVE_2_27");
+ char *path = secure_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)
{
@@ -577,7 +593,7 @@ open_archive (struct locarhandle *ah, bool readonly)
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

View File

@@ -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 {};

View File

@@ -0,0 +1,28 @@
From 31915e55f9c34f6137ab1c5ac002375a2d5d4589 Mon Sep 17 00:00:00 2001
From: Frederik Schwan <frederik.schwan@linux.com>
Date: Fri, 4 Aug 2023 15:19:57 +0200
Subject: [PATCH] force --hash-style=both to keep compatibility with old niche
software
---
Makeconfig | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makeconfig b/Makeconfig
index 77d7fd14df..2ae67c4beb 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -378,6 +378,10 @@ relro-LDFLAGS = -Wl,-z,relro
LDFLAGS.so += $(relro-LDFLAGS)
LDFLAGS-rtld += $(relro-LDFLAGS)
+hashstyle-LDFLAGS = -Wl,--hash-style=both
+LDFLAGS.so += $(hashstyle-LDFLAGS)
+LDFLAGS-rtld += $(hashstyle-LDFLAGS)
+
# Linker options to enable and disable DT_RELR.
ifeq ($(have-dt-relr),yes)
dt-relr-ldflag = -Wl,-z,pack-relative-relocs
--
2.41.0