From ab04cbf74bd9a2084894c3712abbe3ffb8fe4c6e Mon Sep 17 00:00:00 2001 From: Aleksi Hannula Date: Wed, 14 Jan 2026 22:03:14 +0200 Subject: [PATCH] minimal-bootstrap.musl-tcc: 1.1.24 -> 1.2.5 --- .../minimal-bootstrap/coreutils/musl.nix | 2 - .../linux/minimal-bootstrap/default.nix | 8 +-- .../minimal-bootstrap/findutils/default.nix | 1 - .../minimal-bootstrap/findutils/static.nix | 1 - .../musl/avoid_pthread_x86_64.patch | 16 ----- .../musl/stdio_flush_on_exit.patch | 71 ------------------- .../musl/{1.1.nix => tcc.nix} | 32 +++------ 7 files changed, 13 insertions(+), 118 deletions(-) delete mode 100644 pkgs/os-specific/linux/minimal-bootstrap/musl/avoid_pthread_x86_64.patch delete mode 100644 pkgs/os-specific/linux/minimal-bootstrap/musl/stdio_flush_on_exit.patch rename pkgs/os-specific/linux/minimal-bootstrap/musl/{1.1.nix => tcc.nix} (69%) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix index a06be1c2c8bc..80418bbb3ce0 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix @@ -27,8 +27,6 @@ let "--build=${buildPlatform.config}" "--host=${hostPlatform.config}" "--disable-dependency-tracking" - # musl 1.1.x doesn't use 64bit time_t - "--disable-year2038" # libstdbuf.so fails in static builds "--enable-no-install-program=stdbuf,arch,coreutils,hostname" # Disable PATH_MAX for better reproducibility diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 57d1940e5a61..25cedd7548b4 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -284,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; @@ -329,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; } ); @@ -337,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; } ); diff --git a/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix index d04485f0a7d0..96531fbbe67d 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix @@ -70,7 +70,6 @@ bash.runCommand "${pname}-${version}" --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ - --disable-year2038 \ --disable-dependency-tracking # Build diff --git a/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix index 39410bb928b8..1b15ab1f1b58 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix @@ -68,7 +68,6 @@ bash.runCommand "${pname}-${version}" --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ - --disable-year2038 \ --disable-dependency-tracking \ CC=musl-gcc \ CFLAGS=-static diff --git a/pkgs/os-specific/linux/minimal-bootstrap/musl/avoid_pthread_x86_64.patch b/pkgs/os-specific/linux/minimal-bootstrap/musl/avoid_pthread_x86_64.patch deleted file mode 100644 index b2aa1e004ab0..000000000000 --- a/pkgs/os-specific/linux/minimal-bootstrap/musl/avoid_pthread_x86_64.patch +++ /dev/null @@ -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) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/musl/stdio_flush_on_exit.patch b/pkgs/os-specific/linux/minimal-bootstrap/musl/stdio_flush_on_exit.patch deleted file mode 100644 index 145c13b29611..000000000000 --- a/pkgs/os-specific/linux/minimal-bootstrap/musl/stdio_flush_on_exit.patch +++ /dev/null @@ -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 -SPDX-FileCopyrightText: 2025 Luna Nova - -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 - #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; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/musl/1.1.nix b/pkgs/os-specific/linux/minimal-bootstrap/musl/tcc.nix similarity index 69% rename from pkgs/os-specific/linux/minimal-bootstrap/musl/1.1.nix rename to pkgs/os-specific/linux/minimal-bootstrap/musl/tcc.nix index 6a072f100ec1..942399975fe8 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/musl/1.1.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/musl/tcc.nix @@ -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 \