minimal-bootstrap: Update and address loose ends (#480093)

This commit is contained in:
John Ericson
2026-01-14 20:52:33 +00:00
committed by GitHub
40 changed files with 209 additions and 234 deletions
@@ -20,11 +20,11 @@
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "bash";
version = "5.2.37";
version = "5.3";
src = fetchurl {
url = "mirror://gnu/bash/bash-${version}.tar.gz";
hash = "sha256-lZmyLs0dV4etfTt78MWfMSszltHigRdd0fikAU2mIf8=";
hash = "sha256-DVzYaWX4aaJs9k9Lcb57lvkKO6iz104n6OnZ1VUPMbo=";
};
patches = [
@@ -109,6 +109,7 @@ bootBash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
--without-bash-malloc
# Build
@@ -19,11 +19,11 @@
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "bash-static";
version = "5.2.15";
version = "5.3";
src = fetchurl {
url = "mirror://gnu/bash/bash-${version}.tar.gz";
sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
sha256 = "sha256-DVzYaWX4aaJs9k9Lcb57lvkKO6iz104n6OnZ1VUPMbo=";
};
in
bash.runCommand "${pname}-${version}"
@@ -62,8 +62,8 @@ bash.runCommand "${pname}-${version}"
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--without-bash-malloc \
--disable-dependency-tracking \
--enable-static-link \
bash_cv_func_strtoimax=y \
CC=musl-gcc
# Build
@@ -20,11 +20,16 @@ let
# Based on https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a1-static-binutils.nix
inherit (import ./common.nix { inherit lib; }) meta;
pname = "binutils";
version = "2.41";
# Unfortunately, this is the latest version (as of 2.45.1) that works for
# - tinycc that compiles gcc 4.6.4 (ar in 2.45.* produce incompatible archives for tcc linker)
# - gcc 4.6.4 that compiles musl 1.2.5 (ld crashes in 2.43 and 2.44)
# This might need some further investigation.
version = "2.42";
src = fetchurl {
url = "mirror://gnu/binutils/binutils-${version}.tar.xz";
hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
hash = "sha256-9uTUH9X8d4sGt4kUV7NiDaXs6hAGxqSkGumYEJ+FqAA=";
};
patches = [
@@ -37,6 +42,7 @@ let
"--build=${buildPlatform.config}"
"--host=${hostPlatform.config}"
"--with-sysroot=/"
"--disable-dependency-tracking"
"--enable-deterministic-archives"
# depends on bison
"--disable-gprofng"
@@ -98,6 +104,12 @@ bash.runCommand "${pname}-${version}"
export CC="tcc -B ${tinycc.libs}/lib"
export AR="tcc -ar"
export lt_cv_sys_max_cmd_len=32768
# binutils 2.42 has a broken check for TLS storage class, which results
# in the TLS macro begin undefined.
# Let's help it along. We won't need TLS anyway.
export ac_cv_tls=" "
export CFLAGS="-D__LITTLE_ENDIAN__=1"
bash ./configure ${lib.concatStringsSep " " configureFlags}
@@ -20,11 +20,11 @@
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "binutils-static";
version = "2.41";
version = "2.45.1";
src = fetchurl {
url = "mirror://gnu/binutils/binutils-${version}.tar.xz";
hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
hash = "sha256-X+EB5v6dGP3slZYtge1nD97l834/SPC++Hvd+GJROqU=";
};
patches = [
@@ -39,6 +39,8 @@ let
"--build=${buildPlatform.config}"
"--host=${hostPlatform.config}"
"--disable-dependency-tracking"
"--with-sysroot=/"
"--enable-deterministic-archives"
# depends on bison
@@ -70,6 +70,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc
# Build
@@ -15,24 +15,30 @@
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "bootstrap-coreutils-musl";
version = "9.4";
version = "9.9";
src = fetchurl {
url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz";
hash = "sha256-X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
hash = "sha256-kacZ/Pkj3mhgFvLI0ISovh95PzQXOGEnPEZo98Za+Uo=";
};
configureFlags = [
"--prefix=${placeholder "out"}"
"--build=${buildPlatform.config}"
"--host=${hostPlatform.config}"
# musl 1.1.x doesn't use 64bit time_t
"--disable-year2038"
"--disable-dependency-tracking"
# libstdbuf.so fails in static builds
"--enable-no-install-program=stdbuf,arch,coreutils,hostname"
# Disable PATH_MAX for better reproducibility
"gl_cv_func_getcwd_path_max=\"no, but it is partly working\""
"gl_cv_have_unlimited_file_name_length=no"
# test crashes bash-2.05b?
"gl_cv_func_pthread_rwlock_good_waitqueue=no"
# depends on linux/version.h, which is not present at this stage
"gl_cv_func_copy_file_range=no"
"gl_cv_onwards_func_copy_file_range=no"
];
in
bash.runCommand "${pname}-${version}"
@@ -68,8 +74,12 @@ bash.runCommand "${pname}-${version}"
bash ./configure ${lib.concatStringsSep " " configureFlags}
# Build
make -j $NIX_BUILD_CORES AR="tcc -ar" MAKEINFO="true"
#
# Set SUBDIRS=. to avoid cd'ing to gnulib-tests. Those have
# compilation issues related to pthread and linux/*.h not
# being available.
make -j $NIX_BUILD_CORES AR="tcc -ar" MAKEINFO="true" SUBDIRS=.
# Install
make -j $NIX_BUILD_CORES install MAKEINFO="true"
make -j $NIX_BUILD_CORES install MAKEINFO="true" SUBDIRS=.
''
@@ -15,26 +15,28 @@
findutils,
gnutar,
gzip,
linux-headers,
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "coreutils-static";
version = "9.4";
version = "9.9";
src = fetchurl {
url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz";
hash = "sha256-X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
hash = "sha256-kacZ/Pkj3mhgFvLI0ISovh95PzQXOGEnPEZo98Za+Uo=";
};
configureFlags = [
"--prefix=${placeholder "out"}"
"--build=${buildPlatform.config}"
"--host=${hostPlatform.config}"
"--disable-dependency-tracking"
# libstdbuf.so fails in static builds
"--enable-no-install-program=stdbuf"
"--enable-single-binary=symlinks"
"CC=musl-gcc"
"CFLAGS=-static"
"CFLAGS=\"-static -I${linux-headers}/include\""
];
in
bash.runCommand "${pname}-${version}"
@@ -138,32 +138,24 @@ lib.makeScope
tinycc = tinycc-musl;
gnumake = gnumake-musl;
gnutar = gnutar-musl;
# FIXME: not sure why new gawk doesn't work
gawk = gawk-mes;
};
gcc46-cxx = callPackage ./gcc/4.6.cxx.nix {
gcc = gcc46;
gnumake = gnumake-musl;
gnutar = gnutar-musl;
# FIXME: not sure why new gawk doesn't work
gawk = gawk-mes;
};
gcc8 = callPackage ./gcc/8.nix {
gcc10 = callPackage ./gcc/10.nix {
gcc = gcc46-cxx;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
# FIXME: not sure why new gawk doesn't work
gawk = gawk-mes;
};
gcc-latest = callPackage ./gcc/latest.nix {
gcc = gcc8;
gcc = gcc10;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
# FIXME: not sure why new gawk doesn't work
gawk = gawk-mes;
};
gcc-glibc = callPackage ./gcc/glibc.nix {
@@ -292,13 +284,13 @@ lib.makeScope
mes-libc = callPackage ./mes/libc.nix { };
musl11-intermediate = callPackage ./musl/1.1.nix {
musl-tcc-intermediate = callPackage ./musl/tcc.nix {
bash = bash_2_05;
tinycc = tinycc-mes;
gnused = gnused-mes;
};
musl11 = callPackage ./musl/1.1.nix {
musl-tcc = callPackage ./musl/tcc.nix {
bash = bash_2_05;
tinycc = tinycc-musl-intermediate;
gnused = gnused-mes;
@@ -337,7 +329,7 @@ lib.makeScope
tinycc-musl-intermediate = lib.recurseIntoAttrs (
callPackage ./tinycc/musl.nix {
bash = bash_2_05;
musl = musl11-intermediate;
musl = musl-tcc-intermediate;
tinycc = tinycc-mes;
}
);
@@ -345,7 +337,7 @@ lib.makeScope
tinycc-musl = lib.recurseIntoAttrs (
callPackage ./tinycc/musl.nix {
bash = bash_2_05;
musl = musl11;
musl = musl-tcc;
tinycc = tinycc-musl-intermediate;
}
);
@@ -370,55 +362,61 @@ lib.makeScope
};
inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText;
test = kaem.runCommand "minimal-bootstrap-test" { } ''
echo ${bash.tests.get-version}
echo ${bash-static.tests.get-version}
echo ${bash_2_05.tests.get-version}
echo ${binutils.tests.get-version}
echo ${binutils-static.tests.get-version}
echo ${bison.tests.get-version}
echo ${busybox-static.tests.get-version}
echo ${bzip2.tests.get-version}
echo ${bzip2-static.tests.get-version}
echo ${coreutils-musl.tests.get-version}
echo ${coreutils-static.tests.get-version}
echo ${diffutils.tests.get-version}
echo ${diffutils-static.tests.get-version}
echo ${findutils.tests.get-version}
echo ${findutils-static.tests.get-version}
echo ${gawk.tests.get-version}
echo ${gawk-mes.tests.get-version}
echo ${gawk-static.tests.get-version}
echo ${gcc46.tests.get-version}
echo ${gcc46-cxx.tests.hello-world}
echo ${gcc8.tests.hello-world}
echo ${gcc-latest.tests.hello-world}
echo ${gcc-glibc.tests.hello-world}
echo ${glibc.tests.hello-world}
echo ${gnugrep.tests.get-version}
echo ${gnugrep-static.tests.get-version}
echo ${gnum4.tests.get-version}
echo ${gnumake-musl.tests.get-version}
echo ${gnumake-static.tests.get-version}
echo ${gnupatch-static.tests.get-version}
echo ${gnused.tests.get-version}
echo ${gnused-mes.tests.get-version}
echo ${gnused-static.tests.get-version}
echo ${gnutar.tests.get-version}
echo ${gnutar-latest.tests.get-version}
echo ${gnutar-musl.tests.get-version}
echo ${gnutar-static.tests.get-version}
echo ${gzip.tests.get-version}
echo ${gzip-static.tests.get-version}
echo ${heirloom.tests.get-version}
echo ${mes.compiler.tests.get-version}
echo ${musl.tests.hello-world}
echo ${patchelf-static.tests.get-version}
echo ${python.tests.get-version}
echo ${tinycc-mes.compiler.tests.chain}
echo ${tinycc-musl.compiler.tests.hello-world}
echo ${xz.tests.get-version}
mkdir ''${out}
'';
test = kaem.runCommand "minimal-bootstrap-test" { } (
''
echo ${bash.tests.get-version}
echo ${bash-static.tests.get-version}
echo ${bash_2_05.tests.get-version}
echo ${binutils.tests.get-version}
echo ${binutils-static.tests.get-version}
echo ${bison.tests.get-version}
echo ${busybox-static.tests.get-version}
echo ${bzip2.tests.get-version}
echo ${bzip2-static.tests.get-version}
echo ${coreutils-musl.tests.get-version}
echo ${coreutils-static.tests.get-version}
echo ${diffutils.tests.get-version}
echo ${diffutils-static.tests.get-version}
echo ${findutils.tests.get-version}
echo ${findutils-static.tests.get-version}
echo ${gawk.tests.get-version}
echo ${gawk-mes.tests.get-version}
echo ${gawk-static.tests.get-version}
echo ${gcc46.tests.get-version}
echo ${gcc46-cxx.tests.hello-world}
echo ${gcc10.tests.hello-world}
echo ${gcc-latest.tests.hello-world}
echo ${gnugrep.tests.get-version}
echo ${gnugrep-static.tests.get-version}
echo ${gnum4.tests.get-version}
echo ${gnumake-musl.tests.get-version}
echo ${gnumake-static.tests.get-version}
echo ${gnupatch-static.tests.get-version}
echo ${gnused.tests.get-version}
echo ${gnused-mes.tests.get-version}
echo ${gnused-static.tests.get-version}
echo ${gnutar.tests.get-version}
echo ${gnutar-latest.tests.get-version}
echo ${gnutar-musl.tests.get-version}
echo ${gnutar-static.tests.get-version}
echo ${gzip.tests.get-version}
echo ${gzip-static.tests.get-version}
echo ${heirloom.tests.get-version}
echo ${mes.compiler.tests.get-version}
echo ${musl.tests.hello-world}
echo ${patchelf-static.tests.get-version}
echo ${python.tests.get-version}
echo ${tinycc-mes.compiler.tests.chain}
echo ${tinycc-musl.compiler.tests.hello-world}
echo ${xz.tests.get-version}
''
+ (lib.strings.optionalString (hostPlatform.libc == "glibc") ''
echo ${gcc-glibc.tests.hello-world}
echo ${glibc.tests.hello-world}
'')
+ ''
mkdir ''${out}
''
);
}
)
@@ -65,7 +65,8 @@ bash.runCommand "${pname}-${version}"
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config}
--host=${hostPlatform.config} \
--disable-dependency-tracking
# Build
make -j $NIX_BUILD_CORES AR="tcc -ar"
@@ -68,6 +68,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static \
ac_cv_path_PR_PROGRAM=pr
@@ -14,11 +14,11 @@
}:
let
pname = "findutils";
version = "4.9.0";
version = "4.10.0";
src = fetchurl {
url = "mirror://gnu/findutils/findutils-${version}.tar.xz";
hash = "sha256-or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
hash = "sha256-E4fgtn/yR9Kr3pmPkN+/cMFJE5Glnd/suK5ph4nwpPU=";
};
in
bash.runCommand "${pname}-${version}"
@@ -69,7 +69,8 @@ bash.runCommand "${pname}-${version}"
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config}
--host=${hostPlatform.config} \
--disable-dependency-tracking
# Build
make -j $NIX_BUILD_CORES
@@ -18,11 +18,11 @@
}:
let
pname = "findutils-static";
version = "4.9.0";
version = "4.10.0";
src = fetchurl {
url = "mirror://gnu/findutils/findutils-${version}.tar.xz";
hash = "sha256-or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
hash = "sha256-E4fgtn/yR9Kr3pmPkN+/cMFJE5Glnd/suK5ph4nwpPU=";
};
in
bash.runCommand "${pname}-${version}"
@@ -68,6 +68,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static
@@ -15,11 +15,11 @@
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "gawk";
version = "5.2.2";
version = "5.3.2";
src = fetchurl {
url = "mirror://gnu/gawk/gawk-${version}.tar.gz";
hash = "sha256-lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA=";
hash = "sha256-hjmhqI+0EaG+AmY3OdA+kCptMTtcb+Ak0L/rM0GhmhE=";
};
in
bash.runCommand "${pname}-${version}"
@@ -55,7 +55,8 @@ bash.runCommand "${pname}-${version}"
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config}
--host=${hostPlatform.config} \
--disable-dependency-tracking
# Build
make -j $NIX_BUILD_CORES
@@ -62,6 +62,7 @@ bash.runCommand "${pname}-${version}"
bash ./configure \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
--disable-nls \
--prefix=$out
@@ -61,6 +61,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static
@@ -21,11 +21,13 @@
}:
let
pname = "gcc";
version = "8.5.0";
# Cannot use 10.5.0, see:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?format=multiple&id=110716
version = "10.4.0";
src = fetchurl {
url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz";
hash = "sha256-0wiEGlEbuDCmEAOXsAQtskzhH2Qtq26m7kSELlMl7VA=";
hash = "sha256-ySl9W818tD89/C/tU4npSMkxL9li72pM5FXP+WPr5PE=";
};
# last version to compile with gcc 4.6
@@ -35,10 +37,10 @@ let
hash = "sha256-/UgpkSzd0S+EGBw0Ucx1K+IkZD6H+sSXtp7d2txJtPI=";
};
mpfrVersion = "4.2.1";
mpfrVersion = "4.2.2";
mpfr = fetchurl {
url = "mirror://gnu/mpfr/mpfr-${mpfrVersion}.tar.xz";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
hash = "sha256-tnugOD736KhWNzTi6InvXsPDuJigHQD6CmhprYHGzgE=";
};
mpcVersion = "1.3.1";
@@ -138,6 +140,7 @@ bash.runCommand "${pname}-${version}"
--with-sysroot=${musl} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-dependency-tracking \
--disable-libmpx \
--disable-libsanitizer \
--disable-lto \
@@ -54,6 +54,11 @@ let
# Remove hardcoded NATIVE_SYSTEM_HEADER_DIR
./no-system-headers.patch
];
# config.sub was generated with outdated autotools, which get confused by
# 4-component target tuples
fakeBuildPlatform = lib.strings.removeSuffix "-musl" buildPlatform.config;
fakeHostPlatform = lib.strings.removeSuffix "-musl" hostPlatform.config;
in
bash.runCommand "${pname}-${version}"
{
@@ -132,12 +137,13 @@ bash.runCommand "${pname}-${version}"
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--build=${fakeBuildPlatform} \
--host=${fakeHostPlatform} \
--with-native-system-header-dir=${musl}/include \
--with-build-sysroot=${musl} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-dependency-tracking \
--disable-libmudflap \
--disable-libstdcxx-pch \
--disable-lto \
@@ -52,6 +52,11 @@ let
# Remove hardcoded NATIVE_SYSTEM_HEADER_DIR
./no-system-headers.patch
];
# config.sub was generated with outdated autotools, which get confused by
# 4-component target tuples
fakeBuildPlatform = lib.strings.removeSuffix "-musl" buildPlatform.config;
fakeHostPlatform = lib.strings.removeSuffix "-musl" hostPlatform.config;
in
bash.runCommand "${pname}-${version}"
{
@@ -115,12 +120,13 @@ bash.runCommand "${pname}-${version}"
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--build=${fakeBuildPlatform} \
--host=${fakeHostPlatform} \
--with-native-system-header-dir=${tinycc.libs}/include \
--with-build-sysroot=${tinycc.libs}/include \
--disable-bootstrap \
--disable-decimal-float \
--disable-dependency-tracking \
--disable-libatomic \
--disable-libcilkrts \
--disable-libgomp \
@@ -22,7 +22,7 @@
}:
let
pname = "gcc";
version = "13.2.0";
version = "15.2.0";
linkerName =
{
i686-linux = "ld-linux.so.2";
@@ -32,7 +32,7 @@ let
src = fetchurl {
url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
hash = "sha256-Q4/ZloJrDIJIWinaA6ctcdbjVBqD7HAt9Ccfb+Al0k4=";
};
gmpVersion = "6.3.0";
@@ -41,10 +41,10 @@ let
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfrVersion = "4.2.1";
mpfrVersion = "4.2.2";
mpfr = fetchurl {
url = "mirror://gnu/mpfr/mpfr-${mpfrVersion}.tar.xz";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
hash = "sha256-tnugOD736KhWNzTi6InvXsPDuJigHQD6CmhprYHGzgE=";
};
mpcVersion = "1.3.1";
@@ -21,11 +21,11 @@
}:
let
pname = "gcc";
version = "13.2.0";
version = "15.2.0";
src = fetchurl {
url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
hash = "sha256-Q4/ZloJrDIJIWinaA6ctcdbjVBqD7HAt9Ccfb+Al0k4=";
};
gmpVersion = "6.3.0";
@@ -34,10 +34,10 @@ let
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfrVersion = "4.2.1";
mpfrVersion = "4.2.2";
mpfr = fetchurl {
url = "mirror://gnu/mpfr/mpfr-${mpfrVersion}.tar.xz";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
hash = "sha256-tnugOD736KhWNzTi6InvXsPDuJigHQD6CmhprYHGzgE=";
};
mpcVersion = "1.3.1";
@@ -135,6 +135,7 @@ bash.runCommand "${pname}-${version}"
--with-sysroot=${musl} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-dependency-tracking \
--disable-libsanitizer \
--disable-lto \
--disable-multilib \
@@ -20,11 +20,11 @@
}:
let
pname = "glibc";
version = "2.38";
version = "2.42";
src = fetchurl {
url = "mirror://gnu/libc/glibc-${version}.tar.xz";
hash = "sha256-+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I=";
hash = "sha256-0XdeMuRijmTvkw9DW2e7Y691may2viszW58Z8WUJ8X8=";
};
linkerFile =
@@ -33,6 +33,7 @@ let
i686-linux = "ld-linux";
}
.${buildPlatform.system};
in
bash.runCommand "${pname}-${version}"
{
@@ -101,7 +102,8 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--with-headers=${linux-headers}/include
--with-headers=${linux-headers}/include \
--disable-dependency-tracking
# Build
make -j $NIX_BUILD_CORES
@@ -18,11 +18,11 @@
}:
let
pname = "gnugrep-static";
version = "3.11";
version = "3.12";
src = fetchurl {
url = "mirror://gnu/grep/grep-${version}.tar.xz";
hash = "sha256-HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=";
hash = "sha256-JkmyfA6Q5jLq3NdXvgbG6aT0jZQd5R58D4P/dkCKB7k=";
};
in
bash.runCommand "${pname}-${version}"
@@ -69,6 +69,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static
@@ -69,6 +69,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc
# Build
@@ -68,7 +68,8 @@ bash.runCommand "${pname}-${version}"
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config}
--host=${hostPlatform.config} \
--disable-dependency-tracking
# Build
make AR="tcc -ar"
@@ -71,12 +71,16 @@ bash.runCommand "${pname}-${version}"
${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}
# Configure
#
# Use std=gnu17 to avoid issue GCC 15.2.0 incompatibility.
# There is no newer release of gnumake available right now.
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static
CFLAGS="-static -std=gnu17"
# Build
make -j $NIX_BUILD_CORES
@@ -69,6 +69,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static
@@ -22,6 +22,11 @@ let
url = "mirror://gnu/sed/sed-${version}.tar.gz";
hash = "sha256-20XNY/0BDmUFN9ZdXfznaJplJ0UjZgbl5ceCk3Jn2YM=";
};
# config.sub was generated with outdated autotools, which get confused by
# 4-component target tuples
fakeBuildPlatform = lib.strings.removeSuffix "-musl" buildPlatform.config;
fakeHostPlatform = lib.strings.removeSuffix "-musl" hostPlatform.config;
in
bash.runCommand "${pname}-${version}"
{
@@ -52,8 +57,8 @@ bash.runCommand "${pname}-${version}"
export CC="tcc -B ${tinycc.libs}/lib"
export LD=tcc
./configure \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--build=${fakeBuildPlatform} \
--host=${fakeHostPlatform} \
--disable-shared \
--disable-nls \
--disable-dependency-tracking \
@@ -61,6 +61,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static
@@ -57,6 +57,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc
# Build
@@ -50,6 +50,7 @@ bash.runCommand "${pname}-${version}"
bash ./configure \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
--disable-nls \
--prefix=$out
@@ -56,6 +56,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
--disable-nls
# Build
@@ -61,6 +61,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static
@@ -51,7 +51,8 @@ bash.runCommand "${pname}-${version}"
# Configure
export CC="tcc -B ${tinycc.libs}/lib -Dstrlwr=unused"
bash ./configure --prefix=$out
bash ./configure --prefix=$out \
--disable-dependency-tracking
# Build
make
@@ -18,11 +18,11 @@
}:
let
pname = "gzip-static";
version = "1.13";
version = "1.14";
src = fetchurl {
url = "mirror://gnu/gzip/gzip-${version}.tar.xz";
hash = "sha256-dFTraTXbF8ZlVXbC4bD6vv04tNCTbg+H9IzQYs6RoFc=";
hash = "sha256-Aae4gb0iC/32Ffl7hxj4C9/T9q3ThbmT3Pbv0U6MCsY=";
};
in
bash.runCommand "${pname}-${version}"
@@ -68,6 +68,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static
@@ -1,16 +0,0 @@
diff --git arch/x86_64/pthread_arch.h arch/x86_64/pthread_arch.h
index 65e880c..91b4a63 100644
--- arch/x86_64/pthread_arch.h
+++ arch/x86_64/pthread_arch.h
@@ -1,8 +1,8 @@
+extern pthread_t g_pthread;
+
static inline struct pthread *__pthread_self()
{
- struct pthread *self;
- __asm__ ("mov %%fs:0,%0" : "=r" (self) );
- return self;
+ return g_pthread;
}
#define TP_ADJ(p) (p)
@@ -1,71 +0,0 @@
Initial patch version retrieved from
https://git.stikonas.eu/andrius/live-bootstrap/src/commit/cd361e63f77842d9780303d63382eb686843c76b/sysa/musl-1.1.24/patches/stdio_flush_on_exit.patch
SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
SPDX-FileCopyrightText: 2025 Luna Nova <git@lunnova.dev>
SPDX-License-Identifier: MIT
Make sure real __stdio_exit() is called on exit and not the dummy
noop versions. This fixes the issue of truncated output when redirecting
output to a file or pipe. It also fixes truncated output on programs
that forget to call fclose()
Adds forward declarations to avoid implicit declaration error.
diff --git a/src/exit/exit.c b/src/exit/exit.c
index a6869b37..a4164682 100644
--- src/exit/exit.c
+++ src/exit/exit.c
@@ -2,16 +2,10 @@
#include <stdint.h>
#include "libc.h"
-static void dummy()
-{
-}
-
-/* atexit.c and __stdio_exit.c override these. the latter is linked
- * as a consequence of linking either __toread.c or __towrite.c. */
-weak_alias(dummy, __funcs_on_exit);
-weak_alias(dummy, __stdio_exit);
-weak_alias(dummy, _fini);
+void __funcs_on_exit(void);
+void __stdio_exit(void);
+void _fini(void);
extern weak hidden void (*const __fini_array_start)(void), (*const __fini_array_end)(void);
static void libc_exit_fini(void)
diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h
index d7398f59..69141813 100644
--- src/internal/stdio_impl.h
+++ src/internal/stdio_impl.h
@@ -47,9 +47,9 @@ struct _IO_FILE {
struct __locale_struct *locale;
};
-extern hidden FILE *volatile __stdin_used;
-extern hidden FILE *volatile __stdout_used;
-extern hidden FILE *volatile __stderr_used;
+extern FILE *volatile __stdin_used;
+extern FILE *volatile __stdout_used;
+extern FILE *volatile __stderr_used;
hidden int __lockfile(FILE *);
hidden void __unlockfile(FILE *);
diff --git a/src/stdio/__stdio_exit.c b/src/stdio/__stdio_exit.c
index a5e42c67..5947a141 100644
--- src/stdio/__stdio_exit.c
+++ src/stdio/__stdio_exit.c
@@ -1,10 +1,5 @@
#include "stdio_impl.h"
-static FILE *volatile dummy_file = 0;
-weak_alias(dummy_file, __stdin_used);
-weak_alias(dummy_file, __stdout_used);
-weak_alias(dummy_file, __stderr_used);
-
static void close_file(FILE *f)
{
if (!f) return;
@@ -15,42 +15,22 @@
let
inherit (import ./common.nix { inherit lib; }) pname meta;
version = "1.1.24";
version = "1.2.5";
src = fetchurl {
url = "https://musl.libc.org/releases/musl-${version}.tar.gz";
hash = "sha256-E3DJqBKyzyp9koAlEMygBYzDfmanvt1wBR8KNAFQIqM=";
hash = "sha256-qaEYu+hNh2TaDqDSizqz+uhHf8fkCF2QECuFlvx8deQ=";
};
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24/musl-1.1.24.sh
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24";
patches = [
(fetchurl {
url = "${liveBootstrap}/patches/avoid_set_thread_area.patch";
hash = "sha256-TsbBZXk4/KMZG9EKi7cF+sullVXrxlizLNH0UHGXsPs=";
})
(fetchurl {
url = "${liveBootstrap}/patches/avoid_sys_clone.patch";
hash = "sha256-/ZmH64J57MmbxdfQ4RNjamAiBdkImMTlHsHdgV4gMj4=";
})
(fetchurl {
url = "${liveBootstrap}/patches/set_thread_area.patch";
hash = "sha256-RIZYqbbRSx4X/0iFUhriwwBRmoXVR295GNBUjf2UrM0=";
})
# tinycc doesn't implement backward-jumping jecxz, and it would be hard to implement
(fetchurl {
url = "${liveBootstrap}/patches/sigsetjmp.patch";
hash = "sha256-wd2Aev1zPJXy3q933aiup5p1IMKzVJBquAyl3gbK4PU=";
})
# liveBootstrap/sysa/musl-1.1.24/patches/stdio_flush_on_exit.patch with forward declarations added
# to avoid `error: implicit declaration of function '__stdio_exit'`
# Required to fix buffered stdout being truncated on exit
./stdio_flush_on_exit.patch
./avoid_pthread_x86_64.patch
(fetchurl {
url = "${liveBootstrap}/patches/va_list.patch";
hash = "sha256-UmcMIl+YCi3wIeVvjbsCyqFlkyYsM4ECNwTfXP+s7vg=";
})
];
in
bash.runCommand "${pname}-${version}"
@@ -93,6 +73,12 @@ bash.runCommand "${pname}-${version}"
sed -i 's|@PLT||' src/math/x86_64/expl.s
sed -i 's|@PLT||' src/signal/x86_64/sigsetjmp.s
# TODO Implement the required asm constraints 'x' and 't' in tinycc.
# For now, we just remove code using those constraints. musl automatically
# polyfills with pure C implementations.
rm src/math/i386/*.c
rm src/math/x86_64/*.c
# Configure
bash ./configure \
--prefix=$out \
@@ -68,6 +68,7 @@ bash.runCommand "${pname}-${version}"
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CXXFLAGS=-static
@@ -20,11 +20,11 @@
}:
let
pname = "python";
version = "3.13.7";
version = "3.14.2";
src = fetchurl {
url = "https://www.python.org/ftp/python/${version}/Python-${version}.tar.xz";
hash = "sha256-VGL5CZ39MOI43vg8cdkYl9jKpf9uvHpQ8U1IAs2qp5o=";
hash = "sha256-zlQ6uFS8JWthtx6bJ/gx/9G/1gpHnWOfi+f5dXz1c+k=";
};
patches = [
@@ -14,11 +14,14 @@
}:
let
pname = "xz";
version = "5.4.3";
# At least versions 5.6.4 and 5.8.2 crash with spurious OoM when decompressing
# certain tarballs, when compiled with tcc.
version = "5.4.7";
src = fetchurl {
url = "https://tukaani.org/xz/xz-${version}.tar.gz";
hash = "sha256-HDguC8Lk4K9YOYqQPdYv/35RAXHS3keh6+BtFSjpt+k=";
hash = "sha256-jbZmTEjKB5CLkrrtz+fzuiP0nvJHaGRRirXbZyODbnE=";
};
in
bash.runCommand "${pname}-${version}"
@@ -71,7 +74,8 @@ bash.runCommand "${pname}-${version}"
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-shared \
--disable-assembler
--disable-assembler \
--disable-dependency-tracking
# Build
make -j $NIX_BUILD_CORES