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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
''
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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} \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user