fix: Build tcc-musl through an intermediate stage
If tinycc is linked with a musl which in turn was built by tcc-mes, then this musl has broken implementations of the math library on certain arches, which is in turn caused tcc-mes having stubbed math functions. The only way to get a trustworthy musl is to build it with an intermediate tcc-musl, where the intermediate tcc-musl has at least working ldexp and frexp. Issues in the math library were surfacing on RISC-V when building gmp.
This commit is contained in:
parent
d4efe9b6ad
commit
81f071f1ec
2 changed files with 339 additions and 256 deletions
|
|
@ -1,6 +1,10 @@
|
|||
{ lib, config }:
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
}:
|
||||
let
|
||||
cfg = config.aux.foundation.stages.stage1.musl.boot;
|
||||
cfg-boot0 = config.aux.foundation.stages.stage1.musl.boot0;
|
||||
cfg-boot = config.aux.foundation.stages.stage1.musl.boot;
|
||||
|
||||
platform = config.aux.platform;
|
||||
builders = config.aux.foundation.builders;
|
||||
|
|
@ -8,132 +12,153 @@ let
|
|||
stage1 = config.aux.foundation.stages.stage1;
|
||||
in
|
||||
{
|
||||
options.aux.foundation.stages.stage1.musl.boot = {
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "The package to use for musl-boot.";
|
||||
};
|
||||
options.aux.foundation.stages.stage1.musl = {
|
||||
boot0 = {
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "The package to use for musl-boot0.";
|
||||
};
|
||||
|
||||
version = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "Version of the package.";
|
||||
};
|
||||
version = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "Version of the package.";
|
||||
};
|
||||
|
||||
src = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "Source for the package.";
|
||||
src = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "Source for the package.";
|
||||
};
|
||||
};
|
||||
boot = {
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "The package to use for musl-boot.";
|
||||
};
|
||||
|
||||
version = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "Version of the package.";
|
||||
};
|
||||
|
||||
src = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "Source for the package.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
aux.foundation.stages.stage1.musl.boot = {
|
||||
version = "1.1.24";
|
||||
|
||||
src = builtins.fetchurl {
|
||||
url = "https://musl.libc.org/releases/musl-${cfg.version}.tar.gz";
|
||||
sha256 = "E3DJqBKyzyp9koAlEMygBYzDfmanvt1wBR8KNAFQIqM=";
|
||||
};
|
||||
|
||||
package =
|
||||
let
|
||||
# Thanks to the live-bootstrap project!
|
||||
# See https://github.com/fosslinux/live-bootstrap/blob/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24/musl-1.1.24.sh
|
||||
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24";
|
||||
patches = [
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/avoid_set_thread_area.patch";
|
||||
sha256 = "TsbBZXk4/KMZG9EKi7cF+sullVXrxlizLNH0UHGXsPs=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/avoid_sys_clone.patch";
|
||||
sha256 = "/ZmH64J57MmbxdfQ4RNjamAiBdkImMTlHsHdgV4gMj4=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/fenv.patch";
|
||||
sha256 = "vMVGjoN4deAJW5gsSqA207SJqAbvhrnOsGK49DdEiTI=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/makefile.patch";
|
||||
sha256 = "03iYBAUnsrEdLIIhhhq5mM6BGnPn2EfUmIHu51opxbw=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/musl_weak_symbols.patch";
|
||||
sha256 = "/d9a2eUkpe9uyi1ye6T4CiYc9MR3FZ9na0Gb90+g4v0=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/set_thread_area.patch";
|
||||
sha256 = "RIZYqbbRSx4X/0iFUhriwwBRmoXVR295GNBUjf2UrM0=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/sigsetjmp.patch";
|
||||
sha256 = "wd2Aev1zPJXy3q933aiup5p1IMKzVJBquAyl3gbK4PU=";
|
||||
})
|
||||
# FIXME: this patch causes the build to fail
|
||||
# (builtins.fetchurl {
|
||||
# url = "${liveBootstrap}/patches/stdio_flush_on_exit.patch";
|
||||
# sha256 = "/z5ze3h3QTysay8nRvyvwPv3pmTcKptdkBIaMCoeLDg=";
|
||||
# })
|
||||
# HACK: always flush stdio immediately
|
||||
./patches/always-flush.patch
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/va_list.patch";
|
||||
sha256 = "UmcMIl+YCi3wIeVvjbsCyqFlkyYsM4ECNwTfXP+s7vg=";
|
||||
})
|
||||
];
|
||||
in
|
||||
builders.bash.boot.build {
|
||||
name = "musl-boot-${cfg.version}";
|
||||
|
||||
meta = stage1.musl.meta;
|
||||
|
||||
deps.build.host = [
|
||||
stage1.tinycc.mes.compiler.package
|
||||
stage1.gnumake.boot.package
|
||||
stage1.gnused.boot.package
|
||||
stage1.gnugrep.package
|
||||
stage1.gnupatch.package
|
||||
stage1.gnutar.boot.package
|
||||
stage1.gzip.package
|
||||
];
|
||||
|
||||
script = ''
|
||||
# Unpack
|
||||
tar xzf ${cfg.src}
|
||||
cd musl-${cfg.version}
|
||||
|
||||
# Patch
|
||||
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
|
||||
# tcc does not support complex types
|
||||
rm -rf src/complex
|
||||
# Configure fails without this
|
||||
mkdir -p /dev
|
||||
# https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a3-intermediate-musl.nix
|
||||
sed -i 's|/bin/sh|${stage1.bash.boot.package}/bin/bash|' \
|
||||
tools/*.sh
|
||||
chmod 755 tools/*.sh
|
||||
# patch popen/system to search in PATH instead of hardcoding /bin/sh
|
||||
sed -i 's|posix_spawn(&pid, "/bin/sh",|posix_spawnp(\&pid, "sh",|' \
|
||||
src/stdio/popen.c src/process/system.c
|
||||
sed -i 's|execl("/bin/sh", "sh", "-c",|execlp("sh", "-c",|'\
|
||||
src/misc/wordexp.c
|
||||
|
||||
# Configure
|
||||
bash ./configure \
|
||||
--prefix=$out \
|
||||
--build=${platform.build} \
|
||||
--host=${platform.host} \
|
||||
--disable-shared \
|
||||
CC=tcc
|
||||
|
||||
# Build
|
||||
make AR="tcc -ar" RANLIB=true CFLAGS="-DSYSCALL_NO_TLS"
|
||||
|
||||
# Install
|
||||
make install
|
||||
cp ${stage1.tinycc.mes.libs.package}/lib/libtcc1.a $out/lib
|
||||
|
||||
'';
|
||||
aux.foundation.stages.stage1.musl =
|
||||
let
|
||||
version = "1.1.24";
|
||||
src = builtins.fetchurl {
|
||||
url = "https://musl.libc.org/releases/musl-${version}.tar.gz";
|
||||
sha256 = "E3DJqBKyzyp9koAlEMygBYzDfmanvt1wBR8KNAFQIqM=";
|
||||
};
|
||||
};
|
||||
# Thanks to the live-bootstrap project!
|
||||
# See https://github.com/fosslinux/live-bootstrap/blob/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24/musl-1.1.24.sh
|
||||
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24";
|
||||
patches = [
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/avoid_set_thread_area.patch";
|
||||
sha256 = "TsbBZXk4/KMZG9EKi7cF+sullVXrxlizLNH0UHGXsPs=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/avoid_sys_clone.patch";
|
||||
sha256 = "/ZmH64J57MmbxdfQ4RNjamAiBdkImMTlHsHdgV4gMj4=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/fenv.patch";
|
||||
sha256 = "vMVGjoN4deAJW5gsSqA207SJqAbvhrnOsGK49DdEiTI=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/makefile.patch";
|
||||
sha256 = "03iYBAUnsrEdLIIhhhq5mM6BGnPn2EfUmIHu51opxbw=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/set_thread_area.patch";
|
||||
sha256 = "RIZYqbbRSx4X/0iFUhriwwBRmoXVR295GNBUjf2UrM0=";
|
||||
})
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/sigsetjmp.patch";
|
||||
sha256 = "wd2Aev1zPJXy3q933aiup5p1IMKzVJBquAyl3gbK4PU=";
|
||||
})
|
||||
# FIXME: this patch causes the build to fail
|
||||
# (builtins.fetchurl {
|
||||
# url = "${liveBootstrap}/patches/stdio_flush_on_exit.patch";
|
||||
# sha256 = "/z5ze3h3QTysay8nRvyvwPv3pmTcKptdkBIaMCoeLDg=";
|
||||
# })
|
||||
# HACK: always flush stdio immediately
|
||||
./patches/always-flush.patch
|
||||
(builtins.fetchurl {
|
||||
url = "${liveBootstrap}/patches/va_list.patch";
|
||||
sha256 = "UmcMIl+YCi3wIeVvjbsCyqFlkyYsM4ECNwTfXP+s7vg=";
|
||||
})
|
||||
];
|
||||
muslWithTcc =
|
||||
cfg: name: tcc:
|
||||
(builders.bash.boot.build {
|
||||
inherit name;
|
||||
meta = stage1.musl.meta;
|
||||
|
||||
deps.build.host = [
|
||||
tcc.compiler.package
|
||||
stage1.gnumake.boot.package
|
||||
stage1.gnused.boot.package
|
||||
stage1.gnugrep.package
|
||||
stage1.gnupatch.package
|
||||
stage1.gnutar.boot.package
|
||||
stage1.gzip.package
|
||||
];
|
||||
|
||||
script = ''
|
||||
# Unpack
|
||||
tar xzf ${cfg.src}
|
||||
cd musl-${cfg.version}
|
||||
|
||||
# Patch
|
||||
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
|
||||
# tcc does not support complex types
|
||||
rm -rf src/complex
|
||||
# Configure fails without this
|
||||
mkdir -p /dev
|
||||
# https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a3-intermediate-musl.nix
|
||||
sed -i 's|/bin/sh|${stage1.bash.boot.package}/bin/bash|' \
|
||||
tools/*.sh
|
||||
chmod 755 tools/*.sh
|
||||
# patch popen/system to search in PATH instead of hardcoding /bin/sh
|
||||
sed -i 's|posix_spawn(&pid, "/bin/sh",|posix_spawnp(\&pid, "sh",|' \
|
||||
src/stdio/popen.c src/process/system.c
|
||||
sed -i 's|execl("/bin/sh", "sh", "-c",|execlp("sh", "-c",|'\
|
||||
src/misc/wordexp.c
|
||||
|
||||
# Configure
|
||||
bash ./configure \
|
||||
--prefix=$out \
|
||||
--build=${platform.build} \
|
||||
--host=${platform.host} \
|
||||
--disable-shared \
|
||||
CC=tcc
|
||||
|
||||
# Build
|
||||
make AR="tcc -ar" RANLIB=true CFLAGS="-DSYSCALL_NO_TLS"
|
||||
|
||||
# Install
|
||||
make install
|
||||
cp ${tcc.libs.package}/lib/libtcc1.a $out/lib
|
||||
|
||||
'';
|
||||
});
|
||||
in
|
||||
{
|
||||
boot0 = {
|
||||
inherit src version;
|
||||
package = muslWithTcc cfg-boot0 "musl-boot0-${cfg-boot0.version}" stage1.tinycc.mes;
|
||||
};
|
||||
boot = {
|
||||
inherit src version;
|
||||
package = muslWithTcc cfg-boot "musl-boot-${cfg-boot.version}" stage1.tinycc.musl-boot0;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
args@{ lib, config }:
|
||||
args@{
|
||||
lib,
|
||||
config,
|
||||
}:
|
||||
let
|
||||
cfg = config.aux.foundation.stages.stage1.tinycc.musl;
|
||||
cfg-boot0 = config.aux.foundation.stages.stage1.tinycc.musl-boot0;
|
||||
cfg-final = config.aux.foundation.stages.stage1.tinycc.musl;
|
||||
|
||||
builders = config.aux.foundation.builders;
|
||||
|
||||
|
|
@ -11,34 +15,61 @@ let
|
|||
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
|
||||
in
|
||||
{
|
||||
options.aux.foundation.stages.stage1.tinycc.musl = {
|
||||
compiler = {
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "The package to use for the tinycc-musl compiler.";
|
||||
options.aux.foundation.stages.stage1.tinycc = {
|
||||
musl-boot0 = {
|
||||
compiler = {
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "The package to use for the tinycc-musl-boot0 compiler.";
|
||||
};
|
||||
};
|
||||
|
||||
libs = {
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "The package to use for the tinycc-musl-boot0 libs.";
|
||||
};
|
||||
};
|
||||
|
||||
src = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "Source for the package.";
|
||||
};
|
||||
|
||||
revision = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "Revision of the package.";
|
||||
};
|
||||
};
|
||||
|
||||
libs = {
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "The package to use for the tinycc-musl libs.";
|
||||
musl = {
|
||||
compiler = {
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "The package to use for the tinycc-musl compiler.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
src = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "Source for the package.";
|
||||
};
|
||||
libs = {
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
description = "The package to use for the tinycc-musl libs.";
|
||||
};
|
||||
};
|
||||
|
||||
revision = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "Revision of the package.";
|
||||
src = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "Source for the package.";
|
||||
};
|
||||
|
||||
revision = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "Revision of the package.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
aux.foundation.stages.stage1.tinycc.musl =
|
||||
aux.foundation.stages.stage1.tinycc =
|
||||
let
|
||||
patches = [
|
||||
./patches/ignore-duplicate-symbols.patch
|
||||
|
|
@ -46,133 +77,160 @@ in
|
|||
./patches/static-link.patch
|
||||
];
|
||||
|
||||
tinycc-musl = builders.bash.boot.build {
|
||||
name = "${pname}-${stage1.tinycc.version}";
|
||||
tccMuslWith =
|
||||
prevTcc: cfg: musl:
|
||||
builders.bash.boot.build {
|
||||
name = "${pname}-${stage1.tinycc.version}";
|
||||
|
||||
meta = stage1.tinycc.meta;
|
||||
meta = stage1.tinycc.meta;
|
||||
|
||||
deps.build.host = [
|
||||
stage1.tinycc.boot.compiler.package
|
||||
stage1.gnupatch.package
|
||||
stage1.gnutar.boot.package
|
||||
stage1.gzip.package
|
||||
];
|
||||
deps.build.host = [
|
||||
prevTcc.compiler.package
|
||||
stage1.gnupatch.package
|
||||
stage1.gnutar.boot.package
|
||||
stage1.gzip.package
|
||||
];
|
||||
|
||||
script = ''
|
||||
# Unpack
|
||||
tar xzf ${cfg.src}
|
||||
cd tinycc-${builtins.substring 0 7 cfg.revision}
|
||||
script = ''
|
||||
# Unpack
|
||||
tar xzf ${cfg.src}
|
||||
cd tinycc-${builtins.substring 0 7 cfg.revision}
|
||||
|
||||
# Patch
|
||||
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
|
||||
# Patch
|
||||
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
|
||||
|
||||
# Configure
|
||||
touch config.h
|
||||
# Configure
|
||||
touch config.h
|
||||
|
||||
# Build
|
||||
# We first have to recompile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting,
|
||||
# but when linked with musl it is.
|
||||
ln -s ${stage1.musl.boot.package}/lib/libtcc1.a ./libtcc1.a
|
||||
# Build
|
||||
# We first have to recompile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting,
|
||||
# but when linked with musl it is.
|
||||
ln -s ${musl.package}/lib/libtcc1.a ./libtcc1.a
|
||||
|
||||
tcc \
|
||||
-B ${stage1.tinycc.boot.libs.package}/lib \
|
||||
-DC2STR \
|
||||
-o c2str \
|
||||
conftest.c
|
||||
./c2str include/tccdefs.h tccdefs_.h
|
||||
tcc \
|
||||
-B ${prevTcc.libs.package}/lib \
|
||||
-DC2STR \
|
||||
-o c2str \
|
||||
conftest.c
|
||||
./c2str include/tccdefs.h tccdefs_.h
|
||||
|
||||
tcc -v \
|
||||
-static \
|
||||
-o tcc-musl \
|
||||
-D TCC_TARGET_I386=1 \
|
||||
-D CONFIG_TCCDIR=\"\" \
|
||||
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
|
||||
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
|
||||
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
|
||||
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.musl.boot.package}/include\" \
|
||||
-D TCC_LIBGCC=\"libc.a\" \
|
||||
-D TCC_LIBTCC1=\"libtcc1.a\" \
|
||||
-D CONFIG_TCC_STATIC=1 \
|
||||
-D CONFIG_USE_LIBGCC=1 \
|
||||
-D TCC_VERSION=\"0.9.27\" \
|
||||
-D ONE_SOURCE=1 \
|
||||
-D TCC_MUSL=1 \
|
||||
-D CONFIG_TCC_PREDEFS=1 \
|
||||
-D CONFIG_TCC_SEMLOCK=0 \
|
||||
-B . \
|
||||
-B ${stage1.tinycc.boot.libs.package}/lib \
|
||||
tcc.c
|
||||
# libtcc1.a
|
||||
rm -f libtcc1.a
|
||||
tcc -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
|
||||
tcc -ar cr libtcc1.a libtcc1.o
|
||||
tcc -v \
|
||||
-static \
|
||||
-o tcc-musl \
|
||||
-D TCC_TARGET_I386=1 \
|
||||
-D CONFIG_TCCDIR=\"\" \
|
||||
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
|
||||
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
|
||||
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
|
||||
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${musl.package}/include\" \
|
||||
-I ${musl.package}/include \
|
||||
-D TCC_LIBGCC=\"libc.a\" \
|
||||
-D TCC_LIBTCC1=\"libtcc1.a\" \
|
||||
-D CONFIG_TCC_STATIC=1 \
|
||||
-D CONFIG_USE_LIBGCC=1 \
|
||||
-D TCC_VERSION=\"0.9.27\" \
|
||||
-D ONE_SOURCE=1 \
|
||||
-D TCC_MUSL=1 \
|
||||
-D CONFIG_TCC_PREDEFS=1 \
|
||||
-D CONFIG_TCC_SEMLOCK=0 \
|
||||
-B . \
|
||||
-B ${musl.package}/lib \
|
||||
tcc.c
|
||||
# libtcc1.a
|
||||
rm -f libtcc1.a
|
||||
tcc -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
|
||||
tcc -ar cr libtcc1.a libtcc1.o
|
||||
|
||||
# Rebuild tcc-musl with itself
|
||||
./tcc-musl \
|
||||
-v \
|
||||
-static \
|
||||
-o tcc-musl \
|
||||
-D TCC_TARGET_I386=1 \
|
||||
-D CONFIG_TCCDIR=\"\" \
|
||||
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
|
||||
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
|
||||
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
|
||||
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.musl.boot.package}/include\" \
|
||||
-D TCC_LIBGCC=\"libc.a\" \
|
||||
-D TCC_LIBTCC1=\"libtcc1.a\" \
|
||||
-D CONFIG_TCC_STATIC=1 \
|
||||
-D CONFIG_USE_LIBGCC=1 \
|
||||
-D TCC_VERSION=\"0.9.27\" \
|
||||
-D ONE_SOURCE=1 \
|
||||
-D TCC_MUSL=1 \
|
||||
-D CONFIG_TCC_PREDEFS=1 \
|
||||
-D CONFIG_TCC_SEMLOCK=0 \
|
||||
-B . \
|
||||
-B ${stage1.musl.boot.package}/lib \
|
||||
tcc.c
|
||||
# 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/alloca.S
|
||||
./tcc-musl -ar cr libtcc1.a libtcc1.o alloca.o
|
||||
# Rebuild tcc-musl with itself
|
||||
./tcc-musl \
|
||||
-v \
|
||||
-static \
|
||||
-o tcc-musl \
|
||||
-D TCC_TARGET_I386=1 \
|
||||
-D CONFIG_TCCDIR=\"\" \
|
||||
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
|
||||
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
|
||||
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
|
||||
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${musl.package}/include\" \
|
||||
-D TCC_LIBGCC=\"libc.a\" \
|
||||
-D TCC_LIBTCC1=\"libtcc1.a\" \
|
||||
-D CONFIG_TCC_STATIC=1 \
|
||||
-D CONFIG_USE_LIBGCC=1 \
|
||||
-D TCC_VERSION=\"0.9.27\" \
|
||||
-D ONE_SOURCE=1 \
|
||||
-D TCC_MUSL=1 \
|
||||
-D CONFIG_TCC_PREDEFS=1 \
|
||||
-D CONFIG_TCC_SEMLOCK=0 \
|
||||
-B . \
|
||||
-B ${musl.package}/lib \
|
||||
tcc.c
|
||||
# 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/alloca.S
|
||||
./tcc-musl -ar cr libtcc1.a libtcc1.o alloca.o
|
||||
|
||||
# Install
|
||||
install -D tcc-musl $out/bin/tcc
|
||||
install -Dm444 libtcc1.a $out/lib/libtcc1.a
|
||||
'';
|
||||
};
|
||||
# Install
|
||||
install -D tcc-musl $out/bin/tcc
|
||||
install -Dm444 libtcc1.a $out/lib/libtcc1.a
|
||||
'';
|
||||
};
|
||||
mkCompiler =
|
||||
name: tcc:
|
||||
builders.bash.boot.build {
|
||||
name = "${name}-${stage1.tinycc.version}-compiler";
|
||||
|
||||
meta = stage1.tinycc.meta;
|
||||
|
||||
script = ''
|
||||
install -D ${tcc}/bin/tcc $out/bin/tcc
|
||||
'';
|
||||
};
|
||||
mkLibs =
|
||||
name: tcc: musl:
|
||||
builders.bash.boot.build {
|
||||
name = "${pname}-${stage1.tinycc.version}-libs";
|
||||
|
||||
meta = stage1.tinycc.meta;
|
||||
|
||||
script = ''
|
||||
mkdir $out
|
||||
cp -r ${musl.package}/* $out
|
||||
chmod +w $out/lib/libtcc1.a
|
||||
cp ${tcc}/lib/libtcc1.a $out/lib/libtcc1.a
|
||||
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
revision = "fd6d2180c5c801bb0b4c5dde27d61503059fc97d";
|
||||
musl-boot0 =
|
||||
let
|
||||
tcc = tccMuslWith stage1.tinycc.mes cfg-boot0 stage1.musl.boot0;
|
||||
in
|
||||
{
|
||||
revision = "fd6d2180c5c801bb0b4c5dde27d61503059fc97d";
|
||||
|
||||
src = builtins.fetchurl {
|
||||
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg.revision}.tar.gz";
|
||||
sha256 = "R81SNbEmh4s9FNQxCWZwUiMCYRkkwOHAdRf0aMnnRiA=";
|
||||
};
|
||||
src = builtins.fetchurl {
|
||||
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg-boot0.revision}.tar.gz";
|
||||
sha256 = "R81SNbEmh4s9FNQxCWZwUiMCYRkkwOHAdRf0aMnnRiA=";
|
||||
};
|
||||
compiler.package = mkCompiler "${pname}-boot0" tcc;
|
||||
libs.package = mkLibs "${pname}-boot0" tcc stage1.musl.boot0;
|
||||
};
|
||||
musl =
|
||||
let
|
||||
tcc = tccMuslWith stage1.tinycc.musl-boot0 cfg-final stage1.musl.boot;
|
||||
in
|
||||
{
|
||||
revision = "fd6d2180c5c801bb0b4c5dde27d61503059fc97d";
|
||||
|
||||
compiler.package = builders.bash.boot.build {
|
||||
name = "${pname}-${stage1.tinycc.version}-compiler";
|
||||
|
||||
meta = stage1.tinycc.meta;
|
||||
|
||||
script = ''
|
||||
install -D ${tinycc-musl}/bin/tcc $out/bin/tcc
|
||||
'';
|
||||
};
|
||||
|
||||
libs.package = builders.bash.boot.build {
|
||||
name = "${pname}-${stage1.tinycc.version}-libs";
|
||||
|
||||
meta = stage1.tinycc.meta;
|
||||
|
||||
script = ''
|
||||
mkdir $out
|
||||
cp -r ${stage1.musl.boot.package}/* $out
|
||||
chmod +w $out/lib/libtcc1.a
|
||||
cp ${tinycc-musl}/lib/libtcc1.a $out/lib/libtcc1.a
|
||||
|
||||
'';
|
||||
};
|
||||
src = builtins.fetchurl {
|
||||
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg-final.revision}.tar.gz";
|
||||
sha256 = "R81SNbEmh4s9FNQxCWZwUiMCYRkkwOHAdRf0aMnnRiA=";
|
||||
};
|
||||
compiler.package = mkCompiler pname tcc;
|
||||
libs.package = mkLibs pname tcc stage1.musl.boot;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue