This commit is contained in:
parent
6d0463d37d
commit
6ee203a884
|
@ -33,7 +33,16 @@ in
|
||||||
# platform.host = lib.modules.overrides.force "x86_64-linux";
|
# platform.host = lib.modules.overrides.force "x86_64-linux";
|
||||||
# };
|
# };
|
||||||
cross-aux-a-x86_64-linux = config.packages.cross.x86_64-linux.aux.a;
|
cross-aux-a-x86_64-linux = config.packages.cross.x86_64-linux.aux.a;
|
||||||
cross-foundation-gcc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.gcc;
|
cross-foundation-gcc-newlib-x86_64-linux = config.packages.cross-tools.x86_64-linux.foundation.gcc-newlib;
|
||||||
|
|
||||||
|
cross-foundation-binutils-x86_64-linux = config.packages.cross-tools.x86_64-linux.foundation.binutils;
|
||||||
|
|
||||||
|
cross-foundation-glibc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.glibc;
|
||||||
|
cross-foundation-gcc-x86_64-linux = config.packages.cross-tools.x86_64-linux.foundation.gcc-cross;
|
||||||
|
|
||||||
|
cross-binutils = config.packages.cross.x86_64-linux.foundation.binutils;
|
||||||
|
gcc-bootstrap = config.packages.foundation.gcc-bootstrap;
|
||||||
|
|
||||||
|
|
||||||
example-a = config.packages.foundation.gcc.versions.latest.extend {
|
example-a = config.packages.foundation.gcc.versions.latest.extend {
|
||||||
platform = {
|
platform = {
|
||||||
|
|
|
@ -4,7 +4,7 @@ let
|
||||||
|
|
||||||
doubles = lib.systems.doubles.all;
|
doubles = lib.systems.doubles.all;
|
||||||
|
|
||||||
packages = builtins.removeAttrs config.packages [ "cross" ];
|
packages = builtins.removeAttrs config.packages [ "cross" "cross-tools" ];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
includes = [
|
includes = [
|
||||||
|
@ -21,6 +21,14 @@ in
|
||||||
freeform = lib.types.packages;
|
freeform = lib.types.packages;
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
cross-tools = lib.attrs.generate doubles (
|
||||||
|
system:
|
||||||
|
lib.options.create {
|
||||||
|
description = "The cross-compilation tools for the ${system} target.";
|
||||||
|
type = lib.types.packages;
|
||||||
|
default.value = { };
|
||||||
|
}
|
||||||
|
);
|
||||||
cross = lib.attrs.generate doubles (
|
cross = lib.attrs.generate doubles (
|
||||||
system:
|
system:
|
||||||
lib.options.create {
|
lib.options.create {
|
||||||
|
@ -54,6 +62,36 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
packages.cross-tools = lib.attrs.generate doubles (
|
||||||
|
system:
|
||||||
|
builtins.mapAttrs
|
||||||
|
(
|
||||||
|
namespace:
|
||||||
|
builtins.mapAttrs (
|
||||||
|
name: alias:
|
||||||
|
let
|
||||||
|
setTarget =
|
||||||
|
package:
|
||||||
|
package
|
||||||
|
// {
|
||||||
|
__modules__ = package.__modules__ ++ [
|
||||||
|
{
|
||||||
|
config.platform = {
|
||||||
|
target = lib.modules.override 5 system;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
updated = alias // {
|
||||||
|
versions = builtins.mapAttrs (version: package: setTarget package) alias.versions;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
updated
|
||||||
|
)
|
||||||
|
)
|
||||||
|
packages
|
||||||
|
);
|
||||||
packages.cross = lib.attrs.generate doubles (
|
packages.cross = lib.attrs.generate doubles (
|
||||||
system:
|
system:
|
||||||
builtins.mapAttrs
|
builtins.mapAttrs
|
||||||
|
@ -62,7 +100,7 @@ in
|
||||||
builtins.mapAttrs (
|
builtins.mapAttrs (
|
||||||
name: alias:
|
name: alias:
|
||||||
let
|
let
|
||||||
setHost =
|
setPlatform =
|
||||||
package:
|
package:
|
||||||
package
|
package
|
||||||
// {
|
// {
|
||||||
|
@ -77,7 +115,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
updated = alias // {
|
updated = alias // {
|
||||||
versions = builtins.mapAttrs (version: package: setHost package) alias.versions;
|
versions = builtins.mapAttrs (version: package: setPlatform package) alias.versions;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
updated
|
updated
|
||||||
|
|
|
@ -33,10 +33,12 @@ in
|
||||||
isHostBootstrapped = config.platform.host.double == "i686-linux";
|
isHostBootstrapped = config.platform.host.double == "i686-linux";
|
||||||
|
|
||||||
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
|
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
|
||||||
|
|
||||||
|
isCross = config.platform.build.double != config.platform.host.double && config.platform.host.double == config.platform.target.double;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
meta = {
|
meta = {
|
||||||
platforms = [ "i686-linux" ];
|
platforms = [ "i686-linux" "x86_64-linux" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
pname = "binutils";
|
pname = "binutils";
|
||||||
|
@ -47,14 +49,56 @@ in
|
||||||
deps = {
|
deps = {
|
||||||
build = {
|
build = {
|
||||||
only = {
|
only = {
|
||||||
gcc = lib.modules.when (!isBootstrapped) packages.foundation.gcc;
|
gcc = lib.modules.when (!isBootstrapped) (
|
||||||
|
if isCross then
|
||||||
|
packages.foundation.gcc-cross.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
inherit (config.platform) build target;
|
||||||
|
host = config.platform.build;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
packages.foundation.gcc-cross
|
||||||
|
);
|
||||||
|
glibc = lib.modules.when (isCross) (
|
||||||
|
packages.foundation.glibc.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
inherit (config.platform) host target build;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
binutils = lib.modules.when (isCross) (
|
||||||
|
packages.foundation.binutils.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
inherit (config.platform) target build;
|
||||||
|
host = config.platform.build;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
# gcc = lib.modules.when (!isBootstrapped || isCross) (if (!isBootstrapped && !isCross) then
|
||||||
|
# packages.foundation.gcc-cross
|
||||||
|
# else
|
||||||
|
# (packages.foundation.gcc-cross.versions.latest.extend {
|
||||||
|
# platform = lib.modules.override 0 {
|
||||||
|
# inherit (config.platform) host target;
|
||||||
|
# build = config.platform.host;
|
||||||
|
# };
|
||||||
|
# }));
|
||||||
|
|
||||||
|
# gcc = lib.modules.when (isBootstrapped) (packages.foundation.gcc.versions.latest.extend {
|
||||||
|
# gcc = lib.modules.when (isCross) (packages.foundation.gcc.versions.latest.extend {
|
||||||
|
# platform = lib.modules.override 0 {
|
||||||
|
# inherit (config.platform) host target;
|
||||||
|
# build = config.platform.target;
|
||||||
|
# };
|
||||||
|
# });
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
env = {
|
env = rec {
|
||||||
PATH = lib.paths.bin (
|
PATH = lib.paths.bin (
|
||||||
lib.lists.when isBootstrapped
|
lib.lists.when (isBootstrapped)
|
||||||
[ foundation.stage2-gcc ]
|
[ foundation.stage2-gcc ]
|
||||||
++ [
|
++ [
|
||||||
foundation.stage2-gcc
|
foundation.stage2-gcc
|
||||||
|
@ -70,6 +114,13 @@ in
|
||||||
foundation.stage1-xz
|
foundation.stage1-xz
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
CC = lib.modules.when (isCross) "x86_64-unknown-linux-gnu-gcc -Wl,-dynamic-linker -Wl,${config.deps.build.only.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.build.only.glibc.package}/lib";
|
||||||
|
CXX = lib.modules.when (isCross) "x86_64-unknown-linux-gnu-g++ -Wl,-dynamic-linker -Wl,${config.deps.build.only.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.build.only.glibc.package}/lib";
|
||||||
|
LDFLAGS_FOR_TARGET = lib.modules.when (isCross) "-B${config.deps.build.only.glibc.package}/lib -L${config.deps.build.only.glibc.package}/lib -I${config.deps.build.only.glibc.package}/include";
|
||||||
|
CC_FOR_BUILD = CC;
|
||||||
|
CXX_FOR_BUILD = CXX;
|
||||||
|
CC_FOR_TARGET = CC;
|
||||||
|
CXX_FOR_TARGET = CXX;
|
||||||
};
|
};
|
||||||
|
|
||||||
phases =
|
phases =
|
||||||
|
@ -79,9 +130,11 @@ in
|
||||||
./patches/deterministic.patch
|
./patches/deterministic.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
configureFlags = [
|
configureFlags =
|
||||||
# "CC=musl-gcc"
|
lib.lists.when (!isCross) [
|
||||||
"LDFLAGS=--static"
|
"LDFLAGS=--static"
|
||||||
|
] ++ [
|
||||||
|
# "CC=musl-gcc"
|
||||||
"--prefix=${builtins.placeholder "out"}"
|
"--prefix=${builtins.placeholder "out"}"
|
||||||
"--build=${config.platform.build.triple}"
|
"--build=${config.platform.build.triple}"
|
||||||
"--host=${config.platform.host.triple}"
|
"--host=${config.platform.host.triple}"
|
||||||
|
@ -116,6 +169,9 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configure = ''
|
configure = ''
|
||||||
|
echo "BUILD: ${config.platform.build.triple}"
|
||||||
|
echo "HOST: ${config.platform.host.triple}"
|
||||||
|
echo "TARGET: ${config.platform.target.triple}"
|
||||||
bash ./configure ${builtins.concatStringsSep " " configureFlags}
|
bash ./configure ${builtins.concatStringsSep " " configureFlags}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
248
tidepool/src/packages/foundation/gcc/bootstrap.nix
Normal file
248
tidepool/src/packages/foundation/gcc/bootstrap.nix
Normal file
|
@ -0,0 +1,248 @@
|
||||||
|
{ config, options }:
|
||||||
|
let
|
||||||
|
inherit (config)
|
||||||
|
lib
|
||||||
|
mirrors
|
||||||
|
builders
|
||||||
|
# These are the upstream foundational packages exported from the Aux Foundation project.
|
||||||
|
|
||||||
|
foundation
|
||||||
|
packages
|
||||||
|
;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config.packages.foundation.gcc-bootstrap = {
|
||||||
|
versions = {
|
||||||
|
"latest" =
|
||||||
|
{ config, meta }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
src = lib.options.create {
|
||||||
|
type = lib.types.derivation;
|
||||||
|
description = "Source for the package.";
|
||||||
|
};
|
||||||
|
|
||||||
|
cc = {
|
||||||
|
src = lib.options.create {
|
||||||
|
type = lib.types.derivation;
|
||||||
|
description = "The cc source for the package.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
gmp = {
|
||||||
|
src = lib.options.create {
|
||||||
|
type = lib.types.derivation;
|
||||||
|
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.derivation;
|
||||||
|
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.derivation;
|
||||||
|
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.derivation;
|
||||||
|
description = "The isl source for the package.";
|
||||||
|
};
|
||||||
|
version = lib.options.create {
|
||||||
|
type = lib.types.string;
|
||||||
|
description = "Version of isl.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
meta = {
|
||||||
|
platforms = [ "x86_64-linux" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
pname = "gcc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
|
||||||
|
version = "13.2.0";
|
||||||
|
|
||||||
|
builder = builders.basic;
|
||||||
|
|
||||||
|
deps = {
|
||||||
|
build = {
|
||||||
|
build = {
|
||||||
|
gcc = (packages.foundation.gcc-cross.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
build = "i686-linux";
|
||||||
|
target = config.platform.target;
|
||||||
|
host = "i686-linux";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
binutils = (packages.foundation.binutils.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
build = "i686-linux";
|
||||||
|
target = config.platform.target;
|
||||||
|
host = config.platform.host;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
glibc = (packages.foundation.glibc.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
build = "i686-linux";
|
||||||
|
target = config.platform.target;
|
||||||
|
host = config.platform.host;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
linux-headers = (packages.foundation.linux-headers.versions.latest.extend {
|
||||||
|
platform.target = lib.modules.override 0 config.platform.target;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
env = {
|
||||||
|
PATH = lib.paths.bin (
|
||||||
|
[
|
||||||
|
foundation.stage2-gnumake
|
||||||
|
foundation.stage2-gnused
|
||||||
|
foundation.stage2-gnugrep
|
||||||
|
foundation.stage2-gnupatch
|
||||||
|
foundation.stage2-gawk
|
||||||
|
foundation.stage2-diffutils
|
||||||
|
foundation.stage2-findutils
|
||||||
|
foundation.stage2-gnutar
|
||||||
|
foundation.stage2-gzip
|
||||||
|
foundation.stage2-bzip2
|
||||||
|
foundation.stage1-xz
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
phases = let
|
||||||
|
patches = [
|
||||||
|
# Make binutils output deterministic by default.
|
||||||
|
./patches/libstdc++-target.patch
|
||||||
|
];
|
||||||
|
in {
|
||||||
|
unpack = ''
|
||||||
|
# Unpack
|
||||||
|
tar xf ${config.src}
|
||||||
|
tar xf ${config.gmp.src}
|
||||||
|
tar xf ${config.mpfr.src}
|
||||||
|
tar xf ${config.mpc.src}
|
||||||
|
tar xf ${config.isl.src}
|
||||||
|
cd gcc-${config.version}
|
||||||
|
|
||||||
|
ln -s ../gmp-${config.gmp.version} gmp
|
||||||
|
ln -s ../mpfr-${config.mpfr.version} mpfr
|
||||||
|
ln -s ../mpc-${config.mpc.version} mpc
|
||||||
|
ln -s ../isl-${config.isl.version} isl
|
||||||
|
'';
|
||||||
|
|
||||||
|
patch = ''
|
||||||
|
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
|
||||||
|
'';
|
||||||
|
|
||||||
|
configure = ''
|
||||||
|
# Configure
|
||||||
|
export CC="x86_64-unknown-linux-gnu-gcc -Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export CXX="x86_64-unknown-linux-gnu-g++ -Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2"
|
||||||
|
export LIBRARY_PATH="${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export LDFLAGS_FOR_TARGET="-L${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export LDFLAGS_FOR_TARGET="$LDFLAGS_FOR_TARGET -B${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export LDFLAGS_FOR_TARGET="$LDFLAGS_FOR_TARGET -I${config.deps.build.build.glibc.package}/include"
|
||||||
|
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
|
||||||
|
echo PATH=$PATH
|
||||||
|
|
||||||
|
bash ../configure \
|
||||||
|
--prefix=$out \
|
||||||
|
--build=${config.platform.build.triple} \
|
||||||
|
--host=${config.platform.host.triple} \
|
||||||
|
--target=${config.platform.target.triple} \
|
||||||
|
--with-as=${config.deps.build.build.binutils.package}/bin/as \
|
||||||
|
--with-ld=${config.deps.build.build.binutils.package}/bin/ld \
|
||||||
|
--enable-languages=c,c++ \
|
||||||
|
--disable-bootstrap \
|
||||||
|
--disable-libsanitizer \
|
||||||
|
--disable-multilib \
|
||||||
|
--with-native-system-header-dir=${config.deps.build.build.glibc.package}/include \
|
||||||
|
--with-gxx-include-dir=${placeholder "out"}/include/c++/${config.version}/ \
|
||||||
|
--with-build-sysroot=/ \
|
||||||
|
--enable-static \
|
||||||
|
LDFLAGS_FOR_TARGET="-L$(pwd)/${config.platform.target.triple}/libgcc $LDFLAGS_FOR_TARGET"
|
||||||
|
'';
|
||||||
|
|
||||||
|
build = ''
|
||||||
|
# Build
|
||||||
|
make -j $NIX_BUILD_CORES
|
||||||
|
'';
|
||||||
|
|
||||||
|
install = ''
|
||||||
|
# Install
|
||||||
|
make -j $NIX_BUILD_CORES install
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/gcc/gcc-${config.version}/gcc-${config.version}.tar.xz";
|
||||||
|
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
|
||||||
|
};
|
||||||
|
|
||||||
|
gmp = {
|
||||||
|
version = "6.3.0";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
|
||||||
|
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mpfr = {
|
||||||
|
version = "4.2.1";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
|
||||||
|
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mpc = {
|
||||||
|
version = "1.3.1";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
|
||||||
|
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
isl = {
|
||||||
|
version = "0.24";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
|
||||||
|
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
262
tidepool/src/packages/foundation/gcc/cross.nix
Normal file
262
tidepool/src/packages/foundation/gcc/cross.nix
Normal file
|
@ -0,0 +1,262 @@
|
||||||
|
{ config, options }:
|
||||||
|
let
|
||||||
|
inherit (config)
|
||||||
|
lib
|
||||||
|
mirrors
|
||||||
|
builders
|
||||||
|
# These are the upstream foundational packages exported from the Aux Foundation project.
|
||||||
|
|
||||||
|
foundation
|
||||||
|
packages
|
||||||
|
;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
includes = [
|
||||||
|
./newlib.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
config.packages.context.options = {
|
||||||
|
"foundation:cflags" = lib.options.create {
|
||||||
|
type = lib.types.list.of lib.types.string;
|
||||||
|
default.value = [ ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config.packages.foundation.gcc-cross = {
|
||||||
|
versions = {
|
||||||
|
"latest" =
|
||||||
|
{ config, meta }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
src = lib.options.create {
|
||||||
|
type = lib.types.derivation;
|
||||||
|
description = "Source for the package.";
|
||||||
|
};
|
||||||
|
|
||||||
|
cc = {
|
||||||
|
src = lib.options.create {
|
||||||
|
type = lib.types.derivation;
|
||||||
|
description = "The cc source for the package.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
gmp = {
|
||||||
|
src = lib.options.create {
|
||||||
|
type = lib.types.derivation;
|
||||||
|
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.derivation;
|
||||||
|
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.derivation;
|
||||||
|
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.derivation;
|
||||||
|
description = "The isl source for the package.";
|
||||||
|
};
|
||||||
|
version = lib.options.create {
|
||||||
|
type = lib.types.string;
|
||||||
|
description = "Version of isl.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
isBuildBootstrapped = config.platform.build.double == "i686-linux";
|
||||||
|
isHostBootstrapped = config.platform.host.double == "i686-linux";
|
||||||
|
|
||||||
|
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta = {
|
||||||
|
platforms = [ "i686-linux" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
pname = "gcc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
|
||||||
|
version = "13.2.0";
|
||||||
|
|
||||||
|
builder = builders.basic;
|
||||||
|
|
||||||
|
deps = {
|
||||||
|
build = {
|
||||||
|
build = {
|
||||||
|
binutils = (packages.foundation.binutils.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 config.platform;
|
||||||
|
});
|
||||||
|
glibc = (packages.foundation.glibc.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
inherit (config.platform) build target;
|
||||||
|
host = config.platform.target;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
linux-headers = (packages.foundation.linux-headers.versions.latest.extend {
|
||||||
|
platform.target = lib.modules.override 0 config.platform.target;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
env = {
|
||||||
|
PATH = lib.paths.bin (
|
||||||
|
lib.lists.when
|
||||||
|
(isBootstrapped)
|
||||||
|
[
|
||||||
|
foundation.stage2-gcc
|
||||||
|
foundation.stage2-binutils
|
||||||
|
]
|
||||||
|
++ [
|
||||||
|
foundation.stage2-gnumake
|
||||||
|
foundation.stage2-gnused
|
||||||
|
foundation.stage2-gnugrep
|
||||||
|
foundation.stage2-gnupatch
|
||||||
|
foundation.stage2-gawk
|
||||||
|
foundation.stage2-diffutils
|
||||||
|
foundation.stage2-findutils
|
||||||
|
foundation.stage2-gnutar
|
||||||
|
foundation.stage2-gzip
|
||||||
|
foundation.stage2-bzip2
|
||||||
|
foundation.stage1-xz
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
phases = let
|
||||||
|
patches = [
|
||||||
|
# Make binutils output deterministic by default.
|
||||||
|
./patches/libstdc++-target.patch
|
||||||
|
];
|
||||||
|
in {
|
||||||
|
unpack = ''
|
||||||
|
# Unpack
|
||||||
|
tar xf ${config.src}
|
||||||
|
tar xf ${config.gmp.src}
|
||||||
|
tar xf ${config.mpfr.src}
|
||||||
|
tar xf ${config.mpc.src}
|
||||||
|
tar xf ${config.isl.src}
|
||||||
|
cd gcc-${config.version}
|
||||||
|
|
||||||
|
ln -s ../gmp-${config.gmp.version} gmp
|
||||||
|
ln -s ../mpfr-${config.mpfr.version} mpfr
|
||||||
|
ln -s ../mpc-${config.mpc.version} mpc
|
||||||
|
ln -s ../isl-${config.isl.version} isl
|
||||||
|
'';
|
||||||
|
|
||||||
|
patch = ''
|
||||||
|
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
|
||||||
|
'';
|
||||||
|
|
||||||
|
configure = ''
|
||||||
|
# Configure
|
||||||
|
export CC="gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
|
export CXX="g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
|
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2"
|
||||||
|
export LIBRARY_PATH="${foundation.stage1-musl}/lib"
|
||||||
|
export LDFLAGS_FOR_TARGET="-L${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export LDFLAGS_FOR_TARGET="$LDFLAGS_FOR_TARGET -B${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export LDFLAGS_FOR_TARGET="$LDFLAGS_FOR_TARGET -I${config.deps.build.build.linux-headers.package}/lib"
|
||||||
|
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
|
||||||
|
# TODO(vlinkz) Hack to fix missing crti.o and crtn.o. Figure out how to properly find their paths.
|
||||||
|
mkdir gcc
|
||||||
|
ln -sv ${config.deps.build.build.glibc.package}/lib/{crti.o,crtn.o} gcc
|
||||||
|
mkdir -p x86_64-unknown-linux-gnu/libstdc++-v3/src
|
||||||
|
ln -sv ${config.deps.build.build.glibc.package}/lib/{crti.o,crtn.o} x86_64-unknown-linux-gnu/libstdc++-v3/src
|
||||||
|
|
||||||
|
bash ../configure \
|
||||||
|
--prefix=$out \
|
||||||
|
--build=${config.platform.build.triple} \
|
||||||
|
--host=${config.platform.host.triple} \
|
||||||
|
--target=${config.platform.target.triple} \
|
||||||
|
--with-as=${config.deps.build.build.binutils.package}/bin/${config.platform.target.triple}-as \
|
||||||
|
--with-ld=${config.deps.build.build.binutils.package}/bin/${config.platform.target.triple}-ld \
|
||||||
|
--enable-languages=c,c++ \
|
||||||
|
--disable-libsanitizer \
|
||||||
|
--disable-lto \
|
||||||
|
--disable-multilib \
|
||||||
|
--with-headers=${config.deps.build.build.glibc.package}/include \
|
||||||
|
--with-build-sysroot=/ \
|
||||||
|
LDFLAGS_FOR_TARGET="-L$(pwd)/${config.platform.target.triple}/libgcc $LDFLAGS_FOR_TARGET"
|
||||||
|
'';
|
||||||
|
|
||||||
|
build = ''
|
||||||
|
# Build
|
||||||
|
make -j $NIX_BUILD_CORES
|
||||||
|
'';
|
||||||
|
|
||||||
|
install = ''
|
||||||
|
# Install
|
||||||
|
make -j $NIX_BUILD_CORES install
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/gcc/gcc-${config.version}/gcc-${config.version}.tar.xz";
|
||||||
|
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
|
||||||
|
};
|
||||||
|
|
||||||
|
gmp = {
|
||||||
|
version = "6.3.0";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
|
||||||
|
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mpfr = {
|
||||||
|
version = "4.2.1";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
|
||||||
|
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mpc = {
|
||||||
|
version = "1.3.1";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
|
||||||
|
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
isl = {
|
||||||
|
version = "0.24";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
|
||||||
|
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -11,6 +11,12 @@ let
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
includes = [
|
||||||
|
./newlib.nix
|
||||||
|
./cross.nix
|
||||||
|
./bootstrap.nix
|
||||||
|
];
|
||||||
|
|
||||||
config.packages.context.options = {
|
config.packages.context.options = {
|
||||||
"foundation:cflags" = lib.options.create {
|
"foundation:cflags" = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
|
@ -84,16 +90,9 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config =
|
config = {
|
||||||
let
|
|
||||||
isBuildBootstrapped = config.platform.build.double == "i686-linux";
|
|
||||||
isHostBootstrapped = config.platform.host.double == "i686-linux";
|
|
||||||
|
|
||||||
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
meta = {
|
meta = {
|
||||||
platforms = [ "i686-linux" ];
|
platforms = [ "x86_64-linux" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
pname = "gcc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
|
pname = "gcc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
|
||||||
|
@ -101,66 +100,44 @@ in
|
||||||
|
|
||||||
builder = builders.basic;
|
builder = builders.basic;
|
||||||
|
|
||||||
# hooks = ctx: let
|
deps = {
|
||||||
#
|
|
||||||
# in {
|
|
||||||
# "aux:gcc:env" = lib.dag.entry.before [ "unpack" ] ''
|
|
||||||
#
|
|
||||||
# '';
|
|
||||||
# };
|
|
||||||
|
|
||||||
deps =
|
|
||||||
let
|
|
||||||
platform =
|
|
||||||
if !isBuildBootstrapped then
|
|
||||||
{
|
|
||||||
build = "i686-linux";
|
|
||||||
host = lib.modules.override 0 config.platform.build.triple;
|
|
||||||
target = lib.modules.override 0 config.platform.build.triple;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
build = "i686-linux";
|
|
||||||
host = "i686-linux";
|
|
||||||
target = lib.modules.override 0 config.platform.host.triple;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
build = {
|
build = {
|
||||||
only = {
|
build = {
|
||||||
gcc =
|
gcc = (packages.foundation.gcc-cross.versions.latest.extend {
|
||||||
lib.modules.when
|
platform = lib.modules.override 0 {
|
||||||
(!isBootstrapped)
|
build = "i686-linux";
|
||||||
(packages.foundation.gcc.versions.latest.extend {
|
target = config.platform.target;
|
||||||
inherit platform;
|
host = "i686-linux";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
binutils = (packages.foundation.binutils.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
build = "i686-linux";
|
||||||
|
target = config.platform.target;
|
||||||
|
host = config.platform.host;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
glibc = (packages.foundation.glibc.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
build = "i686-linux";
|
||||||
|
target = config.platform.target;
|
||||||
|
host = config.platform.host;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
linux-headers = (packages.foundation.linux-headers.versions.latest.extend {
|
||||||
|
platform.target = lib.modules.override 0 config.platform.target;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
build = {
|
|
||||||
binutils = packages.foundation.binutils;
|
|
||||||
linux-headers = packages.foundation.linux-headers;
|
|
||||||
glibc = packages.foundation.glibc;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
hooks = ctx: {
|
|
||||||
"aux:compiler:setup" = lib.dag.entry.before [ "unpack" ] ''
|
|
||||||
: ''${AUX_COMPILER_LIBRARY_PATH:=}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
PATH = lib.paths.bin (
|
PATH = lib.paths.bin (
|
||||||
lib.lists.when
|
|
||||||
(isBootstrapped)
|
|
||||||
[
|
[
|
||||||
foundation.stage2-gcc
|
|
||||||
# foundation.stage2-binutils
|
|
||||||
]
|
|
||||||
++ [
|
|
||||||
foundation.stage2-gnumake
|
foundation.stage2-gnumake
|
||||||
foundation.stage2-gnused
|
foundation.stage2-gnused
|
||||||
foundation.stage2-gnugrep
|
foundation.stage2-gnugrep
|
||||||
|
foundation.stage2-gnupatch
|
||||||
foundation.stage2-gawk
|
foundation.stage2-gawk
|
||||||
foundation.stage2-diffutils
|
foundation.stage2-diffutils
|
||||||
foundation.stage2-findutils
|
foundation.stage2-findutils
|
||||||
|
@ -172,19 +149,12 @@ in
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
phases =
|
phases = let
|
||||||
let
|
patches = [
|
||||||
host = lib.systems.withBuildInfo config.platform.host;
|
# Make binutils output deterministic by default.
|
||||||
|
./patches/libstdc++-target.patch
|
||||||
compiler = if isBootstrapped then "gcc" else "${config.platform.build.triple}-gcc";
|
];
|
||||||
|
in {
|
||||||
mbits = if host.system.cpu.family == "x86" then if host.is64bit then "-m64" else "-m32" else "";
|
|
||||||
in
|
|
||||||
{
|
|
||||||
"aux:compiler:setup" = ''
|
|
||||||
: ''${AUX_COMPILER_LIBRARY_PATH:=}
|
|
||||||
'';
|
|
||||||
|
|
||||||
unpack = ''
|
unpack = ''
|
||||||
# Unpack
|
# Unpack
|
||||||
tar xf ${config.src}
|
tar xf ${config.src}
|
||||||
|
@ -201,33 +171,40 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
patch = ''
|
patch = ''
|
||||||
# Patch
|
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
|
||||||
# force musl even if host triple is gnu
|
|
||||||
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configure = ''
|
configure = ''
|
||||||
# Configure
|
# Configure
|
||||||
export CC="gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
export CC="x86_64-unknown-linux-gnu-gcc -Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.build.build.glibc.package}/lib"
|
||||||
export CXX="g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
export CXX="x86_64-unknown-linux-gnu-g++ -Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.build.build.glibc.package}/lib"
|
||||||
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2"
|
||||||
export LIBRARY_PATH="${foundation.stage1-musl}/lib"
|
export LIBRARY_PATH="${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export LDFLAGS_FOR_TARGET="-L${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export LDFLAGS_FOR_TARGET="$LDFLAGS_FOR_TARGET -B${config.deps.build.build.glibc.package}/lib"
|
||||||
|
export LDFLAGS_FOR_TARGET="$LDFLAGS_FOR_TARGET -I${config.deps.build.build.glibc.package}/include"
|
||||||
|
|
||||||
bash ./configure \
|
mkdir build
|
||||||
|
cd build
|
||||||
|
|
||||||
|
echo PATH=$PATH
|
||||||
|
|
||||||
|
bash ../configure \
|
||||||
--prefix=$out \
|
--prefix=$out \
|
||||||
--build=${config.platform.build.triple} \
|
--build=${config.platform.build.triple} \
|
||||||
--host=${config.platform.host.triple} \
|
--host=${config.platform.host.triple} \
|
||||||
--target=${config.platform.target.triple} \
|
--target=${config.platform.target.triple} \
|
||||||
--with-sysroot=${foundation.stage1-musl} \
|
--with-as=${config.deps.build.build.binutils.package}/bin/as \
|
||||||
--with-native-system-header-dir=/include \
|
--with-ld=${config.deps.build.build.binutils.package}/bin/ld \
|
||||||
--enable-languages=c,c++ \
|
--enable-languages=c,c++ \
|
||||||
--disable-bootstrap \
|
--disable-bootstrap \
|
||||||
--disable-libsanitizer \
|
--disable-libsanitizer \
|
||||||
--disable-lto \
|
|
||||||
--disable-multilib \
|
--disable-multilib \
|
||||||
--disable-plugin \
|
--with-native-system-header-dir=${config.deps.build.build.glibc.package}/include \
|
||||||
CFLAGS=-static \
|
--with-gxx-include-dir=${placeholder "out"}/include/c++/${config.version}/ \
|
||||||
CXXFLAGS=-static
|
--with-build-sysroot=/ \
|
||||||
|
--enable-static \
|
||||||
|
LDFLAGS_FOR_TARGET="-L$(pwd)/${config.platform.target.triple}/libgcc $LDFLAGS_FOR_TARGET"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
build = ''
|
build = ''
|
||||||
|
|
240
tidepool/src/packages/foundation/gcc/newlib.nix
Normal file
240
tidepool/src/packages/foundation/gcc/newlib.nix
Normal file
|
@ -0,0 +1,240 @@
|
||||||
|
{ config, options }:
|
||||||
|
let
|
||||||
|
inherit (config)
|
||||||
|
lib
|
||||||
|
mirrors
|
||||||
|
builders
|
||||||
|
# These are the upstream foundational packages exported from the Aux Foundation project.
|
||||||
|
|
||||||
|
foundation
|
||||||
|
packages
|
||||||
|
;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config.packages.foundation.gcc-newlib = {
|
||||||
|
versions = {
|
||||||
|
"latest" =
|
||||||
|
{ config, meta }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
src = lib.options.create {
|
||||||
|
type = lib.types.derivation;
|
||||||
|
description = "Source for the package.";
|
||||||
|
};
|
||||||
|
|
||||||
|
cc = {
|
||||||
|
src = lib.options.create {
|
||||||
|
type = lib.types.derivation;
|
||||||
|
description = "The cc source for the package.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
gmp = {
|
||||||
|
src = lib.options.create {
|
||||||
|
type = lib.types.derivation;
|
||||||
|
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.derivation;
|
||||||
|
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.derivation;
|
||||||
|
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.derivation;
|
||||||
|
description = "The isl source for the package.";
|
||||||
|
};
|
||||||
|
version = lib.options.create {
|
||||||
|
type = lib.types.string;
|
||||||
|
description = "Version of isl.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
isBuildBootstrapped = config.platform.build.double == "i686-linux";
|
||||||
|
isHostBootstrapped = config.platform.host.double == "i686-linux";
|
||||||
|
|
||||||
|
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta = {
|
||||||
|
platforms = [ "i686-linux" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
pname = "gcc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
|
||||||
|
version = "13.2.0";
|
||||||
|
|
||||||
|
builder = builders.basic;
|
||||||
|
|
||||||
|
deps = {
|
||||||
|
build = {
|
||||||
|
build = {
|
||||||
|
binutils = (packages.foundation.binutils.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 config.platform;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
env = {
|
||||||
|
PATH = lib.paths.bin (
|
||||||
|
lib.lists.when
|
||||||
|
(isBootstrapped)
|
||||||
|
[
|
||||||
|
foundation.stage2-gcc
|
||||||
|
foundation.stage2-binutils
|
||||||
|
]
|
||||||
|
++ [
|
||||||
|
foundation.stage2-gnumake
|
||||||
|
foundation.stage2-gnused
|
||||||
|
foundation.stage2-gnugrep
|
||||||
|
foundation.stage2-gawk
|
||||||
|
foundation.stage2-diffutils
|
||||||
|
foundation.stage2-findutils
|
||||||
|
foundation.stage2-gnutar
|
||||||
|
foundation.stage2-gzip
|
||||||
|
foundation.stage2-bzip2
|
||||||
|
foundation.stage1-xz
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
phases = {
|
||||||
|
unpack = ''
|
||||||
|
# Unpack
|
||||||
|
tar xf ${config.src}
|
||||||
|
tar xf ${config.gmp.src}
|
||||||
|
tar xf ${config.mpfr.src}
|
||||||
|
tar xf ${config.mpc.src}
|
||||||
|
tar xf ${config.isl.src}
|
||||||
|
cd gcc-${config.version}
|
||||||
|
|
||||||
|
ln -s ../gmp-${config.gmp.version} gmp
|
||||||
|
ln -s ../mpfr-${config.mpfr.version} mpfr
|
||||||
|
ln -s ../mpc-${config.mpc.version} mpc
|
||||||
|
ln -s ../isl-${config.isl.version} isl
|
||||||
|
'';
|
||||||
|
|
||||||
|
patch = ''
|
||||||
|
# Patch
|
||||||
|
# force musl even if host triple is gnu
|
||||||
|
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
|
||||||
|
'';
|
||||||
|
|
||||||
|
configure = ''
|
||||||
|
# Configure
|
||||||
|
export CC="gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
|
export CXX="g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
|
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
|
export LIBRARY_PATH="${foundation.stage1-musl}/lib"
|
||||||
|
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
|
||||||
|
bash ../configure \
|
||||||
|
--prefix=$out \
|
||||||
|
--build=${config.platform.build.triple} \
|
||||||
|
--host=${config.platform.host.triple} \
|
||||||
|
--target=${config.platform.target.triple} \
|
||||||
|
--with-as=${config.deps.build.build.binutils.package}/bin/${config.platform.target.triple}-as \
|
||||||
|
--with-ld=${config.deps.build.build.binutils.package}/bin/${config.platform.target.triple}-ld \
|
||||||
|
--enable-languages=c,c++ \
|
||||||
|
--disable-bootstrap \
|
||||||
|
--disable-libsanitizer \
|
||||||
|
--disable-lto \
|
||||||
|
--disable-multilib \
|
||||||
|
--disable-plugin \
|
||||||
|
--disable-libssp \
|
||||||
|
--disable-libvtv \
|
||||||
|
--disable-libstdcxx \
|
||||||
|
--disable-libquadmath \
|
||||||
|
--disable-threads \
|
||||||
|
--disable-decimal-float \
|
||||||
|
--disable-shared \
|
||||||
|
--disable-libmudflap \
|
||||||
|
--disable-libgomp \
|
||||||
|
--disable-libatomic \
|
||||||
|
--without-headers \
|
||||||
|
--with-newlib
|
||||||
|
'';
|
||||||
|
|
||||||
|
build = ''
|
||||||
|
# Build
|
||||||
|
make -j $NIX_BUILD_CORES
|
||||||
|
'';
|
||||||
|
|
||||||
|
install = ''
|
||||||
|
# Install
|
||||||
|
make -j $NIX_BUILD_CORES install
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/gcc/gcc-${config.version}/gcc-${config.version}.tar.xz";
|
||||||
|
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
|
||||||
|
};
|
||||||
|
|
||||||
|
gmp = {
|
||||||
|
version = "6.3.0";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
|
||||||
|
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mpfr = {
|
||||||
|
version = "4.2.1";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
|
||||||
|
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mpc = {
|
||||||
|
version = "1.3.1";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
|
||||||
|
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
isl = {
|
||||||
|
version = "0.24";
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
|
||||||
|
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
# From https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/development/compilers/gcc/patches/libstdc%2B%2B-target.patch
|
||||||
|
Patch to make the target libraries 'configure' scripts find the proper CPP.
|
||||||
|
I noticed that building the mingw32 cross compiler.
|
||||||
|
Looking at the build script for mingw in archlinux, I think that only nixos
|
||||||
|
needs this patch. I don't know why.
|
||||||
|
diff --git a/Makefile.in b/Makefile.in
|
||||||
|
index 93f66b6..d691917 100644
|
||||||
|
--- a/Makefile.in
|
||||||
|
+++ b/Makefile.in
|
||||||
|
@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \
|
||||||
|
AR="$(AR_FOR_TARGET)"; export AR; \
|
||||||
|
AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
|
||||||
|
CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
|
||||||
|
+ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \
|
||||||
|
CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
|
||||||
|
CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
|
||||||
|
CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
|
||||||
|
@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \
|
||||||
|
RAW_CXX_TARGET_EXPORTS = \
|
||||||
|
$(BASE_TARGET_EXPORTS) \
|
||||||
|
CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
|
||||||
|
- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
|
||||||
|
+ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
|
||||||
|
+ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
|
||||||
|
|
||||||
|
NORMAL_TARGET_EXPORTS = \
|
||||||
|
$(BASE_TARGET_EXPORTS) \
|
||||||
|
- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
|
||||||
|
+ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
|
||||||
|
+ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
|
||||||
|
|
||||||
|
# Where to find GMP
|
||||||
|
HOST_GMPLIBS = @gmplibs@
|
|
@ -1,8 +1,9 @@
|
||||||
{
|
{ lib
|
||||||
lib,
|
, lib'
|
||||||
lib',
|
, config
|
||||||
config,
|
, options
|
||||||
options,
|
, packages
|
||||||
|
,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (config)
|
inherit (config)
|
||||||
|
@ -10,6 +11,7 @@ let
|
||||||
builders
|
builders
|
||||||
# These are the upstream foundational packages exported from the Aux Foundation project.
|
# These are the upstream foundational packages exported from the Aux Foundation project.
|
||||||
|
|
||||||
|
packages
|
||||||
foundation
|
foundation
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
|
@ -26,12 +28,17 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config =
|
||||||
|
let
|
||||||
|
isCross = (config.platform.build.triple != config.platform.host.triple) && (config.platform.host.triple == config.platform.target.triple);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
platforms = [ "i686-linux" ];
|
platforms = [ "i686-linux" "x86_64-linux" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
pname = "gcc";
|
pname = "glibc";
|
||||||
version = "2.38";
|
version = "2.38";
|
||||||
|
|
||||||
src = builtins.fetchurl {
|
src = builtins.fetchurl {
|
||||||
|
@ -41,10 +48,14 @@ in
|
||||||
|
|
||||||
builder = builders.basic;
|
builder = builders.basic;
|
||||||
|
|
||||||
hooks = ctx: {
|
deps = {
|
||||||
"aux:glibc:env" = lib.dag.entry.between ["aux:compiler:setup"] ["configure"] ''
|
build ={
|
||||||
AUX_COMPILER_LIBRARY_PATH="${config.package}/lib:$AUX_COMPILER_LIBRARY_PATH"
|
host = {
|
||||||
'';
|
linux-headers = (packages.foundation.linux-headers.versions.latest.extend {
|
||||||
|
platform.target = lib.modules.override 0 config.platform.target;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
|
@ -52,25 +63,21 @@ in
|
||||||
let
|
let
|
||||||
gcc =
|
gcc =
|
||||||
if
|
if
|
||||||
config.platform.build.triple == config.platform.host.triple
|
isCross
|
||||||
# If we're on the same system then we can use the existing GCC instance.
|
|
||||||
then
|
|
||||||
foundation.stage2-gcc
|
|
||||||
# Otherwise we are going to need a cross-compiler.
|
# Otherwise we are going to need a cross-compiler.
|
||||||
|
then
|
||||||
|
(packages.foundation.gcc-newlib.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
inherit (config.platform) build target;
|
||||||
|
host = config.platform.build;
|
||||||
|
};
|
||||||
|
}).package
|
||||||
|
# If we're on the same system then we can use the existing GCC instance.
|
||||||
else
|
else
|
||||||
(meta.extend (args: {
|
foundation.stage2-gcc;
|
||||||
config = {
|
|
||||||
platform = {
|
|
||||||
build = config.platform.build.triple;
|
|
||||||
host = config.platform.build.triple;
|
|
||||||
target = lib.modules.override.force config.platform.host.triple;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})).config.package;
|
|
||||||
in
|
in
|
||||||
lib.paths.bin [
|
lib.paths.bin [
|
||||||
foundation.stage2-gcc
|
gcc
|
||||||
foundation.stage2-binutils
|
|
||||||
foundation.stage2-gnumake
|
foundation.stage2-gnumake
|
||||||
foundation.stage2-gnused
|
foundation.stage2-gnused
|
||||||
foundation.stage2-gnugrep
|
foundation.stage2-gnugrep
|
||||||
|
@ -86,7 +93,22 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
phases = {
|
phases =
|
||||||
|
let
|
||||||
|
binutils =
|
||||||
|
if
|
||||||
|
isCross
|
||||||
|
then
|
||||||
|
"${(packages.foundation.binutils.versions.latest.extend {
|
||||||
|
platform = lib.modules.override 0 {
|
||||||
|
inherit (config.platform) build target;
|
||||||
|
host = config.platform.build;
|
||||||
|
};
|
||||||
|
}).package}/${config.platform.target.triple}"
|
||||||
|
else
|
||||||
|
foundation.stage2-binutils;
|
||||||
|
in
|
||||||
|
{
|
||||||
unpack = ''
|
unpack = ''
|
||||||
tar xf ${config.src}
|
tar xf ${config.src}
|
||||||
cd glibc-${config.version}
|
cd glibc-${config.version}
|
||||||
|
@ -95,13 +117,13 @@ in
|
||||||
configure = ''
|
configure = ''
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
# libstdc++.so is built against musl and fails to link
|
|
||||||
export CXX=false
|
|
||||||
bash ../configure \
|
bash ../configure \
|
||||||
--prefix=$out \
|
--prefix=$out \
|
||||||
--build=${config.platform.build.triple} \
|
--build=${config.platform.build.triple} \
|
||||||
--host=${config.platform.host.triple} \
|
--host=${config.platform.host.triple} \
|
||||||
--with-headers=${foundation.stage1-linux-headers}/include
|
--with-headers=${config.deps.build.host.linux-headers.package}/include \
|
||||||
|
--with-binutils=${binutils}/bin
|
||||||
'';
|
'';
|
||||||
|
|
||||||
build = ''
|
build = ''
|
||||||
|
@ -111,7 +133,8 @@ in
|
||||||
|
|
||||||
install = ''
|
install = ''
|
||||||
# Install
|
# Install
|
||||||
make -j $NIX_BUILD_CORES INSTALL_UNCOMPRESSED=yes install
|
make -j $NIX_BUILD_CORES install
|
||||||
|
ln -sv $(ls -d ${config.deps.build.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{ lib
|
||||||
lib,
|
, lib'
|
||||||
lib',
|
, config
|
||||||
config,
|
, options
|
||||||
options,
|
,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (config)
|
inherit (config)
|
||||||
|
@ -28,7 +28,7 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
meta = {
|
meta = {
|
||||||
platforms = [ "i686-linux" ];
|
platforms = [ "x86_64-linux" "i686-linux" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
pname = "linux-headers";
|
pname = "linux-headers";
|
||||||
|
@ -60,7 +60,7 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
build = ''
|
build = ''
|
||||||
make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=${config.platform.host.linux.arch} headers
|
make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=${config.platform.target.linux.arch} headers
|
||||||
'';
|
'';
|
||||||
|
|
||||||
install = ''
|
install = ''
|
||||||
|
|
Loading…
Reference in a new issue