diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix index 3b2a772797bf..dd69efc0c641 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/default.nix @@ -20,21 +20,18 @@ let # Based on https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a1-static-binutils.nix inherit (import ./common.nix { inherit lib; }) meta; pname = "binutils"; - - # Unfortunately, this is the latest version (as of 2.45.1) that works for - # - tinycc that compiles gcc 4.6.4 (ar in 2.45.* produce incompatible archives for tcc linker) - # - gcc 4.6.4 that compiles musl 1.2.5 (ld crashes in 2.43 and 2.44) - # This might need some further investigation. - version = "2.42"; + version = "2.46.0"; src = fetchurl { url = "mirror://gnu/binutils/binutils-${version}.tar.xz"; - hash = "sha256-9uTUH9X8d4sGt4kUV7NiDaXs6hAGxqSkGumYEJ+FqAA="; + hash = "sha256-11qU9Nc+ekCG91E+Z+Q56Pzcu3Jv/mP0ZhdE5iVrLPI="; }; patches = [ # Make binutils output deterministic by default. ./deterministic.patch + # Fix __attribute__, to fix mmap-related assertion failures. + ./fix-tinycc-attribute.patch ]; configureFlags = [ @@ -105,11 +102,6 @@ bash.runCommand "${pname}-${version}" export AR="tcc -ar" export lt_cv_sys_max_cmd_len=32768 - # binutils 2.42 has a broken check for TLS storage class, which results - # in the TLS macro begin undefined. - # Let's help it along. We won't need TLS anyway. - export ac_cv_tls=" " - export CFLAGS="-D__LITTLE_ENDIAN__=1" bash ./configure ${lib.concatStringsSep " " configureFlags} diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/fix-tinycc-attribute.patch b/pkgs/os-specific/linux/minimal-bootstrap/binutils/fix-tinycc-attribute.patch new file mode 100644 index 000000000000..ec5371c71e8d --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/fix-tinycc-attribute.patch @@ -0,0 +1,13 @@ +diff --git a/include/ansidecl.h b/include/ansidecl.h +index 0ae6a986..214a41f9 100644 +--- a/include/ansidecl.h ++++ b/include/ansidecl.h +@@ -68,7 +68,7 @@ So instead we use the macro below and test it against specific values. */ + macros freely, and know that they will come into play for the + version of gcc in which they are supported. */ + +-#if (GCC_VERSION < 2007) ++#if (GCC_VERSION < 2007) && !defined(__TINYC__) + # define __attribute__(x) + #endif + diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix index 203a12aabb2c..7f2405585a56 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix @@ -20,11 +20,11 @@ let inherit (import ./common.nix { inherit lib; }) meta; pname = "binutils-static"; - version = "2.45.1"; + version = "2.46.0"; src = fetchurl { url = "mirror://gnu/binutils/binutils-${version}.tar.xz"; - hash = "sha256-X+EB5v6dGP3slZYtge1nD97l834/SPC++Hvd+GJROqU="; + hash = "sha256-11qU9Nc+ekCG91E+Z+Q56Pzcu3Jv/mP0ZhdE5iVrLPI="; }; patches = [ diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bison/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/bison/default.nix index a2ea6fb5cf81..80b488a800dd 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bison/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bison/default.nix @@ -77,5 +77,5 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/busybox/busybox-in-store.patch b/pkgs/os-specific/linux/minimal-bootstrap/busybox/busybox-in-store.patch deleted file mode 100644 index 2d356b66b3ae..000000000000 --- a/pkgs/os-specific/linux/minimal-bootstrap/busybox/busybox-in-store.patch +++ /dev/null @@ -1,23 +0,0 @@ -Allow BusyBox to be invoked as "-busybox". This is -necessary when it's run from the Nix store as -busybox during -stdenv bootstrap. ---- a/libbb/appletlib.c -+++ b/libbb/appletlib.c -@@ -947,7 +947,7 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar - static NORETURN void run_applet_and_exit(const char *name, char **argv) - { - # if ENABLE_BUSYBOX -- if (is_prefixed_with(name, "busybox")) -+ if (strstr(name, "busybox") != 0) - exit(busybox_main(/*unused:*/ 0, argv)); - # endif - # if NUM_APPLETS > 0 -@@ -1045,7 +1045,7 @@ int main(int argc UNUSED_PARAM, char **argv) - - lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv)); - # if !ENABLE_BUSYBOX -- if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox")) -+ if (argv[1] && strstr(bb_basename(argv[0]), "busybox") != 0) - argv++; - # endif - applet_name = argv[0]; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/busybox/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/busybox/static.nix deleted file mode 100644 index 6fc7b19dd3ae..000000000000 --- a/pkgs/os-specific/linux/minimal-bootstrap/busybox/static.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ - lib, - fetchurl, - bash, - gcc, - musl, - binutils, - linux-headers, - gnumake, - gnupatch, - gnused, - gnugrep, - gawk, - diffutils, - findutils, - gnutar, - bzip2, -}: -let - pname = "busybox-static"; - version = "1.36.1"; - - src = fetchurl { - url = "https://busybox.net/downloads/busybox-${version}.tar.bz2"; - hash = "sha256-uMwkyVdNgJ5yecO+NJeVxdXOtv3xnKcJ+AzeUOR94xQ="; - }; - - patches = [ - ./busybox-in-store.patch - ]; - - busyboxConfig = [ - "CC=musl-gcc" - "HOSTCC=musl-gcc" - "CFLAGS=-I${linux-headers}/include" - "KCONFIG_NOTIMESTAMP=y" - "CONFIG_PREFIX=${placeholder "out"}" - "CONFIG_STATIC=y" - ]; -in -bash.runCommand "${pname}-${version}" - { - inherit pname version; - - nativeBuildInputs = [ - gcc - musl - binutils - gnumake - gnupatch - gnused - gnugrep - gawk - diffutils - findutils - gnutar - bzip2 - ]; - - passthru.tests.get-version = - result: - bash.runCommand "${pname}-get-version-${version}" { } '' - ${result} - mkdir $out - ''; - - meta = { - description = "Tiny versions of common UNIX utilities in a single small executable"; - homepage = "https://busybox.net/"; - license = lib.licenses.gpl2Only; - platforms = lib.platforms.linux; - teams = [ lib.teams.minimal-bootstrap ]; - }; - } - '' - # Unpack - tar xf ${src} - cd busybox-${version} - - # Patch - ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} - - # Configure - BUSYBOX_FLAGS="${lib.concatStringsSep " " busyboxConfig}" - make -j $NIX_BUILD_CORES $BUSYBOX_FLAGS defconfig - - # Build - make -j $NIX_BUILD_CORES $BUSYBOX_FLAGS - - # Install - cp busybox $out - '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bzip2/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/static.nix index a597724c871a..fcdb8131957e 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bzip2/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/static.nix @@ -5,6 +5,7 @@ gcc, musl, binutils, + findutils, gnumake, gnutar, gzip, @@ -26,6 +27,7 @@ bash.runCommand "${pname}-${version}" gcc musl binutils + findutils gnumake gnutar gzip @@ -60,4 +62,8 @@ bash.runCommand "${pname}-${version}" # Install make install -j $NIX_BUILD_CORES PREFIX=$out + + # Strip + # Ignore failures, because strip may fail on non-elf files. + find $out/{bin,lib} -type f -exec strip --strip-debug {} + || true '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix index a9884b3fb5e8..680d954cc337 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix @@ -76,5 +76,5 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 7149ef167f0e..a8c44d52fc5c 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -71,12 +71,6 @@ lib.makeScope gnutar = gnutar-latest; }; - busybox-static = callPackage ./busybox/static.nix { - gcc = gcc-latest; - gnumake = gnumake-musl; - gnutar = gnutar-latest; - }; - bzip2 = callPackage ./bzip2 { tinycc = tinycc-musl; gnumake = gnumake-musl; @@ -376,7 +370,6 @@ lib.makeScope echo ${binutils.tests.get-version} echo ${binutils-static.tests.get-version} echo ${bison.tests.get-version} - echo ${busybox-static.tests.get-version} echo ${bzip2.tests.get-version} echo ${bzip2-static.tests.get-version} echo ${coreutils-musl.tests.get-version} diff --git a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/static.nix index 625819146a74..063d1f0a4100 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/static.nix @@ -77,5 +77,5 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix index 1b15ab1f1b58..aa68c36eb73b 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix @@ -76,6 +76,6 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip rm $out/bin/updatedb '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gawk/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gawk/static.nix index e6b20ad4d5e6..2abe73c2aa0c 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gawk/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/static.nix @@ -69,6 +69,6 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip rm $out/bin/gawkbug '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/static.nix index cfdd01efed61..69f8dadd22ab 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/static.nix @@ -77,6 +77,6 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip rm $out/bin/{egrep,fgrep} '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix index a1f762aa2e24..1a7da3f1aff3 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix @@ -86,5 +86,5 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnupatch/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnupatch/static.nix index 7326f3189b05..7cf5c0d1e786 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnupatch/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnupatch/static.nix @@ -77,5 +77,5 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnused/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnused/static.nix index d8d84c355590..f086c21747ff 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnused/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnused/static.nix @@ -69,5 +69,5 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnutar/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnutar/static.nix index 7e2655e8032a..3add87dc6f3a 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnutar/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnutar/static.nix @@ -69,5 +69,5 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gzip/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gzip/static.nix index 82e161329f40..5697ce229934 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gzip/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gzip/static.nix @@ -76,5 +76,5 @@ bash.runCommand "${pname}-${version}" make -j $NIX_BUILD_CORES bin_SCRIPTS= # Install - make -j $NIX_BUILD_CORES bin_SCRIPTS= install + make -j $NIX_BUILD_CORES bin_SCRIPTS= install-strip '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/musl/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/musl/static.nix index 452a4256f483..2376db89984e 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/musl/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/musl/static.nix @@ -6,6 +6,7 @@ bash, gcc, binutils, + findutils, gnumake, gnugrep, gnused, @@ -29,6 +30,7 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc binutils + findutils gnumake gnused gnugrep @@ -90,4 +92,8 @@ bash.runCommand "${pname}-${version}" sed -i 's|/bin/sh|${lib.getExe bash}|' $out/bin/* ln -s ../lib/libc.so $out/bin/ldd ln -s $(ls -d ${linux-headers}/include/* | grep -v scsi\$) $out/include/ + + # Strip + # Ignore failures, because strip may fail on non-elf files. + find $out/{bin,lib} -type f -exec strip --strip-debug {} + || true '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix index 459722161829..d1655151722e 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix @@ -77,11 +77,12 @@ bash.runCommand "${pname}-${version}" --disable-silent-rules \ --disable-nls \ --disable-shared \ + --disable-scripts \ --disable-assembler # Build make -j $NIX_BUILD_CORES # Install - make -j $NIX_BUILD_CORES install + make -j $NIX_BUILD_CORES install-strip ''