Remove target cause GCC is dumb

This commit is contained in:
Ross Smyth 2025-10-02 18:59:46 -04:00 committed by Victor Fuentes
parent b67847e7eb
commit f9b7a00988
Signed by: vlinkz
GPG key ID: DF727B8D5AF99C64
45 changed files with 46 additions and 170 deletions

View file

@ -27,10 +27,7 @@ in
all = lib.lists.flatten [
hooks.build.build
hooks.build.host
hooks.build.target
hooks.host.host
hooks.host.target
hooks.target.target
];
in
builtins.foldl' (
@ -88,10 +85,7 @@ in
bins = lib.paths.bin (
(lib.packages.dependencies.get dependencies.build.build)
++ (lib.packages.dependencies.get dependencies.build.host)
++ (lib.packages.dependencies.get dependencies.build.target)
++ (lib.packages.dependencies.get dependencies.host.host)
++ (lib.packages.dependencies.get dependencies.host.target)
++ (lib.packages.dependencies.get dependencies.target.target)
++ lib.lists.when (system == "i686-linux") [
foundation.stage2-bash
foundation.stage2-coreutils

View file

@ -15,8 +15,8 @@ in
builtins.map (dependency: dependency.package) available;
build =
build: host: target:
builtins.mapAttrs (name: dep: (lib.packages.resolve dep).packages.${build}.${host}.${target});
build: host:
builtins.mapAttrs (name: dep: (lib.packages.resolve dep).packages.${build}.${host});
collect =
package:
@ -36,27 +36,16 @@ in
build =
getPropagatedDependencies dependency.deps.build.build ++ process dependency.deps.build.build;
host = getPropagatedDependencies dependency.deps.build.host ++ process dependency.deps.build.host;
target =
getPropagatedDependencies dependency.deps.build.target ++ process dependency.deps.build.target;
};
host = {
host = getPropagatedDependencies dependency.deps.host.host ++ process dependency.deps.host.host;
target =
getPropagatedDependencies dependency.deps.host.target ++ process dependency.deps.host.target;
};
target = {
target =
getPropagatedDependencies dependency.deps.target.target ++ process dependency.deps.target.target;
};
};
in
lib.lists.flatten [
deps.build.build
deps.build.host
deps.build.target
deps.host.host
deps.host.target
deps.target.target
];
propagated = lib.attrs.mapToList getDeps dependencies;
@ -73,20 +62,9 @@ in
host = withoutNulls (
builtins.attrValues package.deps.build.host ++ process package.deps.build.host
);
target = withoutNulls (
builtins.attrValues package.deps.build.target ++ process package.deps.build.target
);
};
host = {
host = withoutNulls (builtins.attrValues package.deps.host.host ++ process package.deps.host.host);
target = withoutNulls (
builtins.attrValues package.deps.host.target ++ process package.deps.host.target
);
};
target = {
target = withoutNulls (
builtins.attrValues package.deps.target.target ++ process package.deps.target.target
);
};
};
};
@ -119,7 +97,6 @@ in
type = lib.types.enum [
"build"
"host"
"target"
];
writable = false;
default.value = path;
@ -136,13 +113,10 @@ in
build = process "build" [
collected.build.build
collected.build.host
collected.build.target
];
host = process "host" [
collected.host.host
collected.host.target
];
target = process "target" [ collected.target.target ];
in
build
// host
@ -150,7 +124,6 @@ in
inherit
build
host
target
package
;
@ -199,26 +172,12 @@ in
"build"
"host"
];
target = process [
"build"
"target"
];
};
host = {
host = process [
"host"
"host"
];
target = process [
"host"
"target"
];
};
target = {
target = process [
"target"
"target"
];
};
};
};
@ -263,7 +222,7 @@ in
alias;
build =
alias: build: host: target:
alias: build: host:
let
package = lib.packages.resolve alias;
@ -277,36 +236,34 @@ in
buildSystem = lib.systems.withBuildInfo build;
hostSystem = lib.systems.withBuildInfo host;
targetSystem = lib.systems.withBuildInfo target;
platform = {
build = lib.modules.override 75 build;
host = lib.modules.override 75 host;
target = lib.modules.override 75 target;
};
built = package.extendTemporarily {
inherit platform;
};
support = lib.packages.supports package buildSystem.double hostSystem.double targetSystem.double;
support = lib.packages.supports package buildSystem.double hostSystem.double;
result =
if !support.compatible then
builtins.throw "📦 [Aux Tidepool] Package `${identifier}` does not support the platform build=${buildSystem.double}, host=${hostSystem.double}, target=${targetSystem.double}."
builtins.throw "📦 [Aux Tidepool] Package `${identifier}` does not support the platform build=${buildSystem.double}, host=${hostSystem.double}"
else if support.broken then
builtins.throw "📦 [Aux Tidepool] Package `${identifier}` is marked as broken and cannot be built."
else
built;
in
builtins.addErrorContext "📦 [Aux Tidepool] while building package `${identifier}` for platform build=${buildSystem.double}, host=${hostSystem.double}, target=${targetSystem.double}." result;
builtins.addErrorContext "📦 [Aux Tidepool] while building package `${identifier}` for platform build=${buildSystem.double}, host=${hostSystem.double}" result;
supports =
alias: build: host: target:
alias: build: host:
let
package = lib.packages.resolve alias;
matches = builtins.filter (
platform: platform.build == build && platform.host == host && platform.target == target
platform: platform.build == build && platform.host == host
) package.platforms;
in
{

View file

@ -12,31 +12,26 @@ in
# {
# build = "x86_64-linux";
# host = "x86_64-linux";
# target = "x86_64-linux";
# }
#
# {
# build = "*";
# host = "*";
# target = "@host";
# }
#
# {
# build = "*";
# host = ["x86_64-linux", "aarch64-linux"];
# target = "@host";
# }
#
# [
# {
# build = "*";
# host = ["x86_64-linux", "aarch64-linux"];
# target = "@host";
# }
# {
# build = "i686-linux";
# host = "@build";
# target = "@host";
# }
# ]
#
@ -51,23 +46,13 @@ in
let
build = lib.platforms.expand spec spec.build;
host = lib.platforms.expand spec spec.host;
target = lib.platforms.expand spec spec.target;
in
builtins.concatMap (
build:
builtins.concatMap (
host:
builtins.map (target: {
build = build;
host = if host == "@build" then build else host;
target =
if target == "@host" then
if host == "@build" then build else host
else if target == "@build" then
build
else
target;
}) target
) host
) build
) specs

View file

@ -293,8 +293,7 @@ in
platforms = {
build = lib.types.attrs.of lib.types.platforms.host;
host = lib.types.attrs.of lib.types.platforms.target;
target = lib.types.attrs.of (lib.types.attrs.of lib.types.platforms.alias);
host = lib.types.attrs.of lib.types.platforms.host;
alias = lib.types.submodule {
options = {
stable = lib.options.create {
@ -331,12 +330,6 @@ in
type = lib.types.string;
default.value = "@build";
};
target = lib.options.create {
description = "The target platform for the package.";
type = lib.types.string;
default.value = "@host";
};
};
}
);
@ -491,7 +484,7 @@ in
};
deps =
build: host: target:
build: host:
lib.types.submodule {
options = {
build = {
@ -506,12 +499,6 @@ in
type = lib.types.dependencies;
default.value = { };
};
target = lib.options.create {
description = "Dependencies which are created in the build environment and are executed in the target environment.";
type = lib.types.dependencies;
default.value = { };
};
};
host = {
@ -520,20 +507,6 @@ in
type = lib.types.dependencies;
default.value = { };
};
target = lib.options.create {
description = "Dependencies which are executed in the host environment which produces code for the target environment.";
type = lib.types.dependencies;
default.value = { };
};
};
target = {
target = lib.options.create {
description = "Dependencies which are executed in the target environment.";
type = lib.types.dependencies;
default.value = { };
};
};
};
};
@ -546,7 +519,6 @@ in
let
build = config.platform.build;
host = config.platform.host;
target = config.platform.target;
in
{
options = {
@ -728,12 +700,6 @@ in
type = lib.types.string;
default.value = initial.host or "x86_64-linux";
};
target = lib.options.create {
description = "The target platform for the package.";
type = lib.types.string;
default.value = initial.target or "x86_64-linux";
};
};
name = lib.options.create {
@ -818,7 +784,7 @@ in
build:
lib.attrs.generate lib.systems.doubles.all (
host:
lib.attrs.generate lib.systems.doubles.all (target: lib.packages.build config build host target)
lib.attrs.generate lib.systems.doubles.all (target: lib.packages.build config build host)
)
);
};
@ -857,20 +823,15 @@ in
deps = lib.options.create {
description = "The dependencies for the package.";
type = deps build host target;
type = deps build host;
default.value = { };
apply = value: {
build = {
build = lib.packages.dependencies.build build build build value.build.build;
host = lib.packages.dependencies.build build build host value.build.host;
target = lib.packages.dependencies.build build build target value.build.target;
};
host = {
host = lib.packages.dependencies.build build host host value.host.host;
target = lib.packages.dependencies.build build host target value.host.target;
};
target = {
target = lib.packages.dependencies.build build target target value.target.target;
};
};
};

View file

@ -13,17 +13,14 @@ in
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];

View file

@ -17,17 +17,14 @@ in
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];

View file

@ -17,22 +17,18 @@ in
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
{
build = "i686-linux";
host = "i686-linux";
target = "x86_64-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -11,20 +11,42 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
<<<<<<< HEAD
=======
isBuildBootstrapped = platform.build.double == "i686-linux";
isHostBootstrapped = platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isCross =
platform.build.double != platform.host.double;
>>>>>>> 586d02f (Remove target cause GCC is dumb)
version = lib.strings.removeSuffix "-stage1" config.version;
patches = [
../patches/2.41-deterministic.patch
];
<<<<<<< HEAD
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${platform.target.triple}"
=======
configureFlags =
lib.lists.when (!isCross) [
"LDFLAGS=--static"
]
++ [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${platform.host.triple}"
>>>>>>> 586d02f (Remove target cause GCC is dumb)
"--with-sysroot=/"
"--enable-deterministic-archives"
@ -54,8 +76,12 @@ in
platforms = [
{
<<<<<<< HEAD
build = "i686-linux";
target = "x86_64-linux";
=======
build = "@linux";
>>>>>>> 586d02f (Remove target cause GCC is dumb)
}
{
build = "x86_64-linux";

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -12,7 +12,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
prefix = lib.strings.when (

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
configureFlags = [

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -82,7 +81,7 @@ in
--build=${platform.build.triple} \
--host=${platform.host.triple} \
--with-headers=${config.deps.build.host.linux-headers.package}/include \
--with-binutils=${config.deps.build.host.binutils.package}/${platform.target.triple}/bin
--with-binutils=${config.deps.build.host.binutils.package}/${platform.host.triple}/bin
'';
build = ''

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -111,11 +110,11 @@ in
dynamicLinker =
"${config.package.outPath}/lib/"
+ (
if platform.target.double == "x86_64-linux" then
if platform.host.double == "x86_64-linux" then
"ld-linux-x86-64.so.2"
else if platform.target.double == "aarch64-linux" then
else if platform.host.double == "aarch64-linux" then
"ld-linux-aarch64.so.1"
else if platform.target.double == "riscv64-linux" then
else if platform.host.double == "riscv64-linux" then
"ld-linux-riscv64-lp64d.so.1"
else
"ld-linux.so.2"
@ -137,7 +136,7 @@ in
"--with-headers=${config.deps.build.host.linux-headers.package}/include"
]
++ lib.lists.when (config.platform.build != config.platform.host) [
"--with-binutils=${config.deps.build.host.binutils.package}/${platform.target.triple}/bin"
"--with-binutils=${config.deps.build.host.binutils.package}/${platform.host.triple}/bin"
]
);
in

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
patches = [

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -13,7 +13,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{

View file

@ -14,7 +14,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -8,7 +8,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -20,7 +19,7 @@ in
platforms = {
build = "@linux";
target = "@linux";
host = "@linux";
};
builder = builders.foundation.basic;
@ -80,7 +79,7 @@ in
make -j $NIX_BUILD_CORES V=1 \
"CC=''${CC_FOR_TARGET:-''${CC}}" \
"HOSTCC=$CC" \
ARCH=${platform.target.linux.arch} \
ARCH=${platform.host.linux.arch} \
headers
'';

View file

@ -12,7 +12,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
patches = [

View file

@ -18,7 +18,6 @@ let
"x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in

View file

@ -12,7 +12,6 @@ let
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{