From 60ae6bf75109fb902dc67f45488f5c2ec13eaf8e Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Mon, 18 Sep 2023 21:08:25 -0700 Subject: [PATCH] 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"; };