From 0150e1894f23407a9766d9a3ac3bb5911b2c0639 Mon Sep 17 00:00:00 2001 From: Aleksi Hannula Date: Mon, 6 Apr 2026 16:30:05 +0300 Subject: [PATCH 1/2] minimal-bootstrap: Use minimal gcc wrapper --- .../linux/minimal-bootstrap/default.nix | 13 ++- .../linux/minimal-bootstrap/gcc/latest.nix | 19 ++++- .../linux/minimal-bootstrap/gcc/wrapper.nix | 81 +++++++++++++++++++ .../linux/minimal-bootstrap/gcc/wrapper.sh | 51 ++++++++++++ .../linux/minimal-bootstrap/gcc/wrappercxx.sh | 57 +++++++++++++ .../linux/minimal-bootstrap/musl/static.nix | 13 ++- .../linux/minimal-bootstrap/xz/static.nix | 2 +- 7 files changed, 225 insertions(+), 11 deletions(-) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/gcc/wrapper.nix create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/gcc/wrapper.sh create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/gcc/wrappercxx.sh diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 5418c6507b4b..6afd5e5f6259 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -154,11 +154,19 @@ lib.makeScope gnutar = gnutar-latest; }; - gcc-latest = callPackage ./gcc/latest.nix { + gcc-latest-unwrapped = callPackage ./gcc/latest.nix { gcc = gcc10; gnumake = gnumake-musl; gnutar = gnutar-latest; }; + gcc-latest = callPackage ./gcc/wrapper.nix { + bash-build = bash; + gcc-unwrapped = gcc-latest-unwrapped; + targetPlatform = hostPlatform; + libc = musl; + libgcc = gcc-latest-unwrapped; + libstdcxx = gcc-latest-unwrapped; + }; gnugrep = callPackage ./gnugrep { bash = bash_2_05; @@ -294,6 +302,7 @@ lib.makeScope }; musl-static = callPackage ./musl/static.nix { + libgcc = gcc-latest-unwrapped; gcc = gcc-latest; gnumake = gnumake-musl; }; @@ -455,7 +464,7 @@ lib.makeScope }; glibc = callPackage ./glibc { - gcc = gcc-latest; + gcc = gcc-latest-unwrapped; gnumake = gnumake-musl; gnutar = gnutar-latest; gnugrep = gnugrep-static; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gcc/latest.nix b/pkgs/os-specific/linux/minimal-bootstrap/gcc/latest.nix index d003f164abad..8abf382e17d6 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gcc/latest.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gcc/latest.nix @@ -126,10 +126,12 @@ bash.runCommand "${pname}-${version}" --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ - --with-native-system-header-dir=/include \ - --with-sysroot=${musl} \ + --with-native-system-header-dir=${musl}/include \ + --with-sysroot=/ \ --enable-languages=c,c++ \ --enable-checking=release \ + --enable-static \ + --disable-shared \ --disable-bootstrap \ --disable-dependency-tracking \ --disable-libsanitizer \ @@ -144,8 +146,7 @@ bash.runCommand "${pname}-${version}" --disable-multilib \ --disable-nls \ --disable-plugin \ - --without-isl \ - --disable-shared + --without-isl # Build make -j $NIX_BUILD_CORES @@ -155,4 +156,14 @@ bash.runCommand "${pname}-${version}" # libstdc++ gdb pretty-printers + man pages are unused downstream. rm -rf $out/share/gcc-*/python $out/share/man $out/share/info + + if [ -d "$out/lib64" ]; then + shopt -s dotglob + for lib in $out/lib64/*; do + mv --no-clobber "$lib" "$out/lib/" + done + shopt -u dotglob + rm -rf "$out/lib64" + ln -s lib "$out/lib64" + fi '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gcc/wrapper.nix b/pkgs/os-specific/linux/minimal-bootstrap/gcc/wrapper.nix new file mode 100644 index 000000000000..69c0d0f93add --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gcc/wrapper.nix @@ -0,0 +1,81 @@ +{ + fetchurl, + lib, + gnutar, + xz, + bash-build, + gnused, + targetPlatform, + libc, + libgcc, + libstdcxx, + gcc-unwrapped, + binutils, + bash, +}: +let + pname = "gcc-wrapper"; + extraFlags = "-static-libgcc "; + # only supports musl for now + dynamicLinkerGlob = "${libc}/lib/libc.so"; +in +bash-build.runCommand "${pname}-${gcc-unwrapped.version}" + { + inherit pname; + version = gcc-unwrapped.version; + meta = gcc-unwrapped.meta; + nativeBuildInputs = [ gnused ]; + passthru.unwrapped = gcc-unwrapped; + } + '' + if [[ -z '${dynamicLinkerGlob}' ]]; then + echo "Don't know the name of the dynamic linker for platform '${targetPlatform.config}', so guessing instead." + dynamicLinker="${libc}/lib/ld*.so.?" + else + dynamicLinker='${dynamicLinkerGlob}' + fi + dynamicLinker=($dynamicLinker) + case ''${#dynamicLinker[@]} in + 0) echo "No dynamic linker found for platform '${targetPlatform.config}'.";; + 1) echo "Using dynamic linker: '$dynamicLinker'";; + *) echo "Multiple dynamic linkers found for platform '${targetPlatform.config}'.";; + esac + + mkdir -p "$out/bin" + for orig in ${gcc-unwrapped}/bin/*gcc ${gcc-unwrapped}/bin/*gcc-${gcc-unwrapped.version}; do + sed \ + -e 's,@bash@,${lib.getExe bash},' \ + -e "s,@gcc@,$orig," \ + -e "s,@origname@,$(basename "$orig")," \ + -e "s,@origdir@,${gcc-unwrapped}/libexec/gcc," \ + -e "s,@dynlinker@,$dynamicLinker," \ + -e 's,@libgcc@,${libgcc}/lib/gcc/${targetPlatform.config}/${libgcc.version},' \ + -e 's,@libc@,${libc}/lib,' \ + -e 's,@gccinc@,${gcc-unwrapped}/lib/gcc/${targetPlatform.config}/${libgcc.version}/include,' \ + -e 's,@binutils@,${binutils}/bin,' \ + -e 's,@extraflags@,${extraFlags},' \ + '${./wrapper.sh}' > "$out/bin/$(basename "$orig")" + chmod +x "$out/bin/$(basename "$orig")" + done + for orig in ${gcc-unwrapped}/bin/*++; do + sed \ + -e 's,@bash@,${lib.getExe bash},' \ + -e "s,@gcc@,$orig," \ + -e "s,@origname@,$(basename "$orig")," \ + -e "s,@origdir@,${gcc-unwrapped}/libexec/gcc," \ + -e "s,@dynlinker@,$dynamicLinker," \ + -e 's,@libgcc@,${libgcc}/lib/gcc/${targetPlatform.config}/${libgcc.version},' \ + -e 's,@libc@,${libc}/lib,' \ + -e 's,@libstdcxx@,${libstdcxx}/lib,' \ + -e 's,@libstdcxxinc@,${libstdcxx}/include/c++/${libstdcxx.version},' \ + -e 's,@libstdcxxarchinc@,${libstdcxx}/include/c++/${libstdcxx.version}/${targetPlatform.config},' \ + -e 's,@gccinc@,${gcc-unwrapped}/lib/gcc/${targetPlatform.config}/${libgcc.version}/include,' \ + -e 's,@binutils@,${binutils}/bin,' \ + -e 's,@extraflags@,${extraFlags},' \ + '${./wrappercxx.sh}' > "$out/bin/$(basename "$orig")" + chmod +x "$out/bin/$(basename "$orig")" + done + for orig in ${gcc-unwrapped}/bin/*cpp ${gcc-unwrapped}/bin/*-ar ${gcc-unwrapped}/bin/*-nm ${gcc-unwrapped}/bin/*-ranlib; do + ln -s "$orig" "$out/bin/$(basename "$orig")" + done + '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gcc/wrapper.sh b/pkgs/os-specific/linux/minimal-bootstrap/gcc/wrapper.sh new file mode 100644 index 000000000000..45720ce02d4a --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gcc/wrapper.sh @@ -0,0 +1,51 @@ +#!@bash@ + +if [ 1 = "$#" ] && [ "x-v" = "x$1" ]; then + # HACK! should not pass -Wl if there are no input files, otherwise libtool breaks + exec -a "@origname@" @gcc@ -v +fi + +# logic based on pkgs/build-support/bintools-wrapper/ld-wrapper.sh +# very hacky +extraRpath="" +prev="" +for param in "$@"; do + case "$prev" in + -L | -B) + case "$param" in + "$NIX_STORE"/*) + extraRpath="$extraRpath -Wl,-rpath,${param}" + ;; + *) + ;; + esac + ;; + *) + case "$param" in + -L"$NIX_STORE"/* | -B"$NIX_STORE"/*) + extraRpath="$extraRpath -Wl,-rpath,${param:2}" + ;; + "$NIX_STORE"/*.so | "$NIX_STORE"/*.so.*) + extraRpath="$extraRpath -Wl,-rpath,${param%/*}" + ;; + *) + ;; + esac + ;; + esac + prev="$param" +done + +# Order of -B is very particular. musl detection in gnulib requires that +# libc/.. comes before libgcc, otherwise libc is assumed to be glibc. +exec -a "@origname@" @gcc@ -Wl,-dynamic-linker=@dynlinker@ \ + @extraflags@ \ + $extraRpath \ + -Wl,-rpath,@libc@,-rpath,@libgcc@ \ + -B@libc@/.. \ + -B@libgcc@ \ + -B@libc@ \ + -B@origdir@ \ + -B@binutils@ \ + -isystem @gccinc@ \ + "$@" diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gcc/wrappercxx.sh b/pkgs/os-specific/linux/minimal-bootstrap/gcc/wrappercxx.sh new file mode 100644 index 000000000000..c567b0313f08 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gcc/wrappercxx.sh @@ -0,0 +1,57 @@ +#!@bash@ + +if [ 1 = "$#" ] && [ "x-v" = "x$1" ]; then + # HACK! should not pass -Wl if there are no input files, otherwise libtool breaks + exec -a "@origname@" @gcc@ -v +fi + +# logic based on pkgs/build-support/bintools-wrapper/ld-wrapper.sh +# very hacky +extraRpath="" +prev="" +for param in "$@"; do + case "$prev" in + -L | -B) + case "$param" in + "$NIX_STORE"*) + extraRpath="$extraRpath -Wl,-rpath,${param}" + ;; + *) + ;; + esac + ;; + *) + case "$param" in + -L"$NIX_STORE"/* | -B"$NIX_STORE"/*) + extraRpath="$extraRpath -Wl,-rpath,${param:2}" + ;; + "$NIX_STORE"/*.so | "$NIX_STORE"/*.so.*) + extraRpath="$extraRpath -Wl,-rpath,${param%/*}" + ;; + *) + ;; + esac + ;; + esac + prev="$param" +done + +# Order of -B is very particular. musl detection in gnulib requires that +# libc/.. comes before libgcc, otherwise libc is assumed to be glibc. +# Also, libstdcxxinc uses #include_next directives that depend on +# libc headers, so libstdcxx must come before libc. +exec -a "@origname@" @gcc@ -Wl,-dynamic-linker=@dynlinker@ \ + @extraflags@ \ + $extraRpath \ + -Wl,-rpath,@libc@,-rpath,@libgcc@,-rpath,@libstdcxx@ \ + -I @libstdcxxarchinc@ \ + -I @libstdcxxinc@ \ + -B@libc@/.. \ + -B@libc@ \ + -B@libgcc@ \ + -B@origdir@ \ + -B@binutils@ \ + -B@libstdcxx@ \ + -isystem @gccinc@ \ + "$@" + diff --git a/pkgs/os-specific/linux/minimal-bootstrap/musl/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/musl/static.nix index e85e86d8de98..27bfc63aa75f 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/musl/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/musl/static.nix @@ -13,6 +13,7 @@ gnutar, gzip, linux-headers, + libgcc, }: let inherit (import ./common.nix { inherit lib; }) pname meta; @@ -22,6 +23,10 @@ let url = "https://musl.libc.org/releases/musl-${version}.tar.gz"; hash = "sha256-1YX9O2E8ZhUfwySejtRPdwIMtebB5jWmFtP5+CRgUSo="; }; + + binutilsTargetPrefix = lib.optionalString ( + hostPlatform.config != buildPlatform.config + ) "${hostPlatform.config}-"; in bash.runCommand "${pname}-${version}" { @@ -77,23 +82,23 @@ bash.runCommand "${pname}-${version}" src/misc/wordexp.c # Configure + export CC="${binutilsTargetPrefix}gcc -B${libgcc}/lib/gcc/${hostPlatform.config}/${libgcc.version} -Wl,-rpath,${libgcc}/lib/gcc/${hostPlatform.config}/${libgcc.version}" bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ - --syslibdir=$out/lib \ - --enable-wrapper + --syslibdir=$out/lib # Build make -j $NIX_BUILD_CORES # Install make -j $NIX_BUILD_CORES install - sed -i 's|/bin/sh|${lib.getExe bash}|' $out/bin/* + mkdir -p $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 + find $out/{bin,lib} -type f -exec ${binutilsTargetPrefix}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 c663c4cf04f8..707cec7369e3 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix @@ -39,7 +39,7 @@ bash.runCommand "${pname}-${version}" gzip ]; - disallowedReferences = [ musl ]; + disallowedReferences = [ gcc ]; passthru.tests.get-version = result: From 745f12467cb3410993c1e708178c0082cea1cbea Mon Sep 17 00:00:00 2001 From: Aleksi Hannula Date: Mon, 6 Apr 2026 16:31:13 +0300 Subject: [PATCH 2/2] minimal-bootstrap: Fix tools in preparation for early cross-compilation Various packages under minimal-bootstrap explicitly use the musl gcc wrapper (especially the *-static packages). In #494106, the desire is to allow these packages to run on a host platform which may differ from the bootstrap seed platform. That host platform may be a non-musl platform, and furthermore musl may not even be available on the desired host architecture. This change aims to make the packages more generic wrt libc. It is extracted out of #494106. --- .../linux/minimal-bootstrap/bash/static.nix | 13 ++++++++++--- .../linux/minimal-bootstrap/binutils/static.nix | 7 ++----- .../linux/minimal-bootstrap/bison/default.nix | 5 +---- .../linux/minimal-bootstrap/bzip2/static.nix | 17 +++++++++++------ .../minimal-bootstrap/coreutils/static.nix | 5 +---- .../linux/minimal-bootstrap/default.nix | 4 +++- .../minimal-bootstrap/diffutils/static.nix | 8 +++----- .../minimal-bootstrap/findutils/static.nix | 6 +----- .../linux/minimal-bootstrap/gawk/static.nix | 6 +----- .../linux/minimal-bootstrap/gnugrep/static.nix | 6 +----- .../linux/minimal-bootstrap/gnum4/default.nix | 3 --- .../linux/minimal-bootstrap/gnumake/static.nix | 5 +---- .../linux/minimal-bootstrap/gnupatch/static.nix | 6 +----- .../linux/minimal-bootstrap/gnused/static.nix | 6 +----- .../linux/minimal-bootstrap/gnutar/static.nix | 6 +----- .../linux/minimal-bootstrap/gzip/static.nix | 3 --- .../linux/minimal-bootstrap/patchelf/static.nix | 5 +---- .../linux/minimal-bootstrap/python/default.nix | 6 +----- .../linux/minimal-bootstrap/xz/static.nix | 6 +----- .../linux/minimal-bootstrap/zlib/default.nix | 3 --- 20 files changed, 41 insertions(+), 85 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bash/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/bash/static.nix index 31ec4ebc5836..5418d73e352a 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bash/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bash/static.nix @@ -4,8 +4,8 @@ hostPlatform, fetchurl, bash, + gcc-buildbuild, gcc, - musl, binutils, gnumake, gnused, @@ -25,6 +25,10 @@ let url = "mirror://gnu/bash/bash-${version}.tar.gz"; sha256 = "sha256-DVzYaWX4aaJs9k9Lcb57lvkKO6iz104n6OnZ1VUPMbo="; }; + + binutilsTargetPrefix = lib.optionalString ( + hostPlatform.config != buildPlatform.config + ) "${hostPlatform.config}-"; in bash.runCommand "${pname}-${version}" { @@ -32,7 +36,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -56,6 +59,10 @@ bash.runCommand "${pname}-${version}" tar xf ${src} cd bash-${version} + export AR="${binutilsTargetPrefix}ar" + export STRIP="${binutilsTargetPrefix}strip" + export STRIPPROG="$STRIP" + # Configure bash ./configure \ --prefix=$out \ @@ -65,7 +72,7 @@ bash.runCommand "${pname}-${version}" --disable-dependency-tracking \ --disable-nls \ --enable-static-link \ - CC=musl-gcc + CC_FOR_BUILD=${gcc-buildbuild}/bin/gcc # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix index 6461f6523c0b..e29e884a2dfd 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix @@ -4,8 +4,8 @@ hostPlatform, fetchurl, bash, + gcc-buildbuild, gcc, - musl, binutils, gnumake, gnupatch, @@ -33,8 +33,6 @@ let ]; configureFlags = [ - "CC=musl-gcc" - "LDFLAGS=--static" "--prefix=${placeholder "out"}" "--build=${buildPlatform.config}" "--host=${hostPlatform.config}" @@ -42,7 +40,6 @@ let "--disable-dependency-tracking" "--disable-nls" - "--with-sysroot=/" "--enable-deterministic-archives" # depends on bison "--disable-gprofng" @@ -70,7 +67,7 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl + gcc-buildbuild binutils gnumake gnupatch diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bison/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/bison/default.nix index 80b488a800dd..fc588600d5d6 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bison/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bison/default.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -32,7 +31,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -70,8 +68,7 @@ bash.runCommand "${pname}-${version}" --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ - --disable-dependency-tracking \ - CC=musl-gcc + --disable-dependency-tracking # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bzip2/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/static.nix index 540f86112aa4..5a1b0187857f 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bzip2/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/static.nix @@ -1,9 +1,10 @@ { lib, fetchurl, + buildPlatform, + hostPlatform, bash, gcc, - musl, binutils, findutils, gnumake, @@ -18,6 +19,10 @@ let url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz"; sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb"; }; + + binutilsTargetPrefix = lib.optionalString ( + hostPlatform.config != buildPlatform.config + ) "${hostPlatform.config}-"; in bash.runCommand "${pname}-${version}" { @@ -25,7 +30,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils findutils gnumake @@ -72,9 +76,10 @@ bash.runCommand "${pname}-${version}" # Build make \ -j $NIX_BUILD_CORES \ - CC=musl-gcc \ - CFLAGS=-static \ - bzip2 + bzip2 \ + CC=${hostPlatform.config}-gcc \ + AR=${binutilsTargetPrefix}ar \ + RANLIB=${binutilsTargetPrefix}ranlib # Install mkdir -p $out/bin @@ -84,5 +89,5 @@ bash.runCommand "${pname}-${version}" # Strip # Ignore failures, because strip may fail on non-elf files. - strip --strip-debug $out/bin/bzip2 || true + ${binutilsTargetPrefix}strip --strip-debug $out/bin/bzip2 || true '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix index 2291a5dedba3..6c92f12bf58b 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -36,8 +35,7 @@ let # libstdbuf.so fails in static builds "--enable-no-install-program=stdbuf" "--enable-single-binary=symlinks" - "CC=musl-gcc" - "CFLAGS=\"-static -I${linux-headers}/include\"" + "CFLAGS=\"-I${linux-headers}/include\"" ]; in bash.runCommand "${pname}-${version}" @@ -46,7 +44,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 6afd5e5f6259..ac31f89dfa66 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -48,6 +48,7 @@ lib.makeScope }; bash-static = callPackage ./bash/static.nix { + gcc-buildbuild = gcc-latest; gcc = gcc-latest; gnumake = gnumake-musl; gnutar = gnutar-latest; @@ -60,6 +61,7 @@ lib.makeScope }; binutils-static = callPackage ./binutils/static.nix { + gcc-buildbuild = gcc-latest; gcc = gcc-latest; gnumake = gnumake-musl; gnutar = gnutar-latest; @@ -435,7 +437,7 @@ lib.makeScope echo ${gcc46.tests.get-version} echo ${gcc46-cxx.tests.hello-world} echo ${gcc10.tests.hello-world} - echo ${gcc-latest.tests.hello-world} + echo ${gcc-latest-unwrapped.tests.hello-world} '' + (lib.strings.optionalString (hostPlatform.libc == "glibc") '' echo ${gcc-glibc.tests.hello-world} diff --git a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/static.nix index f46805411c61..3ab214a9b179 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/diffutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/diffutils/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -31,7 +30,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -64,15 +62,15 @@ bash.runCommand "${pname}-${version}" cd diffutils-${version} # Configure + # Manually set strcasecmp_works, because we might be cross-compiling bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-dependency-tracking \ --disable-nls \ - CC=musl-gcc \ - CFLAGS=-static \ - ac_cv_path_PR_PROGRAM=pr + ac_cv_path_PR_PROGRAM=pr \ + gl_cv_func_strcasecmp_works=y # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix index c6b1c6e2ba0c..b183888ce033 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/findutils/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -31,7 +30,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -70,9 +68,7 @@ bash.runCommand "${pname}-${version}" --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-dependency-tracking \ - --disable-nls \ - CC=musl-gcc \ - CFLAGS=-static + --disable-nls # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gawk/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gawk/static.nix index c6175308d59d..d35bb47674d6 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gawk/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -32,7 +31,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -66,9 +64,7 @@ bash.runCommand "${pname}-${version}" --disable-extensions \ --disable-mpfr \ --disable-nls \ - --disable-pma \ - CC=musl-gcc \ - CFLAGS=-static + --disable-pma # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/static.nix index 18e71d833461..7680ce122fa4 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -31,7 +30,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -70,9 +68,7 @@ bash.runCommand "${pname}-${version}" --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-dependency-tracking \ - --disable-nls \ - CC=musl-gcc \ - CFLAGS=-static + --disable-nls # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnum4/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnum4/default.nix index 71ff15627feb..1f3edd005952 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnum4/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnum4/default.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -32,7 +31,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -71,7 +69,6 @@ bash.runCommand "${pname}-${version}" --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-dependency-tracking \ - CC=musl-gcc \ CFLAGS=-I${linux-headers}/include # Build diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix index d24f0e6d12ce..65369e28fb64 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnupatch, @@ -42,7 +41,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnupatch @@ -80,8 +78,7 @@ bash.runCommand "${pname}-${version}" --host=${hostPlatform.config} \ --disable-dependency-tracking \ --disable-nls \ - CC=musl-gcc \ - CFLAGS="-static -std=gnu17" + CFLAGS="-std=gnu17" # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnupatch/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnupatch/static.nix index ee25341e0b3b..287776101e8f 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnupatch/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnupatch/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -31,7 +30,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -69,9 +67,7 @@ bash.runCommand "${pname}-${version}" --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ - --disable-dependency-tracking \ - CC=musl-gcc \ - CFLAGS=-static + --disable-dependency-tracking # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnused/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnused/static.nix index 8ebb1791e55c..90346ee634ba 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnused/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnused/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -32,7 +31,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -62,9 +60,7 @@ bash.runCommand "${pname}-${version}" --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-dependency-tracking \ - --disable-nls \ - CC=musl-gcc \ - CFLAGS=-static + --disable-nls # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnutar/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnutar/static.nix index 07eba0ef2fe4..fb6f5ea5ba41 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnutar/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnutar/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -32,7 +31,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -62,9 +60,7 @@ bash.runCommand "${pname}-${version}" --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-dependency-tracking \ - --disable-nls \ - CC=musl-gcc \ - CFLAGS=-static + --disable-nls # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gzip/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gzip/static.nix index f449fdcd3609..76d1ef9474a3 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gzip/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gzip/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -31,7 +30,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -69,7 +67,6 @@ bash.runCommand "${pname}-${version}" --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-dependency-tracking \ - CC=musl-gcc \ CFLAGS=-static # Build diff --git a/pkgs/os-specific/linux/minimal-bootstrap/patchelf/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/patchelf/static.nix index 1bec275f7b2a..622dc2846468 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/patchelf/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/patchelf/static.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -31,7 +30,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -71,8 +69,7 @@ bash.runCommand "${pname}-${version}" --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ --disable-dependency-tracking \ - CC=musl-gcc \ - CXXFLAGS="-static -g0 -O2 -DNDEBUG -ffile-prefix-map=${gcc}=. -fmacro-prefix-map=${gcc}=." + CXXFLAGS="-g0 -O2 -DNDEBUG -ffile-prefix-map=${gcc}=. -fmacro-prefix-map=${gcc}=." # Build make -j $NIX_BUILD_CORES diff --git a/pkgs/os-specific/linux/minimal-bootstrap/python/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/python/default.nix index bc12245fd9db..ff04626a6336 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/python/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/python/default.nix @@ -5,7 +5,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnupatch, @@ -42,7 +41,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnupatch @@ -80,11 +78,9 @@ bash.runCommand "${pname}-${version}" ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} # Configure - export CC=musl-gcc export C_INCLUDE_PATH="${zlib}/include" export LIBRARY_PATH="${zlib}/lib" - export LDFLAGS="-Wl,-rpath,${zlib}/lib -L${zlib}/lib" - export LD_LIBRARY_PATH="$LIBRARY_PATH" + export LDFLAGS="-L${zlib}/lib" bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ diff --git a/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix index 707cec7369e3..cc224fdaeab9 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/xz/static.nix @@ -12,7 +12,6 @@ gawk, gnutar, gzip, - musl, }: let pname = "xz"; @@ -30,7 +29,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ binutils gcc - musl gnumake gnused gnugrep @@ -66,10 +64,8 @@ bash.runCommand "${pname}-${version}" cd xz-${version} # Configure - export CC=musl-gcc export CFLAGS="-g0 -O2 -DNDEBUG" export CXXFLAGS="$CFLAGS" - export LDFLAGS=-static bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ @@ -87,7 +83,7 @@ bash.runCommand "${pname}-${version}" --disable-assembler # Build - make -j $NIX_BUILD_CORES LDFLAGS=-all-static + make -j $NIX_BUILD_CORES # Install make -j $NIX_BUILD_CORES install-strip diff --git a/pkgs/os-specific/linux/minimal-bootstrap/zlib/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/zlib/default.nix index 845f49a48157..79a87e210934 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/zlib/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/zlib/default.nix @@ -3,7 +3,6 @@ fetchurl, bash, gcc, - musl, binutils, gnumake, gnused, @@ -26,7 +25,6 @@ bash.runCommand "${pname}-${version}" nativeBuildInputs = [ gcc - musl binutils gnumake gnused @@ -49,7 +47,6 @@ bash.runCommand "${pname}-${version}" cd zlib-${version} # Configure - export CC=musl-gcc bash ./configure --prefix=$out # Build