Merge pull request #257559 from emilytrau/minimal-glibc-removal

minimal-bootstrap.*: rebuild packages with musl
This commit is contained in:
John Ericson 2023-10-04 15:39:08 -04:00 committed by GitHub
commit 3d007e8a60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 632 additions and 341 deletions

View file

@ -4,15 +4,14 @@
, fetchurl , fetchurl
, bootBash , bootBash
, gnumake , gnumake
, gnupatch
, gnused , gnused
, gnugrep , gnugrep
, gnutar , gnutar
, gawk , gawk
, gzip , gzip
, gcc , diffutils
, glibc , tinycc
, binutils
, linux-headers
, derivationWithMeta , derivationWithMeta
, bash , bash
, coreutils , coreutils
@ -25,19 +24,26 @@ let
url = "mirror://gnu/bash/bash-${version}.tar.gz"; url = "mirror://gnu/bash/bash-${version}.tar.gz";
sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk"; sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
}; };
patches = [
# flush output for generated code
./mksignames-flush.patch
];
in in
bootBash.runCommand "${pname}-${version}" { bootBash.runCommand "${pname}-${version}" {
inherit pname version; inherit pname version;
nativeBuildInputs = [ nativeBuildInputs = [
gcc coreutils
binutils tinycc.compiler
gnumake gnumake
gnupatch
gnused gnused
gnugrep gnugrep
gnutar gnutar
gawk gawk
gzip gzip
diffutils
]; ];
passthru.runCommand = name: env: buildCommand: passthru.runCommand = name: env: buildCommand:
@ -78,22 +84,23 @@ bootBash.runCommand "${pname}-${version}" {
tar xzf ${src} tar xzf ${src}
cd bash-${version} cd bash-${version}
# Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}
# Configure # Configure
export CC="gcc -I${glibc}/include -I${linux-headers}/include" export CC="tcc -B ${tinycc.libs}/lib"
export LIBRARY_PATH="${glibc}/lib" export AR="tcc -ar"
export LIBS="-lc -lnss_files -lnss_dns -lresolv" export LD=tcc
export ac_cv_func_dlopen=no
bash ./configure \ bash ./configure \
--prefix=$out \ --prefix=$out \
--build=${buildPlatform.config} \ --build=${buildPlatform.config} \
--host=${hostPlatform.config} \ --host=${hostPlatform.config} \
--disable-nls \ --without-bash-malloc
--disable-net-redirections
# Build # Build
make SHELL=bash make -j $NIX_BUILD_CORES SHELL=bash
# Install # Install
make install make -j $NIX_BUILD_CORES install
ln -s bash $out/bin/sh 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

@ -3,35 +3,29 @@
, hostPlatform , hostPlatform
, fetchurl , fetchurl
, bash , bash
, coreutils
, gnumake , gnumake
, gnupatch , gnupatch
, gnused
, gnugrep , gnugrep
, gnutar
, gawk , gawk
, bzip2 , diffutils
, sed , gnutar
, mesBootstrap ? false, tinycc ? null , xz
, gcc ? null, glibc ? null, binutils ? null, linux-headers , tinycc
}: }:
assert mesBootstrap -> tinycc != null;
assert !mesBootstrap -> gcc != null && glibc != null && binutils != null;
let let
pname = "binutils" + lib.optionalString mesBootstrap "-mes"; # Based on https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a1-static-binutils.nix
version = "2.20.1"; pname = "binutils";
rev = "a"; version = "2.41";
src = fetchurl { src = fetchurl {
url = "mirror://gnu/binutils/binutils-${version}${rev}.tar.bz2"; url = "mirror://gnu/binutils/binutils-${version}.tar.xz";
sha256 = "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi"; hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
}; };
patches = [ 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. # Make binutils output deterministic by default.
./deterministic.patch ./deterministic.patch
]; ];
@ -40,10 +34,10 @@ let
"--prefix=${placeholder "out"}" "--prefix=${placeholder "out"}"
"--build=${buildPlatform.config}" "--build=${buildPlatform.config}"
"--host=${hostPlatform.config}" "--host=${hostPlatform.config}"
"--disable-nls"
"--disable-shared"
"--disable-werror"
"--with-sysroot=/" "--with-sysroot=/"
"--enable-deterministic-archives"
# depends on bison
"--disable-gprofng"
# Turn on --enable-new-dtags by default to make the linker set # Turn on --enable-new-dtags by default to make the linker set
# RUNPATH instead of RPATH on binaries. This is important because # RUNPATH instead of RPATH on binaries. This is important because
@ -60,15 +54,16 @@ bash.runCommand "${pname}-${version}" {
inherit pname version; inherit pname version;
nativeBuildInputs = [ nativeBuildInputs = [
(if mesBootstrap then tinycc.compiler else gcc) tinycc.compiler
gnumake gnumake
gnupatch gnupatch
gnused
gnugrep gnugrep
gnutar
gawk gawk
bzip2 diffutils
sed gnutar
] ++ lib.optional (!mesBootstrap) binutils; xz
];
passthru.tests.get-version = result: passthru.tests.get-version = result:
bash.runCommand "${pname}-get-version-${version}" {} '' bash.runCommand "${pname}-get-version-${version}" {} ''
@ -85,32 +80,35 @@ bash.runCommand "${pname}-${version}" {
}; };
} '' } ''
# Unpack # Unpack
cp ${src} binutils.tar.bz2 cp ${src} binutils.tar.xz
bunzip2 binutils.tar.bz2 unxz binutils.tar.xz
tar xf binutils.tar tar xf binutils.tar
rm binutils.tar rm binutils.tar
cd binutils-${version} cd binutils-${version}
# Patch # Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} ${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 # Configure
${if mesBootstrap then '' export CC="tcc -B ${tinycc.libs}/lib"
export CC="tcc -B ${tinycc.libs}/lib -D __GLIBC_MINOR__=6 -D MES_BOOTSTRAP=1"
export AR="tcc -ar" export AR="tcc -ar"
'' else '' export lt_cv_sys_max_cmd_len=32768
export CC="gcc -B ${glibc}/lib -I${glibc}/include -I${linux-headers}/include" export CFLAGS="-D__LITTLE_ENDIAN__=1"
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 SED=sed
bash ./configure ${lib.concatStringsSep " " configureFlags} bash ./configure ${lib.concatStringsSep " " configureFlags}
# Build # Build
make make -j $NIX_BUILD_CORES all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof
make all-ld # race condition on ld/.deps/ldwrite.Po, serialize
make -j $NIX_BUILD_CORES
# Install # Install
make install make -j $NIX_BUILD_CORES install
'' ''

View file

@ -3,7 +3,7 @@
, bash , bash
, tinycc , tinycc
, gnumake , gnumake
, gnupatch , gnutar
, gzip , gzip
}: }:
let let
@ -14,16 +14,6 @@ let
url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz"; url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";
sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb"; sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
}; };
patches = [
# mes libc has no time support, so we remove that.
# It also does not have fch{own,mod}, which we don't care about in the bootstrap
# anyway, so we can null-op those calls.
(fetchurl {
url = "https://github.com/fosslinux/live-bootstrap/raw/87e9d7db9d22b400d1c05247254ac39ee2577e80/sysa/bzip2-1.0.8/patches/mes-libc.patch";
sha256 = "14dciwib28h413skzfkh7samzh8x87dmwhldyxxphff04pvl1j3c";
})
];
in in
bash.runCommand "${pname}-${version}" { bash.runCommand "${pname}-${version}" {
inherit pname version; inherit pname version;
@ -31,13 +21,13 @@ bash.runCommand "${pname}-${version}" {
nativeBuildInputs = [ nativeBuildInputs = [
tinycc.compiler tinycc.compiler
gnumake gnumake
gnupatch gnutar
gzip gzip
]; ];
passthru.tests.get-version = result: passthru.tests.get-version = result:
bash.runCommand "${pname}-get-version-${version}" {} '' bash.runCommand "${pname}-get-version-${version}" {} ''
${result}/bin/bzip2 --version --help ${result}/bin/bzip2 --help
mkdir $out mkdir $out
''; '';
@ -50,21 +40,16 @@ bash.runCommand "${pname}-${version}" {
}; };
} '' } ''
# Unpack # Unpack
cp ${src} bzip2.tar.gz tar xzf ${src}
gunzip bzip2.tar.gz
untar --file bzip2.tar
rm bzip2.tar
cd bzip2-${version} cd bzip2-${version}
# Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches}
# Build # Build
make \ make \
CC="tcc -B ${tinycc.libs}/lib -I ." \ -j $NIX_BUILD_CORES \
CC="tcc -B ${tinycc.libs}/lib" \
AR="tcc -ar" \ AR="tcc -ar" \
bzip2 bzip2recover bzip2 bzip2recover
# Install # Install
make install PREFIX=$out make install -j $NIX_BUILD_CORES PREFIX=$out
'' ''

View file

@ -0,0 +1,74 @@
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bash
, tinycc
, gnumake
, gnugrep
, gnused
, gawk
, gnutar
, gzip
}:
let
pname = "coreutils";
version = "9.4";
src = fetchurl {
url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz";
hash = "sha256-X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
};
configureFlags = [
"--prefix=${placeholder "out"}"
"--build=${buildPlatform.config}"
"--host=${hostPlatform.config}"
# musl 1.1.x doesn't use 64bit time_t
"--disable-year2038"
# libstdbuf.so fails in static builds
"--enable-no-install-program=stdbuf"
];
in
bash.runCommand "${pname}-${version}" {
inherit pname version;
nativeBuildInputs = [
tinycc.compiler
gnumake
gnused
gnugrep
gawk
gnutar
gzip
];
passthru.tests.get-version = result:
bash.runCommand "${pname}-get-version-${version}" {} ''
${result}/bin/cat --version
mkdir $out
'';
meta = with lib; {
description = "The GNU Core Utilities";
homepage = "https://www.gnu.org/software/coreutils";
license = licenses.gpl3Plus;
maintainers = teams.minimal-bootstrap.members;
platforms = platforms.unix;
};
} ''
# Unpack
tar xzf ${src}
cd coreutils-${version}
# Configure
export CC="tcc -B ${tinycc.libs}/lib"
export LD=tcc
bash ./configure ${lib.concatStringsSep " " configureFlags}
# Build
make -j $NIX_BUILD_CORES AR="tcc -ar" MAKEINFO="true"
# Install
make -j $NIX_BUILD_CORES install MAKEINFO="true"
''

View file

@ -17,46 +17,46 @@ lib.makeScope
bash = callPackage ./bash { bash = callPackage ./bash {
bootBash = bash_2_05; bootBash = bash_2_05;
gcc = gcc2; tinycc = tinycc-musl;
glibc = glibc22; coreutils = coreutils-musl;
gawk = gawk-mes; gnumake = gnumake-musl;
gnutar = gnutar-musl;
}; };
binutils = callPackage ./binutils { binutils = callPackage ./binutils {
bash = bash_2_05; bash = bash_2_05;
gcc = gcc2; tinycc = tinycc-musl;
binutils = binutils-mes; gnumake = gnumake-musl;
glibc = glibc22; gnutar = gnutar-musl;
sed = heirloom.sed;
gawk = gawk-mes;
};
binutils-mes = callPackage ./binutils {
bash = bash_2_05;
tinycc = tinycc-mes;
sed = heirloom.sed;
gawk = gawk-mes;
mesBootstrap = true;
}; };
bzip2 = callPackage ./bzip2 { bzip2 = callPackage ./bzip2 {
bash = bash_2_05; bash = bash_2_05;
tinycc = tinycc-mes; tinycc = tinycc-musl;
gnumake = gnumake-musl;
gnutar = gnutar-musl;
}; };
coreutils = callPackage ./coreutils { tinycc = tinycc-mes; }; coreutils = callPackage ./coreutils { tinycc = tinycc-mes; };
coreutils-musl = callPackage ./coreutils/musl.nix {
bash = bash_2_05;
tinycc = tinycc-musl;
gnumake = gnumake-musl;
gnutar = gnutar-musl;
};
diffutils = callPackage ./diffutils { diffutils = callPackage ./diffutils {
bash = bash_2_05; bash = bash_2_05;
gcc = gcc2; tinycc = tinycc-musl;
glibc = glibc22; gnumake = gnumake-musl;
gawk = gawk-mes; gnutar = gnutar-musl;
}; };
findutils = callPackage ./findutils { findutils = callPackage ./findutils {
bash = bash_2_05; bash = bash_2_05;
gcc = gcc2; tinycc = tinycc-musl;
glibc = glibc22; gnumake = gnumake-musl;
gawk = gawk-mes; gnutar = gnutar-musl;
}; };
gawk-mes = callPackage ./gawk/mes.nix { gawk-mes = callPackage ./gawk/mes.nix {
@ -67,34 +67,34 @@ lib.makeScope
gawk = callPackage ./gawk { gawk = callPackage ./gawk {
bash = bash_2_05; bash = bash_2_05;
gcc = gcc2; tinycc = tinycc-musl;
glibc = glibc22; gnumake = gnumake-musl;
gnutar = gnutar-musl;
bootGawk = gawk-mes; bootGawk = gawk-mes;
}; };
gcc2 = callPackage ./gcc/2.nix { gcc2 = callPackage ./gcc/2.nix {
bash = bash_2_05; bash = bash_2_05;
gcc = gcc2-mes; gcc = gcc2-mes;
binutils = binutils-mes;
glibc = glibc22; glibc = glibc22;
}; };
gcc2-mes = callPackage ./gcc/2.nix { gcc2-mes = callPackage ./gcc/2.nix {
bash = bash_2_05; bash = bash_2_05;
tinycc = tinycc-mes; tinycc = tinycc-mes;
binutils = binutils-mes;
mesBootstrap = true; mesBootstrap = true;
}; };
gcc46 = callPackage ./gcc/4.6.nix { gcc46 = callPackage ./gcc/4.6.nix {
gcc = gcc2; tinycc = tinycc-musl;
glibc = glibc22; gnumake = gnumake-musl;
gnutar = gnutar-musl;
# FIXME: not sure why new gawk doesn't work
gawk = gawk-mes; gawk = gawk-mes;
}; };
inherit (callPackage ./glibc { inherit (callPackage ./glibc {
bash = bash_2_05; bash = bash_2_05;
gnused = gnused-mes; gnused = gnused-mes;
gawk = gawk-mes;
}) glibc22; }) glibc22;
gnugrep = callPackage ./gnugrep { gnugrep = callPackage ./gnugrep {
@ -104,26 +104,37 @@ lib.makeScope
gnumake = callPackage ./gnumake { tinycc = tinycc-mes; }; gnumake = callPackage ./gnumake { tinycc = tinycc-mes; };
gnumake-musl = callPackage ./gnumake/musl.nix {
bash = bash_2_05;
tinycc = tinycc-musl;
gawk = gawk-mes;
gnumakeBoot = gnumake;
};
gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; }; gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; };
gnused = callPackage ./gnused { gnused = callPackage ./gnused {
bash = bash_2_05; bash = bash_2_05;
gcc = gcc2; tinycc = tinycc-musl;
glibc = glibc22;
gnused = gnused-mes; gnused = gnused-mes;
}; };
gnused-mes = callPackage ./gnused { gnused-mes = callPackage ./gnused/mes.nix {
bash = bash_2_05; bash = bash_2_05;
tinycc = tinycc-mes; tinycc = tinycc-mes;
mesBootstrap = true;
}; };
gnutar = callPackage ./gnutar { gnutar = callPackage ./gnutar/mes.nix {
bash = bash_2_05; bash = bash_2_05;
tinycc = tinycc-mes; tinycc = tinycc-mes;
gnused = gnused-mes; gnused = gnused-mes;
}; };
gnutar-musl = callPackage ./gnutar/musl.nix {
bash = bash_2_05;
tinycc = tinycc-musl;
gnused = gnused-mes;
};
gzip = callPackage ./gzip { gzip = callPackage ./gzip {
bash = bash_2_05; bash = bash_2_05;
tinycc = tinycc-mes; tinycc = tinycc-mes;
@ -152,6 +163,7 @@ lib.makeScope
musl = callPackage ./musl { musl = callPackage ./musl {
gcc = gcc46; gcc = gcc46;
gnumake = gnumake-musl;
}; };
stage0-posix = callPackage ./stage0-posix { }; stage0-posix = callPackage ./stage0-posix { };
@ -167,9 +179,9 @@ lib.makeScope
xz = callPackage ./xz { xz = callPackage ./xz {
bash = bash_2_05; bash = bash_2_05;
tinycc = tinycc-mes; tinycc = tinycc-musl;
gawk = gawk-mes; gnumake = gnumake-musl;
inherit (heirloom) sed; gnutar = gnutar-musl;
}; };
inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText; inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText;
@ -178,8 +190,8 @@ lib.makeScope
echo ${bash.tests.get-version} echo ${bash.tests.get-version}
echo ${bash_2_05.tests.get-version} echo ${bash_2_05.tests.get-version}
echo ${binutils.tests.get-version} echo ${binutils.tests.get-version}
echo ${binutils-mes.tests.get-version}
echo ${bzip2.tests.get-version} echo ${bzip2.tests.get-version}
echo ${coreutils-musl.tests.get-version}
echo ${diffutils.tests.get-version} echo ${diffutils.tests.get-version}
echo ${findutils.tests.get-version} echo ${findutils.tests.get-version}
echo ${gawk-mes.tests.get-version} echo ${gawk-mes.tests.get-version}
@ -191,6 +203,7 @@ lib.makeScope
echo ${gnused.tests.get-version} echo ${gnused.tests.get-version}
echo ${gnused-mes.tests.get-version} echo ${gnused-mes.tests.get-version}
echo ${gnutar.tests.get-version} echo ${gnutar.tests.get-version}
echo ${gnutar-musl.tests.get-version}
echo ${gzip.tests.get-version} echo ${gzip.tests.get-version}
echo ${heirloom.tests.get-version} echo ${heirloom.tests.get-version}
echo ${mes.compiler.tests.get-version} echo ${mes.compiler.tests.get-version}

View file

@ -3,38 +3,35 @@
, hostPlatform , hostPlatform
, fetchurl , fetchurl
, bash , bash
, gcc , tinycc
, glibc
, binutils
, linux-headers
, gnumake , gnumake
, gnugrep , gnugrep
, gnused , gnused
, gawk , gawk
, gnutar , gnutar
, gzip , xz
}: }:
let let
pname = "diffutils"; pname = "diffutils";
version = "2.8.1"; # last version that can be built by tinycc-musl 0.9.27
version = "3.8";
src = fetchurl { src = fetchurl {
url = "mirror://gnu/diffutils/diffutils-${version}.tar.gz"; url = "mirror://gnu/diffutils/diffutils-${version}.tar.xz";
sha256 = "0nizs9r76aiymzasmj1jngl7s71jfzl9xfziigcls8k9n141f065"; hash = "sha256-pr3X0bMSZtEcT03mwbdI1GB6sCMa9RiPwlM9CuJDj+w=";
}; };
in in
bash.runCommand "${pname}-${version}" { bash.runCommand "${pname}-${version}" {
inherit pname version; inherit pname version;
nativeBuildInputs = [ nativeBuildInputs = [
gcc tinycc.compiler
binutils
gnumake gnumake
gnused gnused
gnugrep gnugrep
gawk gawk
gnutar gnutar
gzip xz
]; ];
passthru.tests.get-version = result: passthru.tests.get-version = result:
@ -52,21 +49,23 @@ bash.runCommand "${pname}-${version}" {
}; };
} '' } ''
# Unpack # Unpack
tar xzf ${src} cp ${src} diffutils.tar.xz
unxz diffutils.tar.xz
tar xf diffutils.tar
rm diffutils.tar
cd diffutils-${version} cd diffutils-${version}
# Configure # Configure
export C_INCLUDE_PATH="${glibc}/include:${linux-headers}/include" export CC="tcc -B ${tinycc.libs}/lib"
export LIBRARY_PATH="${glibc}/lib" export LD=tcc
export LIBS="-lc -lnss_files -lnss_dns -lresolv"
bash ./configure \ bash ./configure \
--prefix=$out \ --prefix=$out \
--build=${buildPlatform.config} \ --build=${buildPlatform.config} \
--host=${hostPlatform.config} --host=${hostPlatform.config}
# Build # Build
make make -j $NIX_BUILD_CORES AR="tcc -ar"
# Install # Install
make install make -j $NIX_BUILD_CORES install
'' ''

View file

@ -3,38 +3,34 @@
, hostPlatform , hostPlatform
, fetchurl , fetchurl
, bash , bash
, gcc , tinycc
, glibc
, binutils
, linux-headers
, gnumake , gnumake
, gnugrep , gnugrep
, gnused , gnused
, gawk , gawk
, gnutar , gnutar
, gzip , xz
}: }:
let let
pname = "findutils"; pname = "findutils";
version = "4.4.2"; version = "4.9.0";
src = fetchurl { src = fetchurl {
url = "mirror://gnu/findutils/findutils-${version}.tar.gz"; url = "mirror://gnu/findutils/findutils-${version}.tar.xz";
sha256 = "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks3"; hash = "sha256-or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
}; };
in in
bash.runCommand "${pname}-${version}" { bash.runCommand "${pname}-${version}" {
inherit pname version; inherit pname version;
nativeBuildInputs = [ nativeBuildInputs = [
gcc tinycc.compiler
binutils
gnumake gnumake
gnused gnused
gnugrep gnugrep
gawk gawk
gnutar gnutar
gzip xz
]; ];
passthru.tests.get-version = result: passthru.tests.get-version = result:
@ -52,21 +48,28 @@ bash.runCommand "${pname}-${version}" {
}; };
} '' } ''
# Unpack # Unpack
tar xzf ${src} cp ${src} findutils.tar.xz
unxz findutils.tar.xz
tar xf findutils.tar
rm findutils.tar
cd findutils-${version} cd findutils-${version}
# Patch
# configure fails to accurately detect PATH_MAX support
sed -i 's/chdir_long/chdir/' gl/lib/save-cwd.c
# Configure # Configure
export C_INCLUDE_PATH="${glibc}/include:${linux-headers}/include" export CC="tcc -B ${tinycc.libs}/lib"
export LIBRARY_PATH="${glibc}/lib" export AR="tcc -ar"
export LIBS="-lc -lnss_files -lnss_dns -lresolv" export LD=tcc
bash ./configure \ bash ./configure \
--prefix=$out \ --prefix=$out \
--build=${buildPlatform.config} \ --build=${buildPlatform.config} \
--host=${hostPlatform.config} --host=${hostPlatform.config}
# Build # Build
make make -j $NIX_BUILD_CORES
# Install # Install
make install make -j $NIX_BUILD_CORES install
'' ''

View file

@ -3,10 +3,7 @@
, hostPlatform , hostPlatform
, fetchurl , fetchurl
, bash , bash
, gcc , tinycc
, glibc
, binutils
, linux-headers
, gnumake , gnumake
, gnugrep , gnugrep
, gnused , gnused
@ -17,21 +14,18 @@
let let
inherit (import ./common.nix { inherit lib; }) meta; inherit (import ./common.nix { inherit lib; }) meta;
pname = "gawk"; pname = "gawk";
# >= 4.2.0 fails to cleanly build. may be worth investigating in the future. version = "5.2.2";
# for now this version is sufficient to build glibc 2.16
version = "4.1.4";
src = fetchurl { src = fetchurl {
url = "mirror://gnu/gawk/gawk-${version}.tar.gz"; url = "mirror://gnu/gawk/gawk-${version}.tar.gz";
sha256 = "0dadjkpyyizmyd0l098qps8lb39r0vrz3xl3hwz2cmjs5c70h0wc"; hash = "sha256-lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA=";
}; };
in in
bash.runCommand "${pname}-${version}" { bash.runCommand "${pname}-${version}" {
inherit pname version meta; inherit pname version meta;
nativeBuildInputs = [ nativeBuildInputs = [
gcc tinycc.compiler
binutils
gnumake gnumake
gnused gnused
gnugrep gnugrep
@ -51,18 +45,17 @@ bash.runCommand "${pname}-${version}" {
cd gawk-${version} cd gawk-${version}
# Configure # Configure
export C_INCLUDE_PATH="${glibc}/include:${linux-headers}/include" export CC="tcc -B ${tinycc.libs}/lib"
export LIBRARY_PATH="${glibc}/lib" export AR="tcc -ar"
export LIBS="-lc -lnss_files -lnss_dns -lresolv" export LD=tcc
bash ./configure \ bash ./configure \
--prefix=$out \ --prefix=$out \
--build=${buildPlatform.config} \ --build=${buildPlatform.config} \
--host=${hostPlatform.config} --host=${hostPlatform.config}
# Build # Build
make gawk make -j $NIX_BUILD_CORES
# Install # Install
install -D gawk $out/bin/gawk make -j $NIX_BUILD_CORES install
ln -s gawk $out/bin/awk
'' ''

View file

@ -3,9 +3,7 @@
, hostPlatform , hostPlatform
, fetchurl , fetchurl
, bash , bash
, gcc , tinycc
, glibc
, linux-headers
, binutils , binutils
, gnumake , gnumake
, gnupatch , gnupatch
@ -32,23 +30,10 @@ let
}; };
patches = [ patches = [
# This patch enables building gcc-4.6.4 using gcc-2.95.3 and glibc-2.2.5 # Remove hardcoded NATIVE_SYSTEM_HEADER_DIR
# * Tweak Makefile to allow overriding NATIVE_SYSTEM_HEADER_DIR using #:makeflags ./no-system-headers.patch
# * Add missing limits.h include.
# * Add SSIZE_MAX define. The SSIZE_MAX define has been added to Mes
# upstream and can be removed with the next Mes release.
# * Remove -fbuilding-libgcc flag, it assumes features being present from a
# newer gcc or glibc.
# * [MES_BOOTSTRAP_GCC]: Disable threads harder.
(fetchurl {
url = "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/patches/gcc-boot-4.6.4.patch?id=50249cab3a98839ade2433456fe618acc6f804a5";
sha256 = "1zzd8gnihw6znrgb6c6pfsmm0vix89xw3giv1nnsykm57j0v3z0d";
})
./libstdc++-target.patch
]; ];
# To reduce the set of pre-built bootstrap inputs, build
# GMP & co. from GCC.
gmpVersion = "4.3.2"; gmpVersion = "4.3.2";
gmp = fetchurl { gmp = fetchurl {
url = "mirror://gnu/gmp/gmp-${gmpVersion}.tar.gz"; url = "mirror://gnu/gmp/gmp-${gmpVersion}.tar.gz";
@ -71,7 +56,7 @@ bash.runCommand "${pname}-${version}" {
inherit pname version; inherit pname version;
nativeBuildInputs = [ nativeBuildInputs = [
gcc tinycc.compiler
binutils binutils
gnumake gnumake
gnupatch gnupatch
@ -84,10 +69,6 @@ bash.runCommand "${pname}-${version}" {
gzip gzip
]; ];
# condition in ./libcpp/configure requires `env` which is not available in this coreutils
am_cv_CXX_dependencies_compiler_type = "gcc";
am_cv_CC_dependencies_compiler_type = "gcc";
passthru.tests.get-version = result: passthru.tests.get-version = result:
bash.runCommand "${pname}-get-version-${version}" {} '' bash.runCommand "${pname}-get-version-${version}" {} ''
${result}/bin/gcc --version ${result}/bin/gcc --version
@ -118,18 +99,21 @@ bash.runCommand "${pname}-${version}" {
${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}
# Configure # Configure
export C_INCLUDE_PATH="${gcc}/lib/gcc-lib/${hostPlatform.config}/${gcc.version}/include:${linux-headers}/include:${glibc}/include:$(pwd)/mpfr/src" export CC="tcc -B ${tinycc.libs}/lib"
export C_INCLUDE_PATH="${tinycc.libs}/include:$(pwd)/mpfr/src"
export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH" export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH"
export LDFLAGS="-B${glibc}/lib -Wl,-dynamic-linker -Wl,${glibc}"
export LDFLAGS_FOR_TARGET=$LDFLAGS # Avoid "Link tests are not allowed after GCC_NO_EXECUTABLES"
export LIBRARY_PATH="${glibc}/lib:${gcc}/lib" export lt_cv_shlibpath_overrides_runpath=yes
export LIBS="-lc -lnss_files -lnss_dns -lresolv" export ac_cv_func_memcpy=yes
export ac_cv_func_strerror=yes
bash ./configure \ bash ./configure \
--prefix=$out \ --prefix=$out \
--build=${buildPlatform.config} \ --build=${buildPlatform.config} \
--host=${hostPlatform.config} \ --host=${hostPlatform.config} \
--with-native-system-header-dir=${glibc}/include \ --with-native-system-header-dir=${tinycc.libs}/include \
--with-build-sysroot=${glibc}/include \ --with-build-sysroot=${tinycc.libs}/include \
--disable-bootstrap \ --disable-bootstrap \
--disable-decimal-float \ --disable-decimal-float \
--disable-libatomic \ --disable-libatomic \
@ -146,7 +130,7 @@ bash.runCommand "${pname}-${version}" {
--disable-multilib \ --disable-multilib \
--disable-plugin \ --disable-plugin \
--disable-threads \ --disable-threads \
--enable-languages=c,c++ \ --enable-languages=c \
--enable-static \ --enable-static \
--disable-shared \ --disable-shared \
--enable-threads=single \ --enable-threads=single \
@ -154,8 +138,8 @@ bash.runCommand "${pname}-${version}" {
--disable-build-with-cxx --disable-build-with-cxx
# Build # Build
make make -j $NIX_BUILD_CORES
# Install # Install
make install make -j $NIX_BUILD_CORES install
'' ''

View file

@ -0,0 +1,11 @@
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -440,7 +440,7 @@ LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
LTO_SYMTAB_H = $(srcdir)/../include/lto-symtab.h
# Default native SYSTEM_HEADER_DIR, to be overridden by targets.
-NATIVE_SYSTEM_HEADER_DIR = /usr/include
+# NATIVE_SYSTEM_HEADER_DIR = /usr/include
# Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@

View file

@ -12,13 +12,13 @@
, gzip , gzip
, gawk , gawk
, heirloom , heirloom
, binutils-mes , binutils
, linux-headers , linux-headers
}: }:
let let
pname = "glibc"; pname = "glibc";
buildGlibc = { version, src, patches, configureFlags, gcc, binutils, CC, CPP }: buildGlibc = { version, src, patches, configureFlags, gcc, CC, CPP }:
bash.runCommand "${pname}-${version}" { bash.runCommand "${pname}-${version}" {
inherit pname version; inherit pname version;
@ -114,7 +114,6 @@ in
]; ];
gcc = gcc2-mes; gcc = gcc2-mes;
binutils = binutils-mes;
CC = "gcc -D MES_BOOTSTRAP=1 -D BOOTSTRAP_GLIBC=1 -L $(pwd)"; CC = "gcc -D MES_BOOTSTRAP=1 -D BOOTSTRAP_GLIBC=1 -L $(pwd)";
CPP = "gcc -E -D MES_BOOTSTRAP=1 -D BOOTSTRAP_GLIBC=1"; CPP = "gcc -E -D MES_BOOTSTRAP=1 -D BOOTSTRAP_GLIBC=1";
}; };

View file

@ -0,0 +1,82 @@
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bash
, tinycc
, gnumakeBoot
, gnupatch
, gnused
, gnugrep
, gawk
, gnutar
, gzip
}:
let
pname = "gnumake-musl";
version = "4.4.1";
src = fetchurl {
url = "mirror://gnu/make/make-${version}.tar.gz";
hash = "sha256-3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
};
patches = [
# Replaces /bin/sh with sh, see patch file for reasoning
./0001-No-impure-bin-sh.patch
# Purity: don't look for library dependencies (of the form `-lfoo') in /lib
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
# included Makefiles, don't look in /usr/include and friends.
./0002-remove-impure-dirs.patch
];
in
bash.runCommand "${pname}-${version}" {
inherit pname version;
nativeBuildInputs = [
tinycc.compiler
gnumakeBoot
gnupatch
gnused
gnugrep
gawk
gnutar
gzip
];
passthru.tests.get-version = result:
bash.runCommand "${pname}-get-version-${version}" {} ''
${result}/bin/make --version
mkdir $out
'';
meta = with lib; {
description = "A tool to control the generation of non-source files from sources";
homepage = "https://www.gnu.org/software/make";
license = licenses.gpl3Plus;
maintainers = teams.minimal-bootstrap.members;
mainProgram = "make";
platforms = platforms.unix;
};
} ''
# Unpack
tar xzf ${src}
cd make-${version}
# Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}
# Configure
export CC="tcc -B ${tinycc.libs}/lib"
export LD=tcc
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config}
# Build
make AR="tcc -ar"
# Install
make install
''

View file

@ -0,0 +1,12 @@
{ lib }:
{
meta = with lib; {
description = "GNU sed, a batch stream editor";
homepage = "https://www.gnu.org/software/sed";
license = licenses.gpl3Plus;
maintainers = teams.minimal-bootstrap.members;
mainProgram = "sed";
platforms = platforms.unix;
};
}

View file

@ -4,41 +4,34 @@
, fetchurl , fetchurl
, bash , bash
, gnumake , gnumake
, mesBootstrap ? false, tinycc ? null , tinycc
, gcc ? null, glibc ? null, binutils ? null, gnused ? null, linux-headers, gnugrep , gnused
, gnugrep
, gnutar
, gzip
}: }:
assert mesBootstrap -> tinycc != null;
assert !mesBootstrap -> gcc != null && glibc != null && binutils != null && gnused != null;
let let
pname = "gnused" + lib.optionalString mesBootstrap "-mes"; inherit (import ./common.nix { inherit lib; }) meta;
# last version that can be compiled with mes-libc pname = "gnused";
version = "4.0.9"; # last version that can be bootstrapped with our slightly buggy gnused-mes
version = "4.2";
src = fetchurl { src = fetchurl {
url = "mirror://gnu/sed/sed-${version}.tar.gz"; url = "mirror://gnu/sed/sed-${version}.tar.gz";
sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3"; hash = "sha256-20XNY/0BDmUFN9ZdXfznaJplJ0UjZgbl5ceCk3Jn2YM=";
};
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem
makefile = fetchurl {
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk";
sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya";
}; };
in in
bash.runCommand "${pname}-${version}" { bash.runCommand "${pname}-${version}" {
inherit pname version; inherit pname version meta;
nativeBuildInputs = [ nativeBuildInputs = [
gnumake gnumake
] ++ lib.optionals mesBootstrap [
tinycc.compiler tinycc.compiler
] ++ lib.optionals (!mesBootstrap) [
gcc
glibc
binutils
gnused gnused
gnugrep gnugrep
gnutar
gzip
]; ];
passthru.tests.get-version = result: passthru.tests.get-version = result:
@ -46,51 +39,25 @@ bash.runCommand "${pname}-${version}" {
${result}/bin/sed --version ${result}/bin/sed --version
mkdir ''${out} mkdir ''${out}
''; '';
meta = with lib; {
description = "GNU sed, a batch stream editor";
homepage = "https://www.gnu.org/software/sed";
license = licenses.gpl3Plus;
maintainers = teams.minimal-bootstrap.members;
mainProgram = "sed";
platforms = platforms.unix;
};
} ('' } (''
# Unpack # Unpack
ungz --file ${src} --output sed.tar tar xzf ${src}
untar --file sed.tar
rm sed.tar
cd sed-${version} cd sed-${version}
'' + lib.optionalString mesBootstrap ''
# Configure # Configure
cp ${makefile} Makefile export CC="tcc -B ${tinycc.libs}/lib"
catm config.h export LD=tcc
# Build
make \
CC="tcc -B ${tinycc.libs}/lib" \
LIBC=mes
'' + lib.optionalString (!mesBootstrap) ''
# Configure
export CC="gcc -I${glibc}/include -I${linux-headers}/include"
export LIBRARY_PATH="${glibc}/lib"
export LIBS="-lc -lnss_files -lnss_dns -lresolv"
chmod +x configure
./configure \ ./configure \
--build=${buildPlatform.config} \ --build=${buildPlatform.config} \
--host=${hostPlatform.config} \ --host=${hostPlatform.config} \
--disable-shared \ --disable-shared \
--disable-nls \ --disable-nls \
--disable-dependency-tracking \ --disable-dependency-tracking \
--without-included-regex \
--prefix=$out --prefix=$out
# Build # Build
make make AR="tcc -ar"
'' + ''
# Install # Install
make install PREFIX=$out make install
'') '')

View file

@ -0,0 +1,59 @@
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bash
, gnumake
, tinycc
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "gnused-mes";
# last version that can be compiled with mes-libc
version = "4.0.9";
src = fetchurl {
url = "mirror://gnu/sed/sed-${version}.tar.gz";
sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3";
};
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem
makefile = fetchurl {
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk";
sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya";
};
in
bash.runCommand "${pname}-${version}" {
inherit pname version meta;
nativeBuildInputs = [
gnumake
tinycc.compiler
];
passthru.tests.get-version = result:
bash.runCommand "${pname}-get-version-${version}" {} ''
${result}/bin/sed --version
mkdir ''${out}
'';
} (''
# Unpack
ungz --file ${src} --output sed.tar
untar --file sed.tar
rm sed.tar
cd sed-${version}
# Configure
cp ${makefile} Makefile
catm config.h
# Build
make \
CC="tcc -B ${tinycc.libs}/lib" \
LIBC=mes
# Install
make install PREFIX=$out
'')

View file

@ -0,0 +1,70 @@
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bash
, tinycc
, gnumake
, gnugrep
, gnused
}:
let
# gnutar with musl preserves modify times, allowing make to not try
# rebuilding pregenerated files
pname = "gnutar-musl";
version = "1.12";
src = fetchurl {
url = "mirror://gnu/tar/tar-${version}.tar.gz";
hash = "sha256-xsN+iIsTbM76uQPFEUn0t71lnWnUrqISRfYQU6V6pgo=";
};
in
bash.runCommand "${pname}-${version}" {
inherit pname version;
nativeBuildInputs = [
tinycc.compiler
gnumake
gnused
gnugrep
];
passthru.tests.get-version = result:
bash.runCommand "${pname}-get-version-${version}" {} ''
${result}/bin/tar --version
mkdir $out
'';
meta = with lib; {
description = "GNU implementation of the `tar' archiver";
homepage = "https://www.gnu.org/software/tar";
license = licenses.gpl3Plus;
maintainers = teams.minimal-bootstrap.members;
mainProgram = "tar";
platforms = platforms.unix;
};
} ''
# Unpack
ungz --file ${src} --output tar.tar
untar --file tar.tar
rm tar.tar
cd tar-${version}
# Configure
export CC="tcc -B ${tinycc.libs}/lib"
export LD=tcc
export ac_cv_sizeof_unsigned_long=4
export ac_cv_sizeof_long_long=8
export ac_cv_header_netdb_h=no
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-nls
# Build
make AR="tcc -ar"
# Install
make install
''

View file

@ -58,6 +58,8 @@ let
# url = "${liveBootstrap}/patches/stdio_flush_on_exit.patch"; # url = "${liveBootstrap}/patches/stdio_flush_on_exit.patch";
# hash = "sha256-/z5ze3h3QTysay8nRvyvwPv3pmTcKptdkBIaMCoeLDg="; # hash = "sha256-/z5ze3h3QTysay8nRvyvwPv3pmTcKptdkBIaMCoeLDg=";
# }) # })
# HACK: always flush stdio immediately
./always-flush.patch
(fetchurl { (fetchurl {
url = "${liveBootstrap}/patches/va_list.patch"; url = "${liveBootstrap}/patches/va_list.patch";
hash = "sha256-UmcMIl+YCi3wIeVvjbsCyqFlkyYsM4ECNwTfXP+s7vg="; hash = "sha256-UmcMIl+YCi3wIeVvjbsCyqFlkyYsM4ECNwTfXP+s7vg=";

View file

@ -0,0 +1,12 @@
diff --git src/env/__libc_start_main.c src/env/__libc_start_main.c
index 8fbe526..9476c22 100644
--- src/env/__libc_start_main.c
+++ src/env/__libc_start_main.c
@@ -91,6 +91,7 @@ static int libc_start_main_stage2(int (*main)(int,char **,char **), int argc, ch
__libc_start_init();
/* Pass control to the application */
+ setbuf(stdout, NULL);
exit(main(argc, argv, envp));
return 0;
}

View file

@ -70,8 +70,8 @@ bash.runCommand "${pname}-${version}" {
--host=${hostPlatform.config} --host=${hostPlatform.config}
# Build # Build
make make -j $NIX_BUILD_CORES
# Install # Install
make install make -j $NIX_BUILD_CORES install
'' ''

View file

@ -0,0 +1,13 @@
--- tccelf.c
+++ tccelf.c
@@ -710,8 +710,9 @@ ST_FUNC int set_elf_sym(Section *s, addr_t value, unsigned long size,
#if 0
printf("new_bind=%x new_shndx=%x new_vis=%x old_bind=%x old_shndx=%x old_vis=%x\n",
sym_bind, shndx, new_vis, esym_bind, esym->st_shndx, esym_vis);
-#endif
tcc_error_noabort("'%s' defined twice", name);
+#endif
+ goto do_patch;
}
} else {
esym->st_other = other;

View file

@ -0,0 +1,21 @@
--- tccgen.c
+++ tccgen.c
@@ -4941,7 +4941,7 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
next();
n = -1;
t1 = 0;
- if (td & TYPE_PARAM) while (1) {
+ while (1) {
/* XXX The optional type-quals and static should only be accepted
in parameter decls. The '*' as well, and then even only
in prototypes (not function defs). */
@@ -4972,7 +4972,8 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
}
break;
- } else if (tok != ']') {
+ }
+ if (tok != ']') {
if (!local_stack || (storage & VT_STATIC))
vpushi(expr_const());
else {

View file

@ -1,9 +1,3 @@
# Build steps adapted from https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/tcc-0.9.27/tcc-musl-pass1.sh
#
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
{ lib { lib
, fetchurl , fetchurl
, callPackage , callPackage
@ -12,38 +6,28 @@
, musl , musl
, gnupatch , gnupatch
, gnutar , gnutar
, bzip2 , gzip
}: }:
let let
pname = "tinycc-musl"; pname = "tinycc-musl";
version = "0.9.27"; # next commit introduces use of realpath (unsupported in mes-libc)
version = "unstable-2023-07-10";
rev = "fd6d2180c5c801bb0b4c5dde27d61503059fc97d";
src = fetchurl { src = fetchurl {
url = "https://download.savannah.gnu.org/releases/tinycc/tcc-${version}.tar.bz2"; url = "https://repo.or.cz/tinycc.git/snapshot/${rev}.tar.gz";
hash = "sha256-3iOvePypDOMt/y3UWzQysjNHQLubt7Bb9g/b/Dls65w="; hash = "sha256-R81SNbEmh4s9FNQxCWZwUiMCYRkkwOHAdRf0aMnnRiA=";
}; };
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/424aa5be38a3023aa6842883a3954599b1597986/sysa/tcc-0.9.27/tcc-musl-pass1.sh
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/424aa5be38a3023aa6842883a3954599b1597986/sysa/tcc-0.9.27";
patches = [ patches = [
(fetchurl { ./ignore-duplicate-symbols.patch
url = "${liveBootstrap}/patches/ignore-duplicate-symbols.patch"; ./ignore-static-inside-array.patch
hash = "sha256-6Js8HkzjYlA8ETxeEYRWu+03OJI60NvR5h1QPkcMTlQ="; ./static-link.patch
})
(fetchurl {
url = "${liveBootstrap}/patches/ignore-static-inside-array.patch";
hash = "sha256-IF4RevLGjzRBuYqhuyG7+x6SVljzMAsYRKicNsmtbDY=";
})
(fetchurl {
url = "${liveBootstrap}/patches/static-link.patch";
hash = "sha256-gX/hJ9a/0Zg29KIBUme+mOA8WrPQvp0SvojP8DN9mSI=";
})
]; ];
meta = with lib; { meta = with lib; {
description = "Small, fast, and embeddable C compiler and interpreter"; description = "Small, fast, and embeddable C compiler and interpreter";
homepage = "http://savannah.nongnu.org/projects/tinycc"; homepage = "https://repo.or.cz/w/tinycc.git";
license = licenses.lgpl21Only; license = licenses.lgpl21Only;
maintainers = teams.minimal-bootstrap.members; maintainers = teams.minimal-bootstrap.members;
platforms = [ "i686-linux" ]; platforms = [ "i686-linux" ];
@ -56,15 +40,12 @@ let
tinycc-bootstrappable.compiler tinycc-bootstrappable.compiler
gnupatch gnupatch
gnutar gnutar
bzip2 gzip
]; ];
} '' } ''
# Unpack # Unpack
cp ${src} tinycc.tar.bz2 tar xzf ${src}
bunzip2 tinycc.tar.bz2 cd tinycc-${builtins.substring 0 7 rev}
tar xf tinycc.tar
rm tinycc.tar
cd tcc-${version}
# Patch # Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches} ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches}
@ -77,6 +58,13 @@ let
# but when linked with musl it is. # but when linked with musl it is.
ln -s ${musl}/lib/libtcc1.a ./libtcc1.a ln -s ${musl}/lib/libtcc1.a ./libtcc1.a
tcc \
-B ${tinycc-bootstrappable.libs}/lib \
-DC2STR \
-o c2str \
conftest.c
./c2str include/tccdefs.h tccdefs_.h
tcc -v \ tcc -v \
-static \ -static \
-o tcc-musl \ -o tcc-musl \
@ -92,6 +80,9 @@ let
-D CONFIG_USE_LIBGCC=1 \ -D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \ -D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \ -D ONE_SOURCE=1 \
-D TCC_MUSL=1 \
-D CONFIG_TCC_PREDEFS=1 \
-D CONFIG_TCC_SEMLOCK=0 \
-B . \ -B . \
-B ${tinycc-bootstrappable.libs}/lib \ -B ${tinycc-bootstrappable.libs}/lib \
tcc.c tcc.c
@ -117,13 +108,17 @@ let
-D CONFIG_USE_LIBGCC=1 \ -D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \ -D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \ -D ONE_SOURCE=1 \
-D TCC_MUSL=1 \
-D CONFIG_TCC_PREDEFS=1 \
-D CONFIG_TCC_SEMLOCK=0 \
-B . \ -B . \
-B ${musl}/lib \ -B ${musl}/lib \
tcc.c tcc.c
# libtcc1.a # libtcc1.a
rm -f libtcc1.a rm -f libtcc1.a
./tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c ./tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
./tcc-musl -ar cr libtcc1.a libtcc1.o ./tcc-musl -c -D HAVE_CONFIG_H=1 lib/alloca.S
./tcc-musl -ar cr libtcc1.a libtcc1.o alloca.o
# Install # Install
install -D tcc-musl $out/bin/tcc install -D tcc-musl $out/bin/tcc
@ -151,5 +146,10 @@ in
libs = bash.runCommand "${pname}-${version}-libs" { libs = bash.runCommand "${pname}-${version}-libs" {
inherit pname version meta; inherit pname version meta;
} "install -D ${tinycc-musl}/lib/libtcc1.a $out/lib/libtcc1.a"; } ''
mkdir $out
cp -r ${musl}/* $out
chmod +w $out/lib/libtcc1.a
cp ${tinycc-musl}/lib/libtcc1.a $out/lib/libtcc1.a
'';
} }

View file

@ -0,0 +1,10 @@
--- libtcc.c
+++ libtcc.c
@@ -793,6 +793,7 @@ LIBTCCAPI TCCState *tcc_new(void)
s->gnu_ext = 1;
s->tcc_ext = 1;
+ s->static_link = 1;
s->nocommon = 1;
s->dollars_in_identifiers = 1; /*on by default like in gcc/clang*/
s->cversion = 199901; /* default unless -std=c11 is supplied */

View file

@ -5,18 +5,19 @@
, bash , bash
, tinycc , tinycc
, gnumake , gnumake
, gnused
, gnugrep , gnugrep
, gawk , gawk
, sed , gnutar
, gzip
}: }:
let let
pname = "xz"; pname = "xz";
# >=5.2 uses poll.h, unsupported by meslibc version = "5.4.3";
version = "5.0.8";
src = fetchurl { src = fetchurl {
url = "https://tukaani.org/xz/xz-${version}.tar.bz2"; url = "https://tukaani.org/xz/xz-${version}.tar.gz";
sha256 = "1nkb68dyrf16xwyqichcy1vhgbfg20dxz459rcsdx85h1gczk1i2"; hash = "sha256-HDguC8Lk4K9YOYqQPdYv/35RAXHS3keh6+BtFSjpt+k=";
}; };
in in
bash.runCommand "${pname}-${version}" { bash.runCommand "${pname}-${version}" {
@ -25,9 +26,11 @@ bash.runCommand "${pname}-${version}" {
nativeBuildInputs = [ nativeBuildInputs = [
tinycc.compiler tinycc.compiler
gnumake gnumake
gnused
gnugrep gnugrep
gawk gawk
sed gnutar
gzip
]; ];
passthru.tests.get-version = result: passthru.tests.get-version = result:
@ -45,34 +48,23 @@ bash.runCommand "${pname}-${version}" {
}; };
} '' } ''
# Unpack # Unpack
unbz2 --file ${src} --output xz.tar tar xzf ${src}
untar --file xz.tar
rm xz.tar
cd xz-${version} cd xz-${version}
# Configure # Configure
export CC="tcc -B ${tinycc.libs}/lib -include${./stubs.h}" export CC="tcc -B ${tinycc.libs}/lib"
export CPP="tcc -E"
export LD=tcc
export AR="tcc -ar" export AR="tcc -ar"
export SED=sed export LD=tcc
export ac_cv_prog_cc_c99=
export ac_cv_header_fcntl_h=yes
export ac_cv_header_limits_h=yes
export ac_cv_header_sys_time_h=yes
export ac_cv_func_utime=no
bash ./configure \ bash ./configure \
--prefix=$out \ --prefix=$out \
--build=${buildPlatform.config} \ --build=${buildPlatform.config} \
--host=${hostPlatform.config} \ --host=${hostPlatform.config} \
--disable-shared \ --disable-shared \
--disable-nls \
--disable-threads \
--disable-assembler --disable-assembler
# Build # Build
make all make -j $NIX_BUILD_CORES
# Install # Install
make install make -j $NIX_BUILD_CORES install
'' ''

View file

@ -1,25 +0,0 @@
#define sig_atomic_t int
#define SSIZE_MAX LONG_MAX
#define O_NOCTTY 0400
#define O_NONBLOCK 04000
#define S_ISVTX 01000
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
int fchmod (int fd, int mode)
{
return 0;
}
int fchown (int fd, int owner, int group)
{
return 0;
}
#include <signal.h>
int sigfillset (sigset_t * set)
{
return 0;
}