From 477a60351c2a234cce5d6b6df9dfbf3b1ab29dc4 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Sun, 17 Sep 2023 22:21:18 -0700 Subject: [PATCH 01/26] minimal-bootstrap.gnused: replace glibc with musl --- .../linux/minimal-bootstrap/default.nix | 7 +- .../linux/minimal-bootstrap/gnused/common.nix | 12 ++++ .../minimal-bootstrap/gnused/default.nix | 72 ++++++------------- .../linux/minimal-bootstrap/gnused/mes.nix | 59 +++++++++++++++ 4 files changed, 94 insertions(+), 56 deletions(-) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/gnused/common.nix create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/gnused/mes.nix diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 44cf8bfdb7b8..7387d3eaa910 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -108,14 +108,13 @@ lib.makeScope gnused = callPackage ./gnused { bash = bash_2_05; - gcc = gcc2; - glibc = glibc22; + tinycc = tinycc-musl; + musl = musl11; gnused = gnused-mes; }; - gnused-mes = callPackage ./gnused { + gnused-mes = callPackage ./gnused/mes.nix { bash = bash_2_05; tinycc = tinycc-mes; - mesBootstrap = true; }; gnutar = callPackage ./gnutar { diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnused/common.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnused/common.nix new file mode 100644 index 000000000000..658f05923ac3 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnused/common.nix @@ -0,0 +1,12 @@ +{ lib }: + +{ + meta = with lib; { + description = "GNU sed, a batch stream editor"; + homepage = "https://www.gnu.org/software/sed"; + license = licenses.gpl3Plus; + maintainers = teams.minimal-bootstrap.members; + mainProgram = "sed"; + platforms = platforms.unix; + }; +} diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix index b5647b96ee3c..ee237f016f5b 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix @@ -4,41 +4,35 @@ , fetchurl , bash , gnumake -, mesBootstrap ? false, tinycc ? null -, gcc ? null, glibc ? null, binutils ? null, gnused ? null, linux-headers, gnugrep +, tinycc +, musl +, gnused +, gnugrep +, gnutar +, gzip }: -assert mesBootstrap -> tinycc != null; -assert !mesBootstrap -> gcc != null && glibc != null && binutils != null && gnused != null; + let - pname = "gnused" + lib.optionalString mesBootstrap "-mes"; - # last version that can be compiled with mes-libc - version = "4.0.9"; + inherit (import ./common.nix { inherit lib; }) meta; + pname = "gnused"; + # last version that can be bootstrapped with our slightly buggy gnused-mes + version = "4.2"; src = fetchurl { url = "mirror://gnu/sed/sed-${version}.tar.gz"; - sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3"; - }; - - # Thanks to the live-bootstrap project! - # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem - makefile = fetchurl { - url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk"; - sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya"; + hash = "sha256-20XNY/0BDmUFN9ZdXfznaJplJ0UjZgbl5ceCk3Jn2YM="; }; in bash.runCommand "${pname}-${version}" { - inherit pname version; + inherit pname version meta; nativeBuildInputs = [ gnumake - ] ++ lib.optionals mesBootstrap [ tinycc.compiler - ] ++ lib.optionals (!mesBootstrap) [ - gcc - glibc - binutils gnused gnugrep + gnutar + gzip ]; passthru.tests.get-version = result: @@ -46,51 +40,25 @@ bash.runCommand "${pname}-${version}" { ${result}/bin/sed --version mkdir ''${out} ''; - - meta = with lib; { - description = "GNU sed, a batch stream editor"; - homepage = "https://www.gnu.org/software/sed"; - license = licenses.gpl3Plus; - maintainers = teams.minimal-bootstrap.members; - mainProgram = "sed"; - platforms = platforms.unix; - }; } ('' # Unpack - ungz --file ${src} --output sed.tar - untar --file sed.tar - rm sed.tar + tar xzf ${src} cd sed-${version} -'' + lib.optionalString mesBootstrap '' # Configure - cp ${makefile} Makefile - catm config.h - - # Build - make \ - CC="tcc -B ${tinycc.libs}/lib" \ - LIBC=mes - -'' + lib.optionalString (!mesBootstrap) '' - # Configure - export CC="gcc -I${glibc}/include -I${linux-headers}/include" - export LIBRARY_PATH="${glibc}/lib" - export LIBS="-lc -lnss_files -lnss_dns -lresolv" - chmod +x configure + export CC="tcc -B ${musl}/lib" + export LD=tcc ./configure \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-shared \ --disable-nls \ --disable-dependency-tracking \ - --without-included-regex \ --prefix=$out # Build - make + make AR="tcc -ar" -'' + '' # Install - make install PREFIX=$out + make install '') diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnused/mes.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnused/mes.nix new file mode 100644 index 000000000000..031b5b5f0db0 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnused/mes.nix @@ -0,0 +1,59 @@ +{ lib +, buildPlatform +, hostPlatform +, fetchurl +, bash +, gnumake +, tinycc +}: + +let + inherit (import ./common.nix { inherit lib; }) meta; + pname = "gnused-mes"; + # last version that can be compiled with mes-libc + version = "4.0.9"; + + src = fetchurl { + url = "mirror://gnu/sed/sed-${version}.tar.gz"; + sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3"; + }; + + # Thanks to the live-bootstrap project! + # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem + makefile = fetchurl { + url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk"; + sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya"; + }; +in +bash.runCommand "${pname}-${version}" { + inherit pname version meta; + + nativeBuildInputs = [ + gnumake + tinycc.compiler + ]; + + passthru.tests.get-version = result: + bash.runCommand "${pname}-get-version-${version}" {} '' + ${result}/bin/sed --version + mkdir ''${out} + ''; +} ('' + # Unpack + ungz --file ${src} --output sed.tar + untar --file sed.tar + rm sed.tar + cd sed-${version} + + # Configure + cp ${makefile} Makefile + catm config.h + + # Build + make \ + CC="tcc -B ${tinycc.libs}/lib" \ + LIBC=mes + + # Install + make install PREFIX=$out +'') From 665d36050736d95904c689940e64aea00350b887 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 18 Sep 2023 19:13:01 -0700 Subject: [PATCH 02/26] minimal-bootstrap.binutils: add musl version --- .../minimal-bootstrap/binutils/default.nix | 36 +++--- .../linux/minimal-bootstrap/binutils/mes.nix | 105 ++++++++++++++++ .../linux/minimal-bootstrap/binutils/musl.nix | 114 ++++++++++++++++++ .../linux/minimal-bootstrap/default.nix | 14 ++- 4 files changed, 244 insertions(+), 25 deletions(-) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/binutils/mes.nix create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/binutils/musl.nix diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix index f386ebbaf8e9..75a1512ff09e 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix @@ -5,18 +5,19 @@ , bash , gnumake , gnupatch +, gnused , gnugrep , gnutar , gawk , bzip2 -, sed -, mesBootstrap ? false, tinycc ? null -, gcc ? null, glibc ? null, binutils ? null, linux-headers +, gcc +, glibc +, binutilsBoot +, linux-headers }: -assert mesBootstrap -> tinycc != null; -assert !mesBootstrap -> gcc != null && glibc != null && binutils != null; + let - pname = "binutils" + lib.optionalString mesBootstrap "-mes"; + pname = "binutils"; version = "2.20.1"; rev = "a"; @@ -60,15 +61,16 @@ bash.runCommand "${pname}-${version}" { inherit pname version; nativeBuildInputs = [ - (if mesBootstrap then tinycc.compiler else gcc) + gcc gnumake gnupatch + gnused gnugrep gnutar gawk bzip2 - sed - ] ++ lib.optional (!mesBootstrap) binutils; + binutilsBoot + ]; passthru.tests.get-version = result: bash.runCommand "${pname}-get-version-${version}" {} '' @@ -95,17 +97,11 @@ bash.runCommand "${pname}-${version}" { ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} # Configure - ${if mesBootstrap then '' - export CC="tcc -B ${tinycc.libs}/lib -D __GLIBC_MINOR__=6 -D MES_BOOTSTRAP=1" - export AR="tcc -ar" - '' else '' - export CC="gcc -B ${glibc}/lib -I${glibc}/include -I${linux-headers}/include" - export CPP="gcc -E -I${glibc}/include -I${linux-headers}/include" - export AR="ar" - export LIBRARY_PATH="${glibc}/lib" - export LIBS="-lc -lnss_files -lnss_dns -lresolv" - ''} - export SED=sed + export CC="gcc -B ${glibc}/lib -I${glibc}/include -I${linux-headers}/include" + export CPP="gcc -E -I${glibc}/include -I${linux-headers}/include" + export AR="ar" + export LIBRARY_PATH="${glibc}/lib" + export LIBS="-lc -lnss_files -lnss_dns -lresolv" bash ./configure ${lib.concatStringsSep " " configureFlags} # Build diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/mes.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/mes.nix new file mode 100644 index 000000000000..018b4d78a4ba --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/mes.nix @@ -0,0 +1,105 @@ +{ lib +, buildPlatform +, hostPlatform +, fetchurl +, bash +, gnumake +, gnupatch +, gnused +, gnugrep +, gnutar +, gawk +, bzip2 +, tinycc +}: + +let + pname = "binutils-mes"; + version = "2.20.1"; + rev = "a"; + + src = fetchurl { + url = "mirror://gnu/binutils/binutils-${version}${rev}.tar.bz2"; + sha256 = "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi"; + }; + + patches = [ + # Enables building binutils using TCC and Mes C Library + (fetchurl { + url = "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/patches/binutils-boot-2.20.1a.patch?id=50249cab3a98839ade2433456fe618acc6f804a5"; + sha256 = "086sf6an2k56axvs4jlky5n3hs2l3rq8zq5d37h0b69cdyh7igpn"; + }) + + # Make binutils output deterministic by default. + ./deterministic.patch + ]; + + configureFlags = [ + "--prefix=${placeholder "out"}" + "--build=${buildPlatform.config}" + "--host=${hostPlatform.config}" + "--disable-nls" + "--disable-shared" + "--disable-werror" + "--with-sysroot=/" + + # Turn on --enable-new-dtags by default to make the linker set + # RUNPATH instead of RPATH on binaries. This is important because + # RUNPATH can be overridden using LD_LIBRARY_PATH at runtime. + "--enable-new-dtags" + + # By default binutils searches $libdir for libraries. This brings in + # libbfd and libopcodes into a default visibility. Drop default lib + # path to force users to declare their use of these libraries. + "--with-lib-path=:" + ]; +in +bash.runCommand "${pname}-${version}" { + inherit pname version; + + nativeBuildInputs = [ + tinycc.compiler + gnumake + gnupatch + gnused + gnugrep + gnutar + gawk + bzip2 + ]; + + passthru.tests.get-version = result: + bash.runCommand "${pname}-get-version-${version}" {} '' + ${result}/bin/ld --version + mkdir $out + ''; + + meta = with lib; { + description = "Tools for manipulating binaries (linker, assembler, etc.)"; + homepage = "https://www.gnu.org/software/binutils"; + license = licenses.gpl3Plus; + maintainers = teams.minimal-bootstrap.members; + platforms = platforms.unix; + }; +} '' + # Unpack + cp ${src} binutils.tar.bz2 + bunzip2 binutils.tar.bz2 + tar xf binutils.tar + rm binutils.tar + cd binutils-${version} + + # Patch + ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} + + # Configure + export CC="tcc -B ${tinycc.libs}/lib -D __GLIBC_MINOR__=6 -D MES_BOOTSTRAP=1" + export AR="tcc -ar" + bash ./configure ${lib.concatStringsSep " " configureFlags} + + # Build + make + + # Install + make install +'' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/musl.nix new file mode 100644 index 000000000000..8dfd6e76027f --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/musl.nix @@ -0,0 +1,114 @@ +{ lib +, buildPlatform +, hostPlatform +, fetchurl +, bash +, coreutils +, gnumake +, gnupatch +, gnused +, gnugrep +, gawk +, diffutils +, gnutar +, xz +, tinycc +, musl +}: + +let + pname = "binutils-musl"; + version = "2.41"; + + src = fetchurl { + url = "mirror://gnu/binutils/binutils-${version}.tar.xz"; + hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA="; + }; + + patches = [ + # Make binutils output deterministic by default. + ./deterministic.patch + ]; + + configureFlags = [ + "--prefix=${placeholder "out"}" + "--build=${buildPlatform.config}" + "--host=${hostPlatform.config}" + "--with-sysroot=/" + "--enable-deterministic-archives" + # depends on bison + "--disable-gprofng" + + # Turn on --enable-new-dtags by default to make the linker set + # RUNPATH instead of RPATH on binaries. This is important because + # RUNPATH can be overridden using LD_LIBRARY_PATH at runtime. + "--enable-new-dtags" + + # By default binutils searches $libdir for libraries. This brings in + # libbfd and libopcodes into a default visibility. Drop default lib + # path to force users to declare their use of these libraries. + "--with-lib-path=:" + ]; +in +bash.runCommand "${pname}-${version}" { + inherit pname version; + + nativeBuildInputs = [ + tinycc.compiler + gnumake + gnupatch + gnused + gnugrep + gawk + diffutils + gnutar + xz + ]; + + passthru.tests.get-version = result: + bash.runCommand "${pname}-get-version-${version}" {} '' + ${result}/bin/ld --version + mkdir $out + ''; + + meta = with lib; { + description = "Tools for manipulating binaries (linker, assembler, etc.)"; + homepage = "https://www.gnu.org/software/binutils"; + license = licenses.gpl3Plus; + maintainers = teams.minimal-bootstrap.members; + platforms = platforms.unix; + }; +} '' + # Unpack + cp ${src} binutils.tar.xz + unxz binutils.tar.xz + tar xf binutils.tar + rm binutils.tar + cd binutils-${version} + + # Patch + ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} + sed -i 's|/bin/sh|${bash}/bin/bash|' \ + missing install-sh mkinstalldirs + # see libtool's 74c8993c178a1386ea5e2363a01d919738402f30 + sed -i 's/| \$NL2SP/| sort | $NL2SP/' ltmain.sh + # alias makeinfo to true + mkdir aliases + ln -s ${coreutils}/bin/true aliases/makeinfo + export PATH="$(pwd)/aliases/:$PATH" + + # Configure + export CC="tcc -B ${musl}/lib" + export AR="tcc -ar" + export lt_cv_sys_max_cmd_len=32768 + export CFLAGS="-D__LITTLE_ENDIAN__=1" + bash ./configure ${lib.concatStringsSep " " configureFlags} + + # Build + make all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof + make all-ld # race condition on ld/.deps/ldwrite.Po, serialize + make + + # Install + make install +'' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 7387d3eaa910..b7d05eab8aef 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -25,17 +25,20 @@ lib.makeScope binutils = callPackage ./binutils { bash = bash_2_05; gcc = gcc2; - binutils = binutils-mes; + binutilsBoot = binutils-mes; glibc = glibc22; - sed = heirloom.sed; gawk = gawk-mes; }; - binutils-mes = callPackage ./binutils { + binutils-mes = callPackage ./binutils/mes.nix { bash = bash_2_05; tinycc = tinycc-mes; - sed = heirloom.sed; gawk = gawk-mes; - mesBootstrap = true; + }; + binutils-musl = callPackage ./binutils/musl.nix { + bash = bash_2_05; + tinycc = tinycc-musl; + musl = musl11; + gawk = gawk-mes; }; bzip2 = callPackage ./bzip2 { @@ -178,6 +181,7 @@ lib.makeScope echo ${bash_2_05.tests.get-version} echo ${binutils.tests.get-version} echo ${binutils-mes.tests.get-version} + echo ${binutils-musl.tests.get-version} echo ${bzip2.tests.get-version} echo ${diffutils.tests.get-version} echo ${findutils.tests.get-version} From 20e65d89e60d3667c529cbfb73772220046d18c1 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 18 Sep 2023 19:34:49 -0700 Subject: [PATCH 03/26] minimal-bootstrap.diffutils: use musl --- .../linux/minimal-bootstrap/default.nix | 4 +-- .../minimal-bootstrap/diffutils/default.nix | 32 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index b7d05eab8aef..48e3d4d21d3c 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -50,8 +50,8 @@ lib.makeScope diffutils = callPackage ./diffutils { bash = bash_2_05; - gcc = gcc2; - glibc = glibc22; + tinycc = tinycc-musl; + musl = musl11; gawk = gawk-mes; }; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix index 7545a52524a3..42db4a6640da 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix @@ -3,38 +3,36 @@ , hostPlatform , fetchurl , bash -, gcc -, glibc -, binutils -, linux-headers +, tinycc +, musl , gnumake , gnugrep , gnused , gawk , gnutar -, gzip +, xz }: let pname = "diffutils"; - version = "2.8.1"; + # last version that can be built by tinycc-musl 0.9.27 + version = "3.8"; src = fetchurl { - url = "mirror://gnu/diffutils/diffutils-${version}.tar.gz"; - sha256 = "0nizs9r76aiymzasmj1jngl7s71jfzl9xfziigcls8k9n141f065"; + url = "mirror://gnu/diffutils/diffutils-${version}.tar.xz"; + hash = "sha256-pr3X0bMSZtEcT03mwbdI1GB6sCMa9RiPwlM9CuJDj+w="; }; in bash.runCommand "${pname}-${version}" { inherit pname version; nativeBuildInputs = [ - gcc - binutils + tinycc.compiler gnumake gnused gnugrep gawk gnutar - gzip + xz ]; passthru.tests.get-version = result: @@ -52,20 +50,22 @@ bash.runCommand "${pname}-${version}" { }; } '' # Unpack - tar xzf ${src} + cp ${src} diffutils.tar.xz + unxz diffutils.tar.xz + tar xf diffutils.tar + rm diffutils.tar cd diffutils-${version} # Configure - export C_INCLUDE_PATH="${glibc}/include:${linux-headers}/include" - export LIBRARY_PATH="${glibc}/lib" - export LIBS="-lc -lnss_files -lnss_dns -lresolv" + export CC="tcc -B ${musl}/lib" + export LD=tcc bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} # Build - make + make AR="tcc -ar" # Install make install From 60ae6bf75109fb902dc67f45488f5c2ec13eaf8e Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 18 Sep 2023 21:08:25 -0700 Subject: [PATCH 04/26] minimal-bootstrap.binutils: remove binutils-mes and binutils-glibc --- .../minimal-bootstrap/binutils/default.nix | 63 +++++----- .../linux/minimal-bootstrap/binutils/mes.nix | 105 ---------------- .../linux/minimal-bootstrap/binutils/musl.nix | 114 ------------------ .../linux/minimal-bootstrap/default.nix | 16 --- .../linux/minimal-bootstrap/glibc/default.nix | 5 +- 5 files changed, 35 insertions(+), 268 deletions(-) delete mode 100644 pkgs/os-specific/linux/minimal-bootstrap/binutils/mes.nix delete mode 100644 pkgs/os-specific/linux/minimal-bootstrap/binutils/musl.nix diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix index 75a1512ff09e..fedb6fd22638 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix @@ -3,36 +3,30 @@ , hostPlatform , fetchurl , bash +, coreutils , gnumake , gnupatch , gnused , gnugrep -, gnutar , gawk -, bzip2 -, gcc -, glibc -, binutilsBoot -, linux-headers +, diffutils +, gnutar +, xz +, tinycc +, musl }: let + # Based on https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a1-static-binutils.nix pname = "binutils"; - version = "2.20.1"; - rev = "a"; + version = "2.41"; src = fetchurl { - url = "mirror://gnu/binutils/binutils-${version}${rev}.tar.bz2"; - sha256 = "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi"; + url = "mirror://gnu/binutils/binutils-${version}.tar.xz"; + hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA="; }; patches = [ - # Enables building binutils using TCC and Mes C Library - (fetchurl { - url = "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/patches/binutils-boot-2.20.1a.patch?id=50249cab3a98839ade2433456fe618acc6f804a5"; - sha256 = "086sf6an2k56axvs4jlky5n3hs2l3rq8zq5d37h0b69cdyh7igpn"; - }) - # Make binutils output deterministic by default. ./deterministic.patch ]; @@ -41,10 +35,10 @@ let "--prefix=${placeholder "out"}" "--build=${buildPlatform.config}" "--host=${hostPlatform.config}" - "--disable-nls" - "--disable-shared" - "--disable-werror" "--with-sysroot=/" + "--enable-deterministic-archives" + # depends on bison + "--disable-gprofng" # Turn on --enable-new-dtags by default to make the linker set # RUNPATH instead of RPATH on binaries. This is important because @@ -61,15 +55,15 @@ bash.runCommand "${pname}-${version}" { inherit pname version; nativeBuildInputs = [ - gcc + tinycc.compiler gnumake gnupatch gnused gnugrep - gnutar gawk - bzip2 - binutilsBoot + diffutils + gnutar + xz ]; passthru.tests.get-version = result: @@ -87,24 +81,33 @@ bash.runCommand "${pname}-${version}" { }; } '' # Unpack - cp ${src} binutils.tar.bz2 - bunzip2 binutils.tar.bz2 + cp ${src} binutils.tar.xz + unxz binutils.tar.xz tar xf binutils.tar rm binutils.tar cd binutils-${version} # Patch ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} + sed -i 's|/bin/sh|${bash}/bin/bash|' \ + missing install-sh mkinstalldirs + # see libtool's 74c8993c178a1386ea5e2363a01d919738402f30 + sed -i 's/| \$NL2SP/| sort | $NL2SP/' ltmain.sh + # alias makeinfo to true + mkdir aliases + ln -s ${coreutils}/bin/true aliases/makeinfo + export PATH="$(pwd)/aliases/:$PATH" # Configure - export CC="gcc -B ${glibc}/lib -I${glibc}/include -I${linux-headers}/include" - export CPP="gcc -E -I${glibc}/include -I${linux-headers}/include" - export AR="ar" - export LIBRARY_PATH="${glibc}/lib" - export LIBS="-lc -lnss_files -lnss_dns -lresolv" + export CC="tcc -B ${musl}/lib" + export AR="tcc -ar" + export lt_cv_sys_max_cmd_len=32768 + export CFLAGS="-D__LITTLE_ENDIAN__=1" bash ./configure ${lib.concatStringsSep " " configureFlags} # Build + make all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof + make all-ld # race condition on ld/.deps/ldwrite.Po, serialize make # Install diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/mes.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/mes.nix deleted file mode 100644 index 018b4d78a4ba..000000000000 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/mes.nix +++ /dev/null @@ -1,105 +0,0 @@ -{ lib -, buildPlatform -, hostPlatform -, fetchurl -, bash -, gnumake -, gnupatch -, gnused -, gnugrep -, gnutar -, gawk -, bzip2 -, tinycc -}: - -let - pname = "binutils-mes"; - version = "2.20.1"; - rev = "a"; - - src = fetchurl { - url = "mirror://gnu/binutils/binutils-${version}${rev}.tar.bz2"; - sha256 = "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi"; - }; - - patches = [ - # Enables building binutils using TCC and Mes C Library - (fetchurl { - url = "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/patches/binutils-boot-2.20.1a.patch?id=50249cab3a98839ade2433456fe618acc6f804a5"; - sha256 = "086sf6an2k56axvs4jlky5n3hs2l3rq8zq5d37h0b69cdyh7igpn"; - }) - - # Make binutils output deterministic by default. - ./deterministic.patch - ]; - - configureFlags = [ - "--prefix=${placeholder "out"}" - "--build=${buildPlatform.config}" - "--host=${hostPlatform.config}" - "--disable-nls" - "--disable-shared" - "--disable-werror" - "--with-sysroot=/" - - # Turn on --enable-new-dtags by default to make the linker set - # RUNPATH instead of RPATH on binaries. This is important because - # RUNPATH can be overridden using LD_LIBRARY_PATH at runtime. - "--enable-new-dtags" - - # By default binutils searches $libdir for libraries. This brings in - # libbfd and libopcodes into a default visibility. Drop default lib - # path to force users to declare their use of these libraries. - "--with-lib-path=:" - ]; -in -bash.runCommand "${pname}-${version}" { - inherit pname version; - - nativeBuildInputs = [ - tinycc.compiler - gnumake - gnupatch - gnused - gnugrep - gnutar - gawk - bzip2 - ]; - - passthru.tests.get-version = result: - bash.runCommand "${pname}-get-version-${version}" {} '' - ${result}/bin/ld --version - mkdir $out - ''; - - meta = with lib; { - description = "Tools for manipulating binaries (linker, assembler, etc.)"; - homepage = "https://www.gnu.org/software/binutils"; - license = licenses.gpl3Plus; - maintainers = teams.minimal-bootstrap.members; - platforms = platforms.unix; - }; -} '' - # Unpack - cp ${src} binutils.tar.bz2 - bunzip2 binutils.tar.bz2 - tar xf binutils.tar - rm binutils.tar - cd binutils-${version} - - # Patch - ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} - - # Configure - export CC="tcc -B ${tinycc.libs}/lib -D __GLIBC_MINOR__=6 -D MES_BOOTSTRAP=1" - export AR="tcc -ar" - bash ./configure ${lib.concatStringsSep " " configureFlags} - - # Build - make - - # Install - make install -'' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/musl.nix deleted file mode 100644 index 8dfd6e76027f..000000000000 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/musl.nix +++ /dev/null @@ -1,114 +0,0 @@ -{ lib -, buildPlatform -, hostPlatform -, fetchurl -, bash -, coreutils -, gnumake -, gnupatch -, gnused -, gnugrep -, gawk -, diffutils -, gnutar -, xz -, tinycc -, musl -}: - -let - pname = "binutils-musl"; - version = "2.41"; - - src = fetchurl { - url = "mirror://gnu/binutils/binutils-${version}.tar.xz"; - hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA="; - }; - - patches = [ - # Make binutils output deterministic by default. - ./deterministic.patch - ]; - - configureFlags = [ - "--prefix=${placeholder "out"}" - "--build=${buildPlatform.config}" - "--host=${hostPlatform.config}" - "--with-sysroot=/" - "--enable-deterministic-archives" - # depends on bison - "--disable-gprofng" - - # Turn on --enable-new-dtags by default to make the linker set - # RUNPATH instead of RPATH on binaries. This is important because - # RUNPATH can be overridden using LD_LIBRARY_PATH at runtime. - "--enable-new-dtags" - - # By default binutils searches $libdir for libraries. This brings in - # libbfd and libopcodes into a default visibility. Drop default lib - # path to force users to declare their use of these libraries. - "--with-lib-path=:" - ]; -in -bash.runCommand "${pname}-${version}" { - inherit pname version; - - nativeBuildInputs = [ - tinycc.compiler - gnumake - gnupatch - gnused - gnugrep - gawk - diffutils - gnutar - xz - ]; - - passthru.tests.get-version = result: - bash.runCommand "${pname}-get-version-${version}" {} '' - ${result}/bin/ld --version - mkdir $out - ''; - - meta = with lib; { - description = "Tools for manipulating binaries (linker, assembler, etc.)"; - homepage = "https://www.gnu.org/software/binutils"; - license = licenses.gpl3Plus; - maintainers = teams.minimal-bootstrap.members; - platforms = platforms.unix; - }; -} '' - # Unpack - cp ${src} binutils.tar.xz - unxz binutils.tar.xz - tar xf binutils.tar - rm binutils.tar - cd binutils-${version} - - # Patch - ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} - sed -i 's|/bin/sh|${bash}/bin/bash|' \ - missing install-sh mkinstalldirs - # see libtool's 74c8993c178a1386ea5e2363a01d919738402f30 - sed -i 's/| \$NL2SP/| sort | $NL2SP/' ltmain.sh - # alias makeinfo to true - mkdir aliases - ln -s ${coreutils}/bin/true aliases/makeinfo - export PATH="$(pwd)/aliases/:$PATH" - - # Configure - export CC="tcc -B ${musl}/lib" - export AR="tcc -ar" - export lt_cv_sys_max_cmd_len=32768 - export CFLAGS="-D__LITTLE_ENDIAN__=1" - bash ./configure ${lib.concatStringsSep " " configureFlags} - - # Build - make all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof - make all-ld # race condition on ld/.deps/ldwrite.Po, serialize - make - - # Install - make install -'' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 48e3d4d21d3c..2d3eb43ddc5b 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -23,18 +23,6 @@ lib.makeScope }; binutils = callPackage ./binutils { - bash = bash_2_05; - gcc = gcc2; - binutilsBoot = binutils-mes; - glibc = glibc22; - gawk = gawk-mes; - }; - binutils-mes = callPackage ./binutils/mes.nix { - bash = bash_2_05; - tinycc = tinycc-mes; - gawk = gawk-mes; - }; - binutils-musl = callPackage ./binutils/musl.nix { bash = bash_2_05; tinycc = tinycc-musl; musl = musl11; @@ -78,13 +66,11 @@ lib.makeScope gcc2 = callPackage ./gcc/2.nix { bash = bash_2_05; gcc = gcc2-mes; - binutils = binutils-mes; glibc = glibc22; }; gcc2-mes = callPackage ./gcc/2.nix { bash = bash_2_05; tinycc = tinycc-mes; - binutils = binutils-mes; mesBootstrap = true; }; @@ -180,8 +166,6 @@ lib.makeScope echo ${bash.tests.get-version} echo ${bash_2_05.tests.get-version} echo ${binutils.tests.get-version} - echo ${binutils-mes.tests.get-version} - echo ${binutils-musl.tests.get-version} echo ${bzip2.tests.get-version} echo ${diffutils.tests.get-version} echo ${findutils.tests.get-version} diff --git a/pkgs/os-specific/linux/minimal-bootstrap/glibc/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/glibc/default.nix index 5c4ff386add5..bc6800999247 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/glibc/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/glibc/default.nix @@ -12,13 +12,13 @@ , gzip , gawk , heirloom -, binutils-mes +, binutils , linux-headers }: let pname = "glibc"; - buildGlibc = { version, src, patches, configureFlags, gcc, binutils, CC, CPP }: + buildGlibc = { version, src, patches, configureFlags, gcc, CC, CPP }: bash.runCommand "${pname}-${version}" { inherit pname version; @@ -114,7 +114,6 @@ in ]; gcc = gcc2-mes; - binutils = binutils-mes; CC = "gcc -D MES_BOOTSTRAP=1 -D BOOTSTRAP_GLIBC=1 -L $(pwd)"; CPP = "gcc -E -D MES_BOOTSTRAP=1 -D BOOTSTRAP_GLIBC=1"; }; From 4166e1fded92631a42efd5785a40fb83a9186d2a Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 18 Sep 2023 21:58:40 -0700 Subject: [PATCH 05/26] minimal-bootstrap.gawk: build with musl --- .../linux/minimal-bootstrap/default.nix | 11 ++------ .../linux/minimal-bootstrap/gawk/default.nix | 26 +++++++------------ 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 2d3eb43ddc5b..9d14a60f74f9 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -19,14 +19,12 @@ lib.makeScope bootBash = bash_2_05; gcc = gcc2; glibc = glibc22; - gawk = gawk-mes; }; binutils = callPackage ./binutils { bash = bash_2_05; tinycc = tinycc-musl; musl = musl11; - gawk = gawk-mes; }; bzip2 = callPackage ./bzip2 { @@ -40,14 +38,12 @@ lib.makeScope bash = bash_2_05; tinycc = tinycc-musl; musl = musl11; - gawk = gawk-mes; }; findutils = callPackage ./findutils { bash = bash_2_05; gcc = gcc2; glibc = glibc22; - gawk = gawk-mes; }; gawk-mes = callPackage ./gawk/mes.nix { @@ -58,8 +54,8 @@ lib.makeScope gawk = callPackage ./gawk { bash = bash_2_05; - gcc = gcc2; - glibc = glibc22; + tinycc = tinycc-musl; + musl = musl11; bootGawk = gawk-mes; }; @@ -77,13 +73,11 @@ lib.makeScope gcc46 = callPackage ./gcc/4.6.nix { gcc = gcc2; glibc = glibc22; - gawk = gawk-mes; }; inherit (callPackage ./glibc { bash = bash_2_05; gnused = gnused-mes; - gawk = gawk-mes; }) glibc22; gnugrep = callPackage ./gnugrep { @@ -156,7 +150,6 @@ lib.makeScope xz = callPackage ./xz { bash = bash_2_05; tinycc = tinycc-mes; - gawk = gawk-mes; inherit (heirloom) sed; }; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix index 935414f21760..83a76c73b4ae 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix @@ -3,10 +3,8 @@ , hostPlatform , fetchurl , bash -, gcc -, glibc -, binutils -, linux-headers +, tinycc +, musl , gnumake , gnugrep , gnused @@ -17,21 +15,18 @@ let inherit (import ./common.nix { inherit lib; }) meta; pname = "gawk"; - # >= 4.2.0 fails to cleanly build. may be worth investigating in the future. - # for now this version is sufficient to build glibc 2.16 - version = "4.1.4"; + version = "5.2.0"; src = fetchurl { url = "mirror://gnu/gawk/gawk-${version}.tar.gz"; - sha256 = "0dadjkpyyizmyd0l098qps8lb39r0vrz3xl3hwz2cmjs5c70h0wc"; + hash = "sha256-71r0RJywJp+vOvJL9MAic9RV8HQb88UPht3AkzLWz1Y="; }; in bash.runCommand "${pname}-${version}" { inherit pname version meta; nativeBuildInputs = [ - gcc - binutils + tinycc.compiler gnumake gnused gnugrep @@ -51,18 +46,17 @@ bash.runCommand "${pname}-${version}" { cd gawk-${version} # Configure - export C_INCLUDE_PATH="${glibc}/include:${linux-headers}/include" - export LIBRARY_PATH="${glibc}/lib" - export LIBS="-lc -lnss_files -lnss_dns -lresolv" + export CC="tcc -B ${musl}/lib" + export AR="tcc -ar" + export LD=tcc bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} # Build - make gawk + make # Install - install -D gawk $out/bin/gawk - ln -s gawk $out/bin/awk + make install '' From 3fd09b754739423a1ecf9027ce460aa9fca1ae37 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 18 Sep 2023 21:59:03 -0700 Subject: [PATCH 06/26] minimal-bootstrap.xz: build with musl --- .../linux/minimal-bootstrap/default.nix | 4 +-- .../linux/minimal-bootstrap/xz/default.nix | 35 ++++++++----------- .../linux/minimal-bootstrap/xz/stubs.h | 25 ------------- 3 files changed, 16 insertions(+), 48 deletions(-) delete mode 100644 pkgs/os-specific/linux/minimal-bootstrap/xz/stubs.h diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 9d14a60f74f9..a5c67db65902 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -149,8 +149,8 @@ lib.makeScope xz = callPackage ./xz { bash = bash_2_05; - tinycc = tinycc-mes; - inherit (heirloom) sed; + tinycc = tinycc-musl; + musl = musl11; }; inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix index 92cb240c5f16..32c5b3999c1b 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix @@ -4,19 +4,21 @@ , fetchurl , bash , tinycc +, musl , gnumake +, gnused , gnugrep , gawk -, sed +, gnutar +, gzip }: let pname = "xz"; - # >=5.2 uses poll.h, unsupported by meslibc - version = "5.0.8"; + version = "5.4.3"; src = fetchurl { - url = "https://tukaani.org/xz/xz-${version}.tar.bz2"; - sha256 = "1nkb68dyrf16xwyqichcy1vhgbfg20dxz459rcsdx85h1gczk1i2"; + url = "https://tukaani.org/xz/xz-${version}.tar.gz"; + hash = "sha256-HDguC8Lk4K9YOYqQPdYv/35RAXHS3keh6+BtFSjpt+k="; }; in bash.runCommand "${pname}-${version}" { @@ -25,9 +27,11 @@ bash.runCommand "${pname}-${version}" { nativeBuildInputs = [ tinycc.compiler gnumake + gnused gnugrep gawk - sed + gnutar + gzip ]; passthru.tests.get-version = result: @@ -45,33 +49,22 @@ bash.runCommand "${pname}-${version}" { }; } '' # Unpack - unbz2 --file ${src} --output xz.tar - untar --file xz.tar - rm xz.tar + tar xzf ${src} cd xz-${version} # Configure - export CC="tcc -B ${tinycc.libs}/lib -include${./stubs.h}" - export CPP="tcc -E" - export LD=tcc + export CC="tcc -B ${musl}/lib" export AR="tcc -ar" - export SED=sed - export ac_cv_prog_cc_c99= - export ac_cv_header_fcntl_h=yes - export ac_cv_header_limits_h=yes - export ac_cv_header_sys_time_h=yes - export ac_cv_func_utime=no + export LD=tcc bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-shared \ - --disable-nls \ - --disable-threads \ --disable-assembler # Build - make all + make # Install make install diff --git a/pkgs/os-specific/linux/minimal-bootstrap/xz/stubs.h b/pkgs/os-specific/linux/minimal-bootstrap/xz/stubs.h deleted file mode 100644 index cbf6f823299e..000000000000 --- a/pkgs/os-specific/linux/minimal-bootstrap/xz/stubs.h +++ /dev/null @@ -1,25 +0,0 @@ -#define sig_atomic_t int - -#define SSIZE_MAX LONG_MAX - -#define O_NOCTTY 0400 -#define O_NONBLOCK 04000 - -#define S_ISVTX 01000 -#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) - -int fchmod (int fd, int mode) -{ - return 0; -} - -int fchown (int fd, int owner, int group) -{ - return 0; -} - -#include -int sigfillset (sigset_t * set) -{ - return 0; -} From 114d57a054671ce8a1c9aba807c4bd24329f7923 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 18 Sep 2023 22:21:16 -0700 Subject: [PATCH 07/26] minimal-bootstrap.findutils: rebuild with musl --- .../linux/minimal-bootstrap/default.nix | 4 +-- .../minimal-bootstrap/findutils/default.nix | 34 +++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index a5c67db65902..eb3d73fcdd41 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -42,8 +42,8 @@ lib.makeScope findutils = callPackage ./findutils { bash = bash_2_05; - gcc = gcc2; - glibc = glibc22; + tinycc = tinycc-musl; + musl = musl11; }; gawk-mes = callPackage ./gawk/mes.nix { diff --git a/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix index cf26abd21383..bbdc4198d703 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix @@ -3,38 +3,35 @@ , hostPlatform , fetchurl , bash -, gcc -, glibc -, binutils -, linux-headers +, tinycc +, musl , gnumake , gnugrep , gnused , gawk , gnutar -, gzip +, xz }: let pname = "findutils"; - version = "4.4.2"; + version = "4.9.0"; src = fetchurl { - url = "mirror://gnu/findutils/findutils-${version}.tar.gz"; - sha256 = "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks3"; + url = "mirror://gnu/findutils/findutils-${version}.tar.xz"; + hash = "sha256-or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4="; }; in bash.runCommand "${pname}-${version}" { inherit pname version; nativeBuildInputs = [ - gcc - binutils + tinycc.compiler gnumake gnused gnugrep gawk gnutar - gzip + xz ]; passthru.tests.get-version = result: @@ -52,13 +49,20 @@ bash.runCommand "${pname}-${version}" { }; } '' # Unpack - tar xzf ${src} + cp ${src} findutils.tar.xz + unxz findutils.tar.xz + tar xf findutils.tar + rm findutils.tar cd findutils-${version} + # Patch + # configure fails to accurately detect PATH_MAX support + sed -i 's/chdir_long/chdir/' gl/lib/save-cwd.c + # Configure - export C_INCLUDE_PATH="${glibc}/include:${linux-headers}/include" - export LIBRARY_PATH="${glibc}/lib" - export LIBS="-lc -lnss_files -lnss_dns -lresolv" + export CC="tcc -B ${musl}/lib" + export AR="tcc -ar" + export LD=tcc bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ From 109ba06491384c48290b9159c323d5723e22ee19 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Tue, 19 Sep 2023 17:26:06 -0700 Subject: [PATCH 08/26] minimal-bootstrap.gnumake: rebuild with musl --- .../linux/minimal-bootstrap/default.nix | 7 ++ .../linux/minimal-bootstrap/gnumake/musl.nix | 82 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index eb3d73fcdd41..ab85800af469 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -87,6 +87,13 @@ lib.makeScope gnumake = callPackage ./gnumake { tinycc = tinycc-mes; }; + gnumake-musl = callPackage ./gnumake/musl.nix { + bash = bash_2_05; + tinycc = tinycc-musl; + gawk = gawk-mes; + gnumakeBoot = gnumake; + }; + gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; }; gnused = callPackage ./gnused { diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix new file mode 100644 index 000000000000..6ed0b51fd799 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix @@ -0,0 +1,82 @@ +{ lib +, buildPlatform +, hostPlatform +, fetchurl +, bash +, tinycc +, gnumakeBoot +, gnupatch +, gnused +, gnugrep +, gawk +, gnutar +, gzip +}: +let + pname = "gnumake"; + version = "4.4.1"; + + src = fetchurl { + url = "mirror://gnu/make/make-${version}.tar.gz"; + hash = "sha256-3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M="; + }; + + patches = [ + # Replaces /bin/sh with sh, see patch file for reasoning + ./0001-No-impure-bin-sh.patch + # Purity: don't look for library dependencies (of the form `-lfoo') in /lib + # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for + # included Makefiles, don't look in /usr/include and friends. + ./0002-remove-impure-dirs.patch + ]; +in +bash.runCommand "${pname}-${version}" { + inherit pname version; + + nativeBuildInputs = [ + tinycc.compiler + gnumakeBoot + gnupatch + gnused + gnugrep + gawk + gnutar + gzip + ]; + + passthru.tests.get-version = result: + bash.runCommand "${pname}-get-version-${version}" {} '' + ${result}/bin/make --version + mkdir $out + ''; + + meta = with lib; { + description = "A tool to control the generation of non-source files from sources"; + homepage = "https://www.gnu.org/software/make"; + license = licenses.gpl3Plus; + maintainers = teams.minimal-bootstrap.members; + mainProgram = "make"; + platforms = platforms.unix; + }; +} '' + # Unpack + tar xzf ${src} + cd make-${version} + + # Patch + ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} + + # Configure + export CC="tcc -B ${tinycc.libs}/lib" + export LD=tcc + bash ./configure \ + --prefix=$out \ + --build=${buildPlatform.config} \ + --host=${hostPlatform.config} + + # Build + make AR="tcc -ar" + + # Install + make install +'' From e25205899ad22430b622301ab5148ac3346e6fd5 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Thu, 21 Sep 2023 22:04:57 -0700 Subject: [PATCH 09/26] minimal-bootstrap.tinycc-musl: add alloca to libtcc1 --- .../linux/minimal-bootstrap/tinycc/musl.nix | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix index 6debf25c36b0..18eab4202f0d 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix @@ -42,12 +42,12 @@ let ]; meta = with lib; { - description = "Small, fast, and embeddable C compiler and interpreter"; - homepage = "http://savannah.nongnu.org/projects/tinycc"; - license = licenses.lgpl21Only; - maintainers = teams.minimal-bootstrap.members; - platforms = [ "i686-linux" ]; - }; + description = "Small, fast, and embeddable C compiler and interpreter"; + homepage = "http://savannah.nongnu.org/projects/tinycc"; + license = licenses.lgpl21Only; + maintainers = teams.minimal-bootstrap.members; + platforms = [ "i686-linux" ]; + }; tinycc-musl = bash.runCommand "${pname}-${version}" { inherit pname version meta; @@ -123,7 +123,8 @@ let # libtcc1.a rm -f libtcc1.a ./tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c - ./tcc-musl -ar cr libtcc1.a libtcc1.o + ./tcc-musl -c -D HAVE_CONFIG_H=1 lib/alloca86.S + ./tcc-musl -ar cr libtcc1.a libtcc1.o alloca86.o # Install install -D tcc-musl $out/bin/tcc @@ -151,5 +152,10 @@ in libs = bash.runCommand "${pname}-${version}-libs" { inherit pname version meta; - } "install -D ${tinycc-musl}/lib/libtcc1.a $out/lib/libtcc1.a"; + } '' + mkdir $out + cp -r ${musl}/* $out + chmod +w $out/lib/libtcc1.a + cp ${tinycc-musl}/lib/libtcc1.a $out/lib/libtcc1.a + ''; } From 7287781fc337c5253e181dce38ebb1972ffa829b Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Thu, 21 Sep 2023 22:06:58 -0700 Subject: [PATCH 10/26] minimal-bootstrap.musl11: always flush stdio --- .../os-specific/linux/minimal-bootstrap/musl/1.1.nix | 2 ++ .../linux/minimal-bootstrap/musl/always-flush.patch | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/musl/always-flush.patch diff --git a/pkgs/os-specific/linux/minimal-bootstrap/musl/1.1.nix b/pkgs/os-specific/linux/minimal-bootstrap/musl/1.1.nix index eceb9b72aeb6..704ee42edeb1 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/musl/1.1.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/musl/1.1.nix @@ -58,6 +58,8 @@ let # url = "${liveBootstrap}/patches/stdio_flush_on_exit.patch"; # hash = "sha256-/z5ze3h3QTysay8nRvyvwPv3pmTcKptdkBIaMCoeLDg="; # }) + # HACK: always flush stdio immediately + ./always-flush.patch (fetchurl { url = "${liveBootstrap}/patches/va_list.patch"; hash = "sha256-UmcMIl+YCi3wIeVvjbsCyqFlkyYsM4ECNwTfXP+s7vg="; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/musl/always-flush.patch b/pkgs/os-specific/linux/minimal-bootstrap/musl/always-flush.patch new file mode 100644 index 000000000000..cdeddf962d9d --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/musl/always-flush.patch @@ -0,0 +1,12 @@ +diff --git src/env/__libc_start_main.c src/env/__libc_start_main.c +index 8fbe526..9476c22 100644 +--- src/env/__libc_start_main.c ++++ src/env/__libc_start_main.c +@@ -91,6 +91,7 @@ static int libc_start_main_stage2(int (*main)(int,char **,char **), int argc, ch + __libc_start_init(); + + /* Pass control to the application */ ++ setbuf(stdout, NULL); + exit(main(argc, argv, envp)); + return 0; + } From a5d9d1cf496be8e19c3652e9df03eaea6ecea60b Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Thu, 21 Sep 2023 22:07:51 -0700 Subject: [PATCH 11/26] minimal-bootstrap.gawk: use libs from tinycc-musl --- pkgs/os-specific/linux/minimal-bootstrap/default.nix | 1 - pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index ab85800af469..730bcad27618 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -55,7 +55,6 @@ lib.makeScope gawk = callPackage ./gawk { bash = bash_2_05; tinycc = tinycc-musl; - musl = musl11; bootGawk = gawk-mes; }; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix index 83a76c73b4ae..d7d603f9dc86 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix @@ -4,7 +4,6 @@ , fetchurl , bash , tinycc -, musl , gnumake , gnugrep , gnused @@ -46,7 +45,7 @@ bash.runCommand "${pname}-${version}" { cd gawk-${version} # Configure - export CC="tcc -B ${musl}/lib" + export CC="tcc -B ${tinycc.libs}/lib" export AR="tcc -ar" export LD=tcc bash ./configure \ From 3e95cadee893e998f2f53ef688fffd6493c06f5b Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Thu, 21 Sep 2023 22:10:32 -0700 Subject: [PATCH 12/26] minimal-bootstrap.musl: parallelise build --- pkgs/os-specific/linux/minimal-bootstrap/default.nix | 1 + pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 730bcad27618..7dee2e806445 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -140,6 +140,7 @@ lib.makeScope musl = callPackage ./musl { gcc = gcc46; + gnumake = gnumake-musl; }; stage0-posix = callPackage ./stage0-posix { }; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix index 5ccfbdf67080..787d6bcab55a 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix @@ -70,8 +70,8 @@ bash.runCommand "${pname}-${version}" { --host=${hostPlatform.config} # Build - make + make -j $NIX_BUILD_CORES # Install - make install + make -j $NIX_BUILD_CORES install '' From c9ba05b20da750f3924e6f7d3aa1fb6fe8376c4c Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Thu, 21 Sep 2023 22:29:10 -0700 Subject: [PATCH 13/26] minimal-bootstrap.*: replace uses of musl11 with tinycc-musl.libs --- .../os-specific/linux/minimal-bootstrap/binutils/default.nix | 3 +-- pkgs/os-specific/linux/minimal-bootstrap/default.nix | 5 ----- .../linux/minimal-bootstrap/diffutils/default.nix | 3 +-- .../linux/minimal-bootstrap/findutils/default.nix | 3 +-- pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix | 3 +-- pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix | 3 +-- 6 files changed, 5 insertions(+), 15 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix index fedb6fd22638..7afec17d3c6e 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix @@ -13,7 +13,6 @@ , gnutar , xz , tinycc -, musl }: let @@ -99,7 +98,7 @@ bash.runCommand "${pname}-${version}" { export PATH="$(pwd)/aliases/:$PATH" # Configure - export CC="tcc -B ${musl}/lib" + export CC="tcc -B ${tinycc.libs}/lib" export AR="tcc -ar" export lt_cv_sys_max_cmd_len=32768 export CFLAGS="-D__LITTLE_ENDIAN__=1" diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 7dee2e806445..fc6b2b67cad6 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -24,7 +24,6 @@ lib.makeScope binutils = callPackage ./binutils { bash = bash_2_05; tinycc = tinycc-musl; - musl = musl11; }; bzip2 = callPackage ./bzip2 { @@ -37,13 +36,11 @@ lib.makeScope diffutils = callPackage ./diffutils { bash = bash_2_05; tinycc = tinycc-musl; - musl = musl11; }; findutils = callPackage ./findutils { bash = bash_2_05; tinycc = tinycc-musl; - musl = musl11; }; gawk-mes = callPackage ./gawk/mes.nix { @@ -98,7 +95,6 @@ lib.makeScope gnused = callPackage ./gnused { bash = bash_2_05; tinycc = tinycc-musl; - musl = musl11; gnused = gnused-mes; }; gnused-mes = callPackage ./gnused/mes.nix { @@ -157,7 +153,6 @@ lib.makeScope xz = callPackage ./xz { bash = bash_2_05; tinycc = tinycc-musl; - musl = musl11; }; inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix index 42db4a6640da..b0cacd0ac4f5 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix @@ -4,7 +4,6 @@ , fetchurl , bash , tinycc -, musl , gnumake , gnugrep , gnused @@ -57,7 +56,7 @@ bash.runCommand "${pname}-${version}" { cd diffutils-${version} # Configure - export CC="tcc -B ${musl}/lib" + export CC="tcc -B ${tinycc.libs}/lib" export LD=tcc bash ./configure \ --prefix=$out \ diff --git a/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix index bbdc4198d703..7479ea6fbfbf 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix @@ -4,7 +4,6 @@ , fetchurl , bash , tinycc -, musl , gnumake , gnugrep , gnused @@ -60,7 +59,7 @@ bash.runCommand "${pname}-${version}" { sed -i 's/chdir_long/chdir/' gl/lib/save-cwd.c # Configure - export CC="tcc -B ${musl}/lib" + export CC="tcc -B ${tinycc.libs}/lib" export AR="tcc -ar" export LD=tcc bash ./configure \ diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix index ee237f016f5b..ee566f93c164 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix @@ -5,7 +5,6 @@ , bash , gnumake , tinycc -, musl , gnused , gnugrep , gnutar @@ -46,7 +45,7 @@ bash.runCommand "${pname}-${version}" { cd sed-${version} # Configure - export CC="tcc -B ${musl}/lib" + export CC="tcc -B ${tinycc.libs}/lib" export LD=tcc ./configure \ --build=${buildPlatform.config} \ diff --git a/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix index 32c5b3999c1b..a7eb8478d5ac 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix @@ -4,7 +4,6 @@ , fetchurl , bash , tinycc -, musl , gnumake , gnused , gnugrep @@ -53,7 +52,7 @@ bash.runCommand "${pname}-${version}" { cd xz-${version} # Configure - export CC="tcc -B ${musl}/lib" + export CC="tcc -B ${tinycc.libs}/lib" export AR="tcc -ar" export LD=tcc bash ./configure \ From 0173d3bd90826538c20cc53eb0db8b3ff326f51d Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Sun, 24 Sep 2023 20:39:58 -0700 Subject: [PATCH 14/26] minimal-bootstrap.tinycc-musl: 0.9.27 -> unstable-2023-04-20 latest tinycc is able to build gcc 4.6.4 --- .../tinycc/ignore-duplicate-symbols.patch | 13 ++++ .../tinycc/ignore-static-inside-array.patch | 21 +++++++ .../linux/minimal-bootstrap/tinycc/musl.nix | 61 ++++++++----------- .../tinycc/static-link.patch | 10 +++ 4 files changed, 71 insertions(+), 34 deletions(-) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/tinycc/ignore-duplicate-symbols.patch create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/tinycc/ignore-static-inside-array.patch create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/tinycc/static-link.patch diff --git a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/ignore-duplicate-symbols.patch b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/ignore-duplicate-symbols.patch new file mode 100644 index 000000000000..0aec8b465bf2 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/ignore-duplicate-symbols.patch @@ -0,0 +1,13 @@ +--- tccelf.c ++++ tccelf.c +@@ -710,8 +710,9 @@ ST_FUNC int set_elf_sym(Section *s, addr_t value, unsigned long size, + #if 0 + printf("new_bind=%x new_shndx=%x new_vis=%x old_bind=%x old_shndx=%x old_vis=%x\n", + sym_bind, shndx, new_vis, esym_bind, esym->st_shndx, esym_vis); +-#endif + tcc_error_noabort("'%s' defined twice", name); ++#endif ++ goto do_patch; + } + } else { + esym->st_other = other; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/ignore-static-inside-array.patch b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/ignore-static-inside-array.patch new file mode 100644 index 000000000000..8dc2fe3fcfb4 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/ignore-static-inside-array.patch @@ -0,0 +1,21 @@ +--- tccgen.c ++++ tccgen.c +@@ -4941,7 +4941,7 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td) + next(); + n = -1; + t1 = 0; +- if (td & TYPE_PARAM) while (1) { ++ while (1) { + /* XXX The optional type-quals and static should only be accepted + in parameter decls. The '*' as well, and then even only + in prototypes (not function defs). */ +@@ -4972,7 +4972,8 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td) + } + break; + +- } else if (tok != ']') { ++ } ++ if (tok != ']') { + if (!local_stack || (storage & VT_STATIC)) + vpushi(expr_const()); + else { diff --git a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix index 18eab4202f0d..9dfa14e4821f 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix @@ -1,9 +1,3 @@ -# Build steps adapted from https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/tcc-0.9.27/tcc-musl-pass1.sh -# -# SPDX-FileCopyrightText: 2021-22 fosslinux -# -# SPDX-License-Identifier: GPL-3.0-or-later - { lib , fetchurl , callPackage @@ -12,38 +6,27 @@ , musl , gnupatch , gnutar -, bzip2 +, gzip }: let pname = "tinycc-musl"; - version = "0.9.27"; + version = "unstable-2023-04-20"; + rev = "86f3d8e33105435946383aee52487b5ddf918140"; src = fetchurl { - url = "https://download.savannah.gnu.org/releases/tinycc/tcc-${version}.tar.bz2"; - hash = "sha256-3iOvePypDOMt/y3UWzQysjNHQLubt7Bb9g/b/Dls65w="; + url = "https://repo.or.cz/tinycc.git/snapshot/${rev}.tar.gz"; + hash = "sha256-V3XBXYyzHi9f4JSYGeQwz6+1biUp7cwGaEE+x9fOLYY="; }; - # Thanks to the live-bootstrap project! - # See https://github.com/fosslinux/live-bootstrap/blob/424aa5be38a3023aa6842883a3954599b1597986/sysa/tcc-0.9.27/tcc-musl-pass1.sh - liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/424aa5be38a3023aa6842883a3954599b1597986/sysa/tcc-0.9.27"; patches = [ - (fetchurl { - url = "${liveBootstrap}/patches/ignore-duplicate-symbols.patch"; - hash = "sha256-6Js8HkzjYlA8ETxeEYRWu+03OJI60NvR5h1QPkcMTlQ="; - }) - (fetchurl { - url = "${liveBootstrap}/patches/ignore-static-inside-array.patch"; - hash = "sha256-IF4RevLGjzRBuYqhuyG7+x6SVljzMAsYRKicNsmtbDY="; - }) - (fetchurl { - url = "${liveBootstrap}/patches/static-link.patch"; - hash = "sha256-gX/hJ9a/0Zg29KIBUme+mOA8WrPQvp0SvojP8DN9mSI="; - }) + ./ignore-duplicate-symbols.patch + ./ignore-static-inside-array.patch + ./static-link.patch ]; meta = with lib; { description = "Small, fast, and embeddable C compiler and interpreter"; - homepage = "http://savannah.nongnu.org/projects/tinycc"; + homepage = "https://repo.or.cz/w/tinycc.git"; license = licenses.lgpl21Only; maintainers = teams.minimal-bootstrap.members; platforms = [ "i686-linux" ]; @@ -56,15 +39,12 @@ let tinycc-bootstrappable.compiler gnupatch gnutar - bzip2 + gzip ]; } '' # Unpack - cp ${src} tinycc.tar.bz2 - bunzip2 tinycc.tar.bz2 - tar xf tinycc.tar - rm tinycc.tar - cd tcc-${version} + tar xzf ${src} + cd tinycc-${builtins.substring 0 7 rev} # Patch ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches} @@ -77,6 +57,13 @@ let # but when linked with musl it is. ln -s ${musl}/lib/libtcc1.a ./libtcc1.a + tcc \ + -B ${tinycc-bootstrappable.libs}/lib \ + -DC2STR \ + -o c2str \ + conftest.c + ./c2str include/tccdefs.h tccdefs_.h + tcc -v \ -static \ -o tcc-musl \ @@ -92,6 +79,9 @@ let -D CONFIG_USE_LIBGCC=1 \ -D TCC_VERSION=\"0.9.27\" \ -D ONE_SOURCE=1 \ + -D TCC_MUSL=1 \ + -D CONFIG_TCC_PREDEFS=1 \ + -D CONFIG_TCC_SEMLOCK=0 \ -B . \ -B ${tinycc-bootstrappable.libs}/lib \ tcc.c @@ -117,14 +107,17 @@ let -D CONFIG_USE_LIBGCC=1 \ -D TCC_VERSION=\"0.9.27\" \ -D ONE_SOURCE=1 \ + -D TCC_MUSL=1 \ + -D CONFIG_TCC_PREDEFS=1 \ + -D CONFIG_TCC_SEMLOCK=0 \ -B . \ -B ${musl}/lib \ tcc.c # libtcc1.a rm -f libtcc1.a ./tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c - ./tcc-musl -c -D HAVE_CONFIG_H=1 lib/alloca86.S - ./tcc-musl -ar cr libtcc1.a libtcc1.o alloca86.o + ./tcc-musl -c -D HAVE_CONFIG_H=1 lib/alloca.S + ./tcc-musl -ar cr libtcc1.a libtcc1.o alloca.o # Install install -D tcc-musl $out/bin/tcc diff --git a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/static-link.patch b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/static-link.patch new file mode 100644 index 000000000000..671a3b37f98d --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/static-link.patch @@ -0,0 +1,10 @@ +--- libtcc.c ++++ libtcc.c +@@ -793,6 +793,7 @@ LIBTCCAPI TCCState *tcc_new(void) + + s->gnu_ext = 1; + s->tcc_ext = 1; ++ s->static_link = 1; + s->nocommon = 1; + s->dollars_in_identifiers = 1; /*on by default like in gcc/clang*/ + s->cversion = 199901; /* default unless -std=c11 is supplied */ From d73a846519525a34def7bd1a787c0f303135c788 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Sun, 24 Sep 2023 20:41:35 -0700 Subject: [PATCH 15/26] minimal-bootstrap.gnutar-musl: init at 1.12 gnutar with musl preserves modify times --- .../linux/minimal-bootstrap/default.nix | 9 ++- .../gnutar/{default.nix => mes.nix} | 0 .../linux/minimal-bootstrap/gnutar/musl.nix | 70 +++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) rename pkgs/os-specific/linux/minimal-bootstrap/gnutar/{default.nix => mes.nix} (100%) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/gnutar/musl.nix diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index fc6b2b67cad6..94236777384f 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -102,12 +102,18 @@ lib.makeScope tinycc = tinycc-mes; }; - gnutar = callPackage ./gnutar { + gnutar = callPackage ./gnutar/mes.nix { bash = bash_2_05; tinycc = tinycc-mes; gnused = gnused-mes; }; + gnutar-musl = callPackage ./gnutar/musl.nix { + bash = bash_2_05; + tinycc = tinycc-musl; + gnused = gnused-mes; + }; + gzip = callPackage ./gzip { bash = bash_2_05; tinycc = tinycc-mes; @@ -173,6 +179,7 @@ lib.makeScope echo ${gnused.tests.get-version} echo ${gnused-mes.tests.get-version} echo ${gnutar.tests.get-version} + echo ${gnutar-musl.tests.get-version} echo ${gzip.tests.get-version} echo ${heirloom.tests.get-version} echo ${mes.compiler.tests.get-version} diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnutar/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnutar/mes.nix similarity index 100% rename from pkgs/os-specific/linux/minimal-bootstrap/gnutar/default.nix rename to pkgs/os-specific/linux/minimal-bootstrap/gnutar/mes.nix diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnutar/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnutar/musl.nix new file mode 100644 index 000000000000..0818a0de39a2 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnutar/musl.nix @@ -0,0 +1,70 @@ +{ lib +, buildPlatform +, hostPlatform +, fetchurl +, bash +, tinycc +, gnumake +, gnugrep +, gnused +}: +let + # gnutar with musl preserves modify times, allowing make to not try + # rebuilding pregenerated files + pname = "gnutar-musl"; + version = "1.12"; + + src = fetchurl { + url = "mirror://gnu/tar/tar-${version}.tar.gz"; + hash = "sha256-xsN+iIsTbM76uQPFEUn0t71lnWnUrqISRfYQU6V6pgo="; + }; +in +bash.runCommand "${pname}-${version}" { + inherit pname version; + + nativeBuildInputs = [ + tinycc.compiler + gnumake + gnused + gnugrep + ]; + + passthru.tests.get-version = result: + bash.runCommand "${pname}-get-version-${version}" {} '' + ${result}/bin/tar --version + mkdir $out + ''; + + meta = with lib; { + description = "GNU implementation of the `tar' archiver"; + homepage = "https://www.gnu.org/software/tar"; + license = licenses.gpl3Plus; + maintainers = teams.minimal-bootstrap.members; + mainProgram = "tar"; + platforms = platforms.unix; + }; +} '' + # Unpack + ungz --file ${src} --output tar.tar + untar --file tar.tar + rm tar.tar + cd tar-${version} + + # Configure + export CC="tcc -B ${tinycc.libs}/lib" + export LD=tcc + export ac_cv_sizeof_unsigned_long=4 + export ac_cv_sizeof_long_long=8 + export ac_cv_header_netdb_h=no + bash ./configure \ + --prefix=$out \ + --build=${buildPlatform.config} \ + --host=${hostPlatform.config} \ + --disable-nls + + # Build + make AR="tcc -ar" + + # Install + make install +'' From a680950c8828624ddc71aadcf1e0ca20db544836 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Sun, 24 Sep 2023 20:43:25 -0700 Subject: [PATCH 16/26] minimal-bootstrap.coreutils-musl: init at 9.4 --- .../minimal-bootstrap/coreutils/musl.nix | 74 +++++++++++++++++++ .../linux/minimal-bootstrap/default.nix | 7 ++ 2 files changed, 81 insertions(+) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix diff --git a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix new file mode 100644 index 000000000000..dece020a5e79 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix @@ -0,0 +1,74 @@ +{ lib +, buildPlatform +, hostPlatform +, fetchurl +, bash +, tinycc +, gnumake +, gnugrep +, gnused +, gawk +, gnutar +, gzip +}: +let + pname = "coreutils"; + version = "9.4"; + + src = fetchurl { + url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz"; + hash = "sha256-X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk="; + }; + + configureFlags = [ + "--prefix=${placeholder "out"}" + "--build=${buildPlatform.config}" + "--host=${hostPlatform.config}" + # musl 1.1.x doesn't use 64bit time_t + "--disable-year2038" + # libstdbuf.so fails in static builds + "--enable-no-install-program=stdbuf" + ]; +in +bash.runCommand "${pname}-${version}" { + inherit pname version; + + nativeBuildInputs = [ + tinycc.compiler + gnumake + gnused + gnugrep + gawk + gnutar + gzip + ]; + + passthru.tests.get-version = result: + bash.runCommand "${pname}-get-version-${version}" {} '' + ${result}/bin/cat --version + mkdir $out + ''; + + meta = with lib; { + description = "The GNU Core Utilities"; + homepage = "https://www.gnu.org/software/coreutils"; + license = licenses.gpl3Plus; + maintainers = teams.minimal-bootstrap.members; + platforms = platforms.unix; + }; +} '' + # Unpack + tar xzf ${src} + cd coreutils-${version} + + # Configure + export CC="tcc -B ${tinycc.libs}/lib" + export LD=tcc + bash ./configure ${lib.concatStringsSep " " configureFlags} + + # Build + make -j $NIX_BUILD_CORES AR="tcc -ar" MAKEINFO="true" + + # Install + make -j $NIX_BUILD_CORES install MAKEINFO="true" +'' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 94236777384f..d5346002a29f 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -32,6 +32,12 @@ lib.makeScope }; coreutils = callPackage ./coreutils { tinycc = tinycc-mes; }; + coreutils-musl = callPackage ./coreutils/musl.nix { + bash = bash_2_05; + tinycc = tinycc-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; + }; diffutils = callPackage ./diffutils { bash = bash_2_05; @@ -168,6 +174,7 @@ lib.makeScope echo ${bash_2_05.tests.get-version} echo ${binutils.tests.get-version} echo ${bzip2.tests.get-version} + echo ${coreutils-musl.tests.get-version} echo ${diffutils.tests.get-version} echo ${findutils.tests.get-version} echo ${gawk-mes.tests.get-version} From 29b98b0f89ae12f4160762c7bb01c7e70944580d Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Sun, 24 Sep 2023 20:44:46 -0700 Subject: [PATCH 17/26] minimal-bootstrap.gcc46: build with tinycc-musl --- .../linux/minimal-bootstrap/default.nix | 8 ++- .../linux/minimal-bootstrap/gcc/4.6.nix | 52 +++++++------------ .../gcc/no-system-headers.patch | 11 ++++ 3 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/gcc/no-system-headers.patch diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index d5346002a29f..b872b058a9f3 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -73,8 +73,12 @@ lib.makeScope }; gcc46 = callPackage ./gcc/4.6.nix { - gcc = gcc2; - glibc = glibc22; + coreutils = coreutils-musl; + tinycc = tinycc-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; + # FIXME: not sure why new gawk doesn't work + gawk = gawk-mes; }; inherit (callPackage ./glibc { diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gcc/4.6.nix b/pkgs/os-specific/linux/minimal-bootstrap/gcc/4.6.nix index ce348352b67e..02094413b2c7 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gcc/4.6.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gcc/4.6.nix @@ -3,9 +3,8 @@ , hostPlatform , fetchurl , bash -, gcc -, glibc -, linux-headers +, coreutils +, tinycc , binutils , gnumake , gnupatch @@ -32,23 +31,10 @@ let }; patches = [ - # This patch enables building gcc-4.6.4 using gcc-2.95.3 and glibc-2.2.5 - # * Tweak Makefile to allow overriding NATIVE_SYSTEM_HEADER_DIR using #:makeflags - # * Add missing limits.h include. - # * Add SSIZE_MAX define. The SSIZE_MAX define has been added to Mes - # upstream and can be removed with the next Mes release. - # * Remove -fbuilding-libgcc flag, it assumes features being present from a - # newer gcc or glibc. - # * [MES_BOOTSTRAP_GCC]: Disable threads harder. - (fetchurl { - url = "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/patches/gcc-boot-4.6.4.patch?id=50249cab3a98839ade2433456fe618acc6f804a5"; - sha256 = "1zzd8gnihw6znrgb6c6pfsmm0vix89xw3giv1nnsykm57j0v3z0d"; - }) - ./libstdc++-target.patch + # Remove hardcoded NATIVE_SYSTEM_HEADER_DIR + ./no-system-headers.patch ]; - # To reduce the set of pre-built bootstrap inputs, build - # GMP & co. from GCC. gmpVersion = "4.3.2"; gmp = fetchurl { url = "mirror://gnu/gmp/gmp-${gmpVersion}.tar.gz"; @@ -71,7 +57,8 @@ bash.runCommand "${pname}-${version}" { inherit pname version; nativeBuildInputs = [ - gcc + coreutils + tinycc.compiler binutils gnumake gnupatch @@ -84,10 +71,6 @@ bash.runCommand "${pname}-${version}" { gzip ]; - # condition in ./libcpp/configure requires `env` which is not available in this coreutils - am_cv_CXX_dependencies_compiler_type = "gcc"; - am_cv_CC_dependencies_compiler_type = "gcc"; - passthru.tests.get-version = result: bash.runCommand "${pname}-get-version-${version}" {} '' ${result}/bin/gcc --version @@ -118,18 +101,21 @@ bash.runCommand "${pname}-${version}" { ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} # Configure - export C_INCLUDE_PATH="${gcc}/lib/gcc-lib/${hostPlatform.config}/${gcc.version}/include:${linux-headers}/include:${glibc}/include:$(pwd)/mpfr/src" + export CC="tcc -B ${tinycc.libs}/lib" + export C_INCLUDE_PATH="${tinycc.libs}/include:$(pwd)/mpfr/src" export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH" - export LDFLAGS="-B${glibc}/lib -Wl,-dynamic-linker -Wl,${glibc}" - export LDFLAGS_FOR_TARGET=$LDFLAGS - export LIBRARY_PATH="${glibc}/lib:${gcc}/lib" - export LIBS="-lc -lnss_files -lnss_dns -lresolv" + + # Avoid "Link tests are not allowed after GCC_NO_EXECUTABLES" + export lt_cv_shlibpath_overrides_runpath=yes + export ac_cv_func_memcpy=yes + export ac_cv_func_strerror=yes + bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ - --with-native-system-header-dir=${glibc}/include \ - --with-build-sysroot=${glibc}/include \ + --with-native-system-header-dir=${tinycc.libs}/include \ + --with-build-sysroot=${tinycc.libs}/include \ --disable-bootstrap \ --disable-decimal-float \ --disable-libatomic \ @@ -146,7 +132,7 @@ bash.runCommand "${pname}-${version}" { --disable-multilib \ --disable-plugin \ --disable-threads \ - --enable-languages=c,c++ \ + --enable-languages=c \ --enable-static \ --disable-shared \ --enable-threads=single \ @@ -154,8 +140,8 @@ bash.runCommand "${pname}-${version}" { --disable-build-with-cxx # Build - make + make -j $NIX_BUILD_CORES # Install - make install + make -j $NIX_BUILD_CORES install '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gcc/no-system-headers.patch b/pkgs/os-specific/linux/minimal-bootstrap/gcc/no-system-headers.patch new file mode 100644 index 000000000000..318553bf916b --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gcc/no-system-headers.patch @@ -0,0 +1,11 @@ +--- a/gcc/Makefile.in ++++ b/gcc/Makefile.in +@@ -440,7 +440,7 @@ LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h + LTO_SYMTAB_H = $(srcdir)/../include/lto-symtab.h + + # Default native SYSTEM_HEADER_DIR, to be overridden by targets. +-NATIVE_SYSTEM_HEADER_DIR = /usr/include ++# NATIVE_SYSTEM_HEADER_DIR = /usr/include + # Default cross SYSTEM_HEADER_DIR, to be overridden by targets. + CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@ + From 25a264c6c4f4ee85c1e844dd8ba1973d2fd57a2b Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Sun, 24 Sep 2023 23:55:10 -0700 Subject: [PATCH 18/26] minimal-bootstrap.tinycc-musl: unstable-2023-04-20 -> unstable-2023-07-10 Update to the last version of tinycc supported by bootstrappable-tcc. This upgrade isn't strictly necessary, but I wanted to document that this is the last successful revision --- pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix index 9dfa14e4821f..4d26faac20b1 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/musl.nix @@ -10,12 +10,13 @@ }: let pname = "tinycc-musl"; - version = "unstable-2023-04-20"; - rev = "86f3d8e33105435946383aee52487b5ddf918140"; + # next commit introduces use of realpath (unsupported in mes-libc) + version = "unstable-2023-07-10"; + rev = "fd6d2180c5c801bb0b4c5dde27d61503059fc97d"; src = fetchurl { url = "https://repo.or.cz/tinycc.git/snapshot/${rev}.tar.gz"; - hash = "sha256-V3XBXYyzHi9f4JSYGeQwz6+1biUp7cwGaEE+x9fOLYY="; + hash = "sha256-R81SNbEmh4s9FNQxCWZwUiMCYRkkwOHAdRf0aMnnRiA="; }; patches = [ From 1c1962f97536041ce38116feebc52e4e35ec9396 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 25 Sep 2023 00:12:23 -0700 Subject: [PATCH 19/26] minimal-bootstrap.bash: build with musl --- .../linux/minimal-bootstrap/bash/default.nix | 35 +++++++++++-------- .../bash/mksignames-flush.patch | 10 ++++++ .../linux/minimal-bootstrap/default.nix | 7 ++-- .../linux/minimal-bootstrap/gcc/4.6.nix | 2 -- 4 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/bash/mksignames-flush.patch diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix index dea5ad9f017f..35c4da7acf93 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix @@ -4,15 +4,14 @@ , fetchurl , bootBash , gnumake +, gnupatch , gnused , gnugrep , gnutar , gawk , gzip -, gcc -, glibc -, binutils -, linux-headers +, diffutils +, tinycc , derivationWithMeta , bash , coreutils @@ -25,19 +24,26 @@ let url = "mirror://gnu/bash/bash-${version}.tar.gz"; sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk"; }; + + patches = [ + # flush output for generated code + ./mksignames-flush.patch + ]; in bootBash.runCommand "${pname}-${version}" { inherit pname version; nativeBuildInputs = [ - gcc - binutils + coreutils + tinycc.compiler gnumake + gnupatch gnused gnugrep gnutar gawk gzip + diffutils ]; passthru.runCommand = name: env: buildCommand: @@ -78,22 +84,23 @@ bootBash.runCommand "${pname}-${version}" { tar xzf ${src} cd bash-${version} + # Patch + ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} + # Configure - export CC="gcc -I${glibc}/include -I${linux-headers}/include" - export LIBRARY_PATH="${glibc}/lib" - export LIBS="-lc -lnss_files -lnss_dns -lresolv" - export ac_cv_func_dlopen=no + export CC="tcc -B ${tinycc.libs}/lib" + export AR="tcc -ar" + export LD=tcc bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ - --disable-nls \ - --disable-net-redirections + --without-bash-malloc # Build - make SHELL=bash + make -j $NIX_BUILD_CORES SHELL=bash # Install - make install + make -j $NIX_BUILD_CORES install ln -s bash $out/bin/sh '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bash/mksignames-flush.patch b/pkgs/os-specific/linux/minimal-bootstrap/bash/mksignames-flush.patch new file mode 100644 index 000000000000..6e64dfa7fa3a --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/bash/mksignames-flush.patch @@ -0,0 +1,10 @@ +--- a/support/mksignames.c ++++ b/support/mksignames.c +@@ -68,6 +68,7 @@ write_signames (stream) + fprintf (stream, "};\n\n"); + fprintf (stream, "#define initialize_signames()\n\n"); + #endif ++ fflush(stream); + } + + int diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index b872b058a9f3..d0eed2f87aaf 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -17,8 +17,10 @@ lib.makeScope bash = callPackage ./bash { bootBash = bash_2_05; - gcc = gcc2; - glibc = glibc22; + tinycc = tinycc-musl; + coreutils = coreutils-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; }; binutils = callPackage ./binutils { @@ -73,7 +75,6 @@ lib.makeScope }; gcc46 = callPackage ./gcc/4.6.nix { - coreutils = coreutils-musl; tinycc = tinycc-musl; gnumake = gnumake-musl; gnutar = gnutar-musl; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gcc/4.6.nix b/pkgs/os-specific/linux/minimal-bootstrap/gcc/4.6.nix index 02094413b2c7..4af069523f2c 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gcc/4.6.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gcc/4.6.nix @@ -3,7 +3,6 @@ , hostPlatform , fetchurl , bash -, coreutils , tinycc , binutils , gnumake @@ -57,7 +56,6 @@ bash.runCommand "${pname}-${version}" { inherit pname version; nativeBuildInputs = [ - coreutils tinycc.compiler binutils gnumake From 454dc76ae85b9db28430a95171c08aa1fa81f19e Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 25 Sep 2023 00:26:04 -0700 Subject: [PATCH 20/26] minimal-bootstrap.gawk: 5.2.0 -> 5.2.2, parallelise --- pkgs/os-specific/linux/minimal-bootstrap/default.nix | 2 ++ pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index d0eed2f87aaf..5a7f31949073 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -60,6 +60,8 @@ lib.makeScope gawk = callPackage ./gawk { bash = bash_2_05; tinycc = tinycc-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; bootGawk = gawk-mes; }; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix index d7d603f9dc86..879b98bf00c5 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix @@ -14,11 +14,11 @@ let inherit (import ./common.nix { inherit lib; }) meta; pname = "gawk"; - version = "5.2.0"; + version = "5.2.2"; src = fetchurl { url = "mirror://gnu/gawk/gawk-${version}.tar.gz"; - hash = "sha256-71r0RJywJp+vOvJL9MAic9RV8HQb88UPht3AkzLWz1Y="; + hash = "sha256-lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA="; }; in bash.runCommand "${pname}-${version}" { @@ -54,8 +54,8 @@ bash.runCommand "${pname}-${version}" { --host=${hostPlatform.config} # Build - make + make -j $NIX_BUILD_CORES # Install - make install + make -j $NIX_BUILD_CORES install '' From ee8bf1d3effd139508db98ed3fb2ad4da2a59fa7 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 25 Sep 2023 02:10:10 -0700 Subject: [PATCH 21/26] minimal-bootstrap.xz: parallelise --- pkgs/os-specific/linux/minimal-bootstrap/default.nix | 2 ++ pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 5a7f31949073..f600ec0404e3 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -172,6 +172,8 @@ lib.makeScope xz = callPackage ./xz { bash = bash_2_05; tinycc = tinycc-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; }; inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix index a7eb8478d5ac..8dcccbacaca8 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix @@ -63,8 +63,8 @@ bash.runCommand "${pname}-${version}" { --disable-assembler # Build - make + make -j $NIX_BUILD_CORES # Install - make install + make -j $NIX_BUILD_CORES install '' From d7b804e08edb143432b386c6242f3468494d35e9 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 25 Sep 2023 02:11:55 -0700 Subject: [PATCH 22/26] minimal-bootstrap.diffutils: parallelise --- pkgs/os-specific/linux/minimal-bootstrap/default.nix | 2 ++ .../os-specific/linux/minimal-bootstrap/diffutils/default.nix | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index f600ec0404e3..47ecd077a627 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -44,6 +44,8 @@ lib.makeScope diffutils = callPackage ./diffutils { bash = bash_2_05; tinycc = tinycc-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; }; findutils = callPackage ./findutils { diff --git a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix index b0cacd0ac4f5..24cd643b3497 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix @@ -64,8 +64,8 @@ bash.runCommand "${pname}-${version}" { --host=${hostPlatform.config} # Build - make AR="tcc -ar" + make -j $NIX_BUILD_CORES AR="tcc -ar" # Install - make install + make -j $NIX_BUILD_CORES install '' From 47900241a2527e3bbc134ef03ec7488f22231df7 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 25 Sep 2023 02:13:26 -0700 Subject: [PATCH 23/26] minimal-bootstrap.findutils: parallelise --- pkgs/os-specific/linux/minimal-bootstrap/default.nix | 2 ++ .../os-specific/linux/minimal-bootstrap/findutils/default.nix | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 47ecd077a627..c3ad9d6066c9 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -51,6 +51,8 @@ lib.makeScope findutils = callPackage ./findutils { bash = bash_2_05; tinycc = tinycc-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; }; gawk-mes = callPackage ./gawk/mes.nix { diff --git a/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix index 7479ea6fbfbf..97418d218fb9 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/findutils/default.nix @@ -68,8 +68,8 @@ bash.runCommand "${pname}-${version}" { --host=${hostPlatform.config} # Build - make + make -j $NIX_BUILD_CORES # Install - make install + make -j $NIX_BUILD_CORES install '' From b99da9eb04095ce8bcf9b6b82708a8ca71cf8775 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 25 Sep 2023 02:21:53 -0700 Subject: [PATCH 24/26] minimal-bootstrap.gnumake-musl: fix pname --- pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix index 6ed0b51fd799..504095732e8c 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix @@ -13,7 +13,7 @@ , gzip }: let - pname = "gnumake"; + pname = "gnumake-musl"; version = "4.4.1"; src = fetchurl { From 2f400edeb3451b4b1429d727b506f796d1324573 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 25 Sep 2023 03:43:29 -0700 Subject: [PATCH 25/26] minimal-bootstrap.binutils: parallelise --- .../linux/minimal-bootstrap/binutils/default.nix | 6 +++--- pkgs/os-specific/linux/minimal-bootstrap/default.nix | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix index 7afec17d3c6e..71e391efb550 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix @@ -105,10 +105,10 @@ bash.runCommand "${pname}-${version}" { bash ./configure ${lib.concatStringsSep " " configureFlags} # Build - make all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof + make -j $NIX_BUILD_CORES all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof make all-ld # race condition on ld/.deps/ldwrite.Po, serialize - make + make -j $NIX_BUILD_CORES # Install - make install + make -j $NIX_BUILD_CORES install '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index c3ad9d6066c9..7b6dcd4c447d 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -26,6 +26,8 @@ lib.makeScope binutils = callPackage ./binutils { bash = bash_2_05; tinycc = tinycc-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; }; bzip2 = callPackage ./bzip2 { From adf49a8b0c74762559ea518b953080b810efee9f Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Tue, 26 Sep 2023 22:55:06 -0700 Subject: [PATCH 26/26] minimal-bootstrap.bzip2: build with musl --- .../linux/minimal-bootstrap/bzip2/default.nix | 29 +++++-------------- .../linux/minimal-bootstrap/default.nix | 4 ++- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix index 84fb7a0a1b73..05da061ac263 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix @@ -3,7 +3,7 @@ , bash , tinycc , gnumake -, gnupatch +, gnutar , gzip }: let @@ -14,16 +14,6 @@ let url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz"; sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb"; }; - - patches = [ - # mes libc has no time support, so we remove that. - # It also does not have fch{own,mod}, which we don't care about in the bootstrap - # anyway, so we can null-op those calls. - (fetchurl { - url = "https://github.com/fosslinux/live-bootstrap/raw/87e9d7db9d22b400d1c05247254ac39ee2577e80/sysa/bzip2-1.0.8/patches/mes-libc.patch"; - sha256 = "14dciwib28h413skzfkh7samzh8x87dmwhldyxxphff04pvl1j3c"; - }) - ]; in bash.runCommand "${pname}-${version}" { inherit pname version; @@ -31,13 +21,13 @@ bash.runCommand "${pname}-${version}" { nativeBuildInputs = [ tinycc.compiler gnumake - gnupatch + gnutar gzip ]; passthru.tests.get-version = result: bash.runCommand "${pname}-get-version-${version}" {} '' - ${result}/bin/bzip2 --version --help + ${result}/bin/bzip2 --help mkdir $out ''; @@ -50,21 +40,16 @@ bash.runCommand "${pname}-${version}" { }; } '' # Unpack - cp ${src} bzip2.tar.gz - gunzip bzip2.tar.gz - untar --file bzip2.tar - rm bzip2.tar + tar xzf ${src} cd bzip2-${version} - # Patch - ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches} - # Build make \ - CC="tcc -B ${tinycc.libs}/lib -I ." \ + -j $NIX_BUILD_CORES \ + CC="tcc -B ${tinycc.libs}/lib" \ AR="tcc -ar" \ bzip2 bzip2recover # Install - make install PREFIX=$out + make install -j $NIX_BUILD_CORES PREFIX=$out '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 7b6dcd4c447d..5da47e46edaa 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -32,7 +32,9 @@ lib.makeScope bzip2 = callPackage ./bzip2 { bash = bash_2_05; - tinycc = tinycc-mes; + tinycc = tinycc-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; }; coreutils = callPackage ./coreutils { tinycc = tinycc-mes; };