minimal-bootstrap.bash: build with musl

This commit is contained in:
Emily Trau 2023-09-25 00:12:23 -07:00
parent 25a264c6c4
commit 1c1962f975
4 changed files with 35 additions and 19 deletions

View File

@ -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
''

View File

@ -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

View File

@ -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;

View File

@ -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