feat: bzip2, gcc v8, gcc v13, gnutar

This commit is contained in:
Jake Hamilton 2024-06-07 05:32:10 -07:00
parent 760b190dd1
commit b55f9fc7db
Signed by: jakehamilton
GPG key ID: 9762169A1B35EA68
7 changed files with 492 additions and 19 deletions

View file

@ -90,7 +90,7 @@ in {
stage1.gnupatch.package stage1.gnupatch.package
stage1.gnused.package stage1.gnused.package
stage1.gnugrep.package stage1.gnugrep.package
stage1.gnutar.package stage1.gnutar.musl.package
stage1.gawk.boot.package stage1.gawk.boot.package
stage1.gzip.package stage1.gzip.package
stage1.diffutils.package stage1.diffutils.package

View file

@ -0,0 +1,97 @@
{
lib,
config,
}: let
cfg = config.aux.foundation.stages.stage1.bzip2;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
options.aux.foundation.stages.stage1.bzip2 = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for bzip2.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.package;
description = "Source for the package.";
};
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "High-quality data compression program";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.sourceware.org/bzip2";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.bsdOriginal;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
# TODO: Support more platforms.
default.value = ["i686-linux"];
};
};
};
config = {
aux.foundation.stages.stage1.bzip2 = {
version = "1.0.8";
src = builtins.fetchurl {
url = "https://sourceware.org/pub/bzip2/bzip2-${cfg.version}.tar.gz";
sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
};
package = builders.bash.build {
name = "bzip2-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.package
stage1.gnutar.musl.package
stage1.gzip.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd bzip2-${cfg.version}
# Build
make \
-j $NIX_BUILD_CORES \
CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" \
AR="tcc -ar" \
bzip2 bzip2recover
# Install
make install -j $NIX_BUILD_CORES PREFIX=$out
'';
};
};
};
}

View file

@ -26,6 +26,7 @@ in {
./diffutils ./diffutils
./binutils ./binutils
./findutils ./findutils
./bzip2
./gcc ./gcc
]; ];
@ -70,7 +71,11 @@ in {
# These packages are built using Bash v5 # These packages are built using Bash v5
stage1-gcc-46 = stage1.gcc.v46.package; stage1-gcc-46 = stage1.gcc.v46.package;
stage1-musl = stage1.musl.package; stage1-musl = stage1.musl.package;
stage1-bzip2 = stage1.bzip2.package;
stage1-gcc-46-cxx = stage1.gcc.v46.cxx.package; stage1-gcc-46-cxx = stage1.gcc.v46.cxx.package;
stage1-gnutar = stage1.gnutar.package;
stage1-gcc-8 = stage1.gcc.v8.package;
stage1-gcc = stage1.gcc.package;
}; };
extras = { extras = {

View file

@ -12,9 +12,79 @@ in {
includes = [ includes = [
./v4.6.nix ./v4.6.nix
./v4.6.cxx.nix ./v4.6.cxx.nix
./v8.nix
]; ];
options.aux.foundation.stages.stage1.gcc = { options.aux.foundation.stages.stage1.gcc = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for gcc-cxx.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.package;
description = "Source for the package.";
};
cc = {
src = lib.options.create {
type = lib.types.package;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.package;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.package;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.package;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
isl = {
src = lib.options.create {
type = lib.types.package;
description = "The isl source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
meta = { meta = {
description = lib.options.create { description = lib.options.create {
type = lib.types.string; type = lib.types.string;
@ -42,4 +112,112 @@ in {
}; };
}; };
}; };
config = {
aux.foundation.stages.stage1.gcc = {
version = "13.2.0";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/gmp/gmp-${cfg.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/mpfr/mpfr-${cfg.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/mpc/mpc-${cfg.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${cfg.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
package = builders.bash.build {
name = "gcc-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.v8.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.boot.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.package
stage1.gzip.package
stage1.bzip2.package
stage1.xz.package
];
script = ''
# Unpack
tar xf ${cfg.src}
tar xf ${cfg.gmp.src}
tar xf ${cfg.mpfr.src}
tar xf ${cfg.mpc.src}
tar xf ${cfg.isl.src}
cd gcc-${cfg.version}
ln -s ../gmp-${cfg.gmp.version} gmp
ln -s ../mpfr-${cfg.mpfr.version} mpfr
ln -s ../mpc-${cfg.mpc.version} mpc
ln -s ../isl-${cfg.isl.version} isl
# Patch
# force musl even if host triple is gnu
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
# Configure
export CC="gcc -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CXX="g++ -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--with-native-system-header-dir=/include \
--with-sysroot=${stage1.musl.package} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-libsanitizer \
--disable-lto \
--disable-multilib \
--disable-plugin
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install-strip
'';
};
};
};
} }

View file

@ -0,0 +1,195 @@
{
lib,
config,
}: let
cfg = config.aux.foundation.stages.stage1.gcc.v8;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
options.aux.foundation.stages.stage1.gcc.v8 = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for gcc.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.package;
description = "Source for the package.";
};
cc = {
src = lib.options.create {
type = lib.types.package;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.package;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.package;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.package;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
isl = {
src = lib.options.create {
type = lib.types.package;
description = "The isl source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
};
config = {
aux.foundation.stages.stage1.gcc.v8 = {
version = "8.5.0";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz";
sha256 = "0wiEGlEbuDCmEAOXsAQtskzhH2Qtq26m7kSELlMl7VA=";
};
gmp = {
# last version to compile with gcc 4.6
version = "6.2.1";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/gmp/gmp-${cfg.gmp.version}.tar.xz";
sha256 = "/UgpkSzd0S+EGBw0Ucx1K+IkZD6H+sSXtp7d2txJtPI=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/mpfr/mpfr-${cfg.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/mpc/mpc-${cfg.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${cfg.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
package = builders.bash.build {
name = "gcc-${cfg.version}";
meta = stage1.gcc.meta;
deps.build.host = [
stage1.gcc.v46.cxx.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.boot.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.package
stage1.gzip.package
stage1.bzip2.package
stage1.xz.package
];
script = ''
# Unpack
tar xf ${cfg.src}
tar xf ${cfg.gmp.src}
tar xf ${cfg.mpfr.src}
tar xf ${cfg.mpc.src}
tar xf ${cfg.isl.src}
cd gcc-${cfg.version}
ln -s ../gmp-${cfg.gmp.version} gmp
ln -s ../mpfr-${cfg.mpfr.version} mpfr
ln -s ../mpc-${cfg.mpc.version} mpc
ln -s ../isl-${cfg.isl.version} isl
# Patch
# doesn't recognise musl
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
# Configure
export CC="gcc -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CXX="g++ -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export C_INCLUDE_PATH="${stage1.musl.package}/include"
export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH"
export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--with-native-system-header-dir=/include \
--with-sysroot=${stage1.musl.package} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-libmpx \
--disable-libsanitizer \
--disable-lto \
--disable-multilib \
--disable-plugin
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install-strip
'';
};
};
};
}

View file

@ -34,7 +34,7 @@ in {
description = lib.options.create { description = lib.options.create {
type = lib.types.string; type = lib.types.string;
description = "Description for the package."; description = "Description for the package.";
default.value = "GNU implementation of the `tar' archiver"; default.value = "GNU implementation of the `tar` archiver";
}; };
homepage = lib.options.create { homepage = lib.options.create {
@ -66,11 +66,11 @@ in {
config = { config = {
aux.foundation.stages.stage1.gnutar = { aux.foundation.stages.stage1.gnutar = {
version = "1.12"; version = "1.35";
src = builtins.fetchurl { src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/tar/tar-${cfg.version}.tar.gz"; url = "https://ftpmirror.gnu.org/tar/tar-${cfg.version}.tar.gz";
sha256 = "xsN+iIsTbM76uQPFEUn0t71lnWnUrqISRfYQU6V6pgo="; sha256 = "FNVeMgY+qVJuBX+/Nfyr1TN452l4fv95GcN1WwLStX4=";
}; };
package = builders.bash.boot.build { package = builders.bash.boot.build {
@ -79,36 +79,34 @@ in {
meta = cfg.meta; meta = cfg.meta;
deps.build.host = [ deps.build.host = [
stage1.tinycc.musl.compiler.package stage1.gcc.v46.cxx.package
stage1.gnumake.boot.package stage1.musl.package
stage1.gnused.boot.package stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package stage1.gnugrep.package
stage1.gawk.package
stage1.gzip.package
stage1.gnutar.musl.package
]; ];
script = '' script = ''
# Unpack # Unpack
ungz --file ${cfg.src} --output tar.tar tar xzf ${cfg.src}
untar --file tar.tar
rm tar.tar
cd tar-${cfg.version} cd tar-${cfg.version}
# Configure # Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/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 \ bash ./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \
--disable-nls CC=musl-gcc
# Build # Build
make AR="tcc -ar" make -j $NIX_BUILD_CORES
# Install # Install
make install make -j $NIX_BUILD_CORES install
''; '';
}; };

View file

@ -78,7 +78,7 @@ in {
stage1.gnumake.package stage1.gnumake.package
stage1.gnused.package stage1.gnused.package
stage1.gnugrep.package stage1.gnugrep.package
stage1.gnutar.package stage1.gnutar.musl.package
stage1.gzip.package stage1.gzip.package
]; ];