forked from auxolotl/labs
wip: custom targets
This commit is contained in:
parent
e2f6de0b11
commit
5bc3ec5eb0
29 changed files with 229 additions and 109 deletions
|
|
@ -38,6 +38,15 @@ let
|
|||
./src/mirrors
|
||||
|
||||
recursiveLibModule
|
||||
{
|
||||
config = {
|
||||
systems.extraTargets = {
|
||||
x86_64-linux-musl = {
|
||||
system = "x86_64-unknown-linux-musl";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
]
|
||||
++ lib.lists.from.any module;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ in
|
|||
package.env
|
||||
// {
|
||||
inherit (package) name;
|
||||
inherit script system;
|
||||
inherit script;
|
||||
system = (lib.systems.withBuildInfo system).double;
|
||||
|
||||
outputs = builtins.attrNames (lib.packages.getOutputs package);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,19 @@ let
|
|||
|
||||
getDoubles =
|
||||
predicate:
|
||||
builtins.map lib.systems.into.double (builtins.filter predicate lib.systems.doubles.resolved);
|
||||
builtins.filter (double: predicate (lib.systems.from.string double)) lib.systems.doubles.all;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
systems.extraTargets = (
|
||||
lib.options.create {
|
||||
description = "Map of extra target systems.";
|
||||
default.value = { };
|
||||
type = lib.types.either lib.types.string lib.types.attrs.any;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
config = {
|
||||
lib.systems = {
|
||||
match = builtins.mapAttrs (lib.fp.const matchAnyAttrs) lib.systems.patterns;
|
||||
|
|
@ -1752,12 +1762,15 @@ in
|
|||
from = {
|
||||
string =
|
||||
value:
|
||||
let
|
||||
parts = lib.strings.split "-" value;
|
||||
skeleton = lib.systems.skeleton parts;
|
||||
system = lib.systems.create (lib.systems.from.skeleton skeleton);
|
||||
in
|
||||
system;
|
||||
if lib.attrs.has [ value ] config.systems.extraTargets then
|
||||
lib.systems.from.string config.systems.extraTargets."${value}".system
|
||||
else
|
||||
let
|
||||
parts = lib.strings.split "-" value;
|
||||
skeleton = lib.systems.skeleton parts;
|
||||
system = lib.systems.create (lib.systems.from.skeleton skeleton);
|
||||
in
|
||||
system;
|
||||
|
||||
skeleton =
|
||||
spec@{
|
||||
|
|
@ -2433,7 +2446,8 @@ in
|
|||
# Windows
|
||||
"x86_64-windows"
|
||||
"i686-windows"
|
||||
];
|
||||
]
|
||||
++ builtins.attrNames config.systems.extraTargets;
|
||||
|
||||
arm = getDoubles lib.systems.match.isAarch32;
|
||||
armv7 = getDoubles lib.systems.match.isArmv7;
|
||||
|
|
@ -2538,7 +2552,14 @@ in
|
|||
withBuildInfo =
|
||||
args:
|
||||
let
|
||||
settings = if builtins.isString args then { system = args; } else args;
|
||||
settings =
|
||||
if builtins.isString args then
|
||||
if lib.attrs.has [ args ] config.systems.extraTargets then
|
||||
config.systems.extraTargets."${args}"
|
||||
else
|
||||
{ system = args; }
|
||||
else
|
||||
args;
|
||||
|
||||
resolved = {
|
||||
system = lib.systems.from.string (if settings ? triple then settings.triple else settings.system);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
@ -92,17 +92,12 @@ in
|
|||
|
||||
configure =
|
||||
let
|
||||
flags = builtins.concatStringsSep " " (
|
||||
[
|
||||
"--prefix=$out"
|
||||
"--build=${platform.build.triple}"
|
||||
"--host=${platform.host.triple}"
|
||||
"--enable-static-link"
|
||||
]
|
||||
++ lib.lists.when (config.platform.host == "i686-linux") [
|
||||
"--without-bash-malloc"
|
||||
]
|
||||
);
|
||||
flags = builtins.concatStringsSep " " ([
|
||||
"--prefix=$out"
|
||||
"--build=${platform.build.triple}"
|
||||
"--host=${platform.host.triple}"
|
||||
"--without-bash-malloc"
|
||||
]);
|
||||
in
|
||||
''
|
||||
# Configure
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ in
|
|||
settings = {
|
||||
target = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
default.value = config.platform.host;
|
||||
};
|
||||
allTargets = lib.options.create {
|
||||
description = "Include all targets (dramatically increases size of binaries).";
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ let
|
|||
platform = {
|
||||
build = lib.systems.withBuildInfo config.platform.build;
|
||||
host = lib.systems.withBuildInfo config.platform.host;
|
||||
target = lib.systems.withBuildInfo config.settings.target;
|
||||
};
|
||||
|
||||
version = lib.strings.removeSuffix "-stage1" config.version;
|
||||
|
|
@ -45,8 +46,8 @@ let
|
|||
++ lib.lists.when (config.settings.allTargets) [
|
||||
"--enable-target=all"
|
||||
]
|
||||
++ lib.lists.when (config.settings.target != null) [
|
||||
"--target=${(lib.systems.withBuildInfo config.settings.target).triple}"
|
||||
++ lib.lists.when (platform.host.triple != platform.target.triple) [
|
||||
"--target=${platform.target.triple}"
|
||||
];
|
||||
in
|
||||
{
|
||||
|
|
@ -54,7 +55,7 @@ in
|
|||
settings = {
|
||||
target = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
default.value = config.platform.host;
|
||||
};
|
||||
allTargets = lib.options.create {
|
||||
description = "Include all targets (dramatically increases size of binaries).";
|
||||
|
|
@ -137,7 +138,7 @@ in
|
|||
}
|
||||
)
|
||||
// (lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ in
|
|||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ let
|
|||
|
||||
gccFlags = [
|
||||
"-Wl,-dynamic-linker=${foundation.stage1-musl}/lib/libc.so"
|
||||
"-Wl,-rpath,${foundation.stage1-musl}/lib"
|
||||
"-B${foundation.stage1-musl}/lib"
|
||||
];
|
||||
in
|
||||
|
|
|
|||
|
|
@ -7,24 +7,39 @@ let
|
|||
builders
|
||||
;
|
||||
|
||||
platform = {
|
||||
build = lib.systems.withBuildInfo config.platform.build;
|
||||
host = lib.systems.withBuildInfo config.platform.host;
|
||||
target = lib.systems.withBuildInfo config.settings.target;
|
||||
};
|
||||
|
||||
package =
|
||||
if
|
||||
config.platform.build == config.platform.host && config.platform.host != config.settings.target
|
||||
platform.build.triple == platform.host.triple && platform.host.triple != platform.target.triple
|
||||
then
|
||||
packages.foundation.gcc.versions."13.2.0-stage2".extend {
|
||||
builtins.trace "CROSS ${config.platform.host} ${config.settings.target}"
|
||||
packages.foundation.gcc.versions."13.2.0-stage2".extend
|
||||
{
|
||||
platform = lib.modules.overrides.force config.platform;
|
||||
settings.target = config.settings.target;
|
||||
}
|
||||
else if
|
||||
platform.build.triple != platform.host.triple && platform.host.triple == platform.target.triple
|
||||
then
|
||||
builtins.trace "CROSSED" packages.foundation.gcc.versions."13.2.0-stage3".extend {
|
||||
platform = lib.modules.overrides.force config.platform;
|
||||
settings.target = config.settings.target;
|
||||
}
|
||||
else if
|
||||
config.platform.build != config.platform.host && config.platform.host == config.settings.target
|
||||
platform.build.triple != platform.host.triple && platform.host.triple != platform.target.triple
|
||||
then
|
||||
packages.foundation.gcc.versions."13.2.0-stage3".extend {
|
||||
platform = lib.modules.overrides.force config.platform;
|
||||
}
|
||||
throw "Canadian cross is not supported"
|
||||
else
|
||||
packages.foundation.gcc.versions."13.2.0-stage4".extend {
|
||||
platform = lib.modules.overrides.force config.platform;
|
||||
};
|
||||
builtins.trace "NATIVE ${config.platform.host} ${config.settings.target}"
|
||||
packages.foundation.gcc.versions."13.2.0-stage4".extend
|
||||
{
|
||||
platform = lib.modules.overrides.force config.platform;
|
||||
settings.target = builtins.trace "TARGET ${config.settings.target}" config.settings.target;
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ let
|
|||
];
|
||||
|
||||
gccFlags = [
|
||||
"-Wl,-dynamic-linker=${config.deps.host.glibc.dynamicLinker}"
|
||||
"-Wl,-rpath,${config.deps.host.glibc.package}/lib"
|
||||
"-L${config.deps.host.glibc.package}/lib"
|
||||
"-B${config.deps.host.glibc.package}/lib"
|
||||
"-Wl,-dynamic-linker=${config.deps.host.libc.dynamicLinker}"
|
||||
"-Wl,-rpath,${config.deps.host.libc.package}/lib"
|
||||
"-L${config.deps.host.libc.package}/lib"
|
||||
"-B${config.deps.host.libc.package}/lib"
|
||||
"-L${config.package.outPath}${libPrefix}/lib"
|
||||
"-B${config.package.outPath}${libPrefix}/lib"
|
||||
];
|
||||
|
|
@ -49,9 +49,9 @@ let
|
|||
"--disable-libsanitizer"
|
||||
"--disable-lto"
|
||||
"--disable-multilib"
|
||||
"--with-headers=${config.deps.host.glibc.package}/include"
|
||||
"--with-headers=${config.deps.host.libc.package}/include"
|
||||
"--with-build-sysroot=/"
|
||||
"--with-native-system-header-dir=${config.deps.host.glibc.package}/include"
|
||||
"--with-native-system-header-dir=${config.deps.host.libc.package}/include"
|
||||
"--with-build-time-tools=${config.deps.build.binutils-cross.package}/bin"
|
||||
];
|
||||
in
|
||||
|
|
@ -184,16 +184,26 @@ in
|
|||
};
|
||||
|
||||
host = {
|
||||
glibc = packages.foundation.glibc.versions."2.38-stage1".extend {
|
||||
platform.host = lib.modules.overrides.force config.settings.target;
|
||||
};
|
||||
libc =
|
||||
if platform.target.libc == "glibc" then
|
||||
packages.foundation.glibc.versions."2.38-stage1".extend {
|
||||
platform.host = lib.modules.overrides.force config.settings.target;
|
||||
}
|
||||
else
|
||||
packages.foundation.musl.versions."1.2.4-stage1".extend {
|
||||
platform.host = lib.modules.overrides.force config.settings.target;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
env = {
|
||||
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.glibc.dynamicLinker} -B${config.deps.host.glibc.package}/lib";
|
||||
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.target.triple}/libgcc -L${config.deps.host.glibc.package}/lib";
|
||||
LIBRARY_PATH = "${config.deps.host.glibc.package}/lib";
|
||||
CFLAGS_FOR_TARGET = builtins.concatStringsSep " " [
|
||||
"-Wl,-dynamic-linker=${config.deps.host.libc.dynamicLinker}"
|
||||
"-Wl,-rpath,${config.deps.host.libc.package}/lib"
|
||||
"-B${config.deps.host.libc.package}/lib"
|
||||
];
|
||||
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.target.triple}/libgcc -L${config.deps.host.libc.package}/lib";
|
||||
LIBRARY_PATH = "${config.deps.host.libc.package}/lib";
|
||||
};
|
||||
|
||||
hooks = ctx: {
|
||||
|
|
@ -239,9 +249,9 @@ in
|
|||
|
||||
# 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.host.glibc.package}/lib/{crti.o,crtn.o} gcc
|
||||
ln -sv ${config.deps.host.libc.package}/lib/{crti.o,crtn.o} gcc
|
||||
mkdir -p ${platform.target.triple}/libstdc++-v3/src
|
||||
ln -sv ${config.deps.host.glibc.package}/lib/{crti.o,crtn.o} ${platform.target.triple}/libstdc++-v3/src
|
||||
ln -sv ${config.deps.host.libc.package}/lib/{crti.o,crtn.o} ${platform.target.triple}/libstdc++-v3/src
|
||||
|
||||
bash ../configure ${builtins.concatStringsSep " " configureFlags}
|
||||
'';
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ let
|
|||
];
|
||||
|
||||
gccFlags = [
|
||||
"-Wl,-dynamic-linker=${config.deps.host.glibc.dynamicLinker}"
|
||||
"-Wl,-rpath,${config.deps.host.glibc.package}/lib"
|
||||
"-L${config.deps.host.glibc.package}/lib"
|
||||
"-B${config.deps.host.glibc.package}/lib"
|
||||
"-Wl,-dynamic-linker=${config.deps.host.libc.dynamicLinker}"
|
||||
"-Wl,-rpath,${config.deps.host.libc.package}/lib"
|
||||
"-L${config.deps.host.libc.package}/lib"
|
||||
"-B${config.deps.host.libc.package}/lib"
|
||||
"-L${config.package.outPath}/lib"
|
||||
"-B${config.package.outPath}/lib"
|
||||
];
|
||||
|
|
@ -39,7 +39,7 @@ let
|
|||
"--disable-bootstrap"
|
||||
"--disable-libsanitizer"
|
||||
"--disable-multilib"
|
||||
"--with-native-system-header-dir=${config.deps.host.glibc.package}/include"
|
||||
"--with-native-system-header-dir=${config.deps.host.libc.package}/include"
|
||||
"--with-gxx-include-dir=${builtins.placeholder "out"}/include/c++/${config.version}/"
|
||||
"--with-build-sysroot=/"
|
||||
];
|
||||
|
|
@ -142,7 +142,11 @@ in
|
|||
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
|
||||
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
|
||||
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
|
||||
glibc = packages.foundation.glibc.versions."2.38-bootstrap";
|
||||
libc =
|
||||
if platform.host.libc == "glibc" then
|
||||
packages.foundation.glibc.versions."2.38-bootstrap"
|
||||
else
|
||||
packages.foundation.musl.versions."1.2.4-bootstrap";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -159,27 +163,52 @@ in
|
|||
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
|
||||
binutils = packages.foundation.binutils.versions."2.41-stage1";
|
||||
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
|
||||
glibc = packages.foundation.glibc.versions."2.38-stage1-passthrough";
|
||||
libc =
|
||||
if platform.host.libc == "glibc" then
|
||||
packages.foundation.glibc.versions."2.38-stage1-passthrough"
|
||||
else
|
||||
packages.foundation.musl.versions."1.2.4-stage1-passthrough";
|
||||
}
|
||||
)
|
||||
// {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
|
||||
host = {
|
||||
glibc = packages.foundation.glibc.versions."2.38-stage1";
|
||||
libc =
|
||||
if platform.host.libc == "glibc" then
|
||||
packages.foundation.glibc.versions."2.38-stage1"
|
||||
else
|
||||
packages.foundation.musl.versions."1.2.4-stage1";
|
||||
};
|
||||
};
|
||||
|
||||
env = rec {
|
||||
CFLAGS_FOR_BUILD = "-Wl,-dynamic-linker -Wl,${config.deps.build.glibc.dynamicLinker} -B${config.deps.build.glibc.package}/lib";
|
||||
LDFLAGS_FOR_BUILD = "-L${config.deps.build.gcc.package}/lib -L${config.deps.build.glibc.package}/lib -Wl,-rpath,${config.deps.build.gcc.package}/lib -Wl,-rpath,${config.deps.build.glibc.package}/lib";
|
||||
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.glibc.dynamicLinker} -B${config.deps.host.glibc.package}/lib";
|
||||
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.host.triple}/libgcc -L${config.deps.host.glibc.package}/lib";
|
||||
CFLAGS = CFLAGS_FOR_TARGET;
|
||||
LDFLAGS = LDFLAGS_FOR_TARGET;
|
||||
LIBRARY_PATH = "${config.deps.host.glibc.package}/lib";
|
||||
env = {
|
||||
CFLAGS_FOR_BUILD = builtins.concatStringsSep " " [
|
||||
"-Wl,-dynamic-linker=${config.deps.build.libc.dynamicLinker}"
|
||||
"-Wl,-rpath,${config.deps.build.libc.package}/lib"
|
||||
"-B${config.deps.build.libc.package}/lib"
|
||||
"-Wl,-rpath,${config.deps.build.gcc.package}/lib"
|
||||
"-B${config.deps.build.gcc.package}/lib"
|
||||
];
|
||||
LDFLAGS_FOR_BUILD = builtins.concatStringsSep " " [
|
||||
"-Wl,-rpath,${config.deps.build.gcc.package}/lib"
|
||||
"-Wl,-rpath,${config.deps.build.libc.package}/lib"
|
||||
];
|
||||
CFLAGS_FOR_TARGET = builtins.concatStringsSep " " [
|
||||
"-Wl,-dynamic-linker=${config.deps.host.libc.dynamicLinker}"
|
||||
"-Wl,-rpath,${builtins.placeholder "out"}/lib"
|
||||
"-B${builtins.placeholder "out"}/lib"
|
||||
"-Wl,-rpath,${config.deps.host.libc.package}/lib"
|
||||
"-B${config.deps.host.libc.package}/lib"
|
||||
];
|
||||
LDFLAGS_FOR_TARGET = builtins.concatStringsSep " " [
|
||||
"-L$(pwd)/${platform.host.triple}/libgcc"
|
||||
"-Wl,-rpath,${builtins.placeholder "out"}/lib"
|
||||
"-Wl,-rpath,${config.deps.host.libc.package}/lib"
|
||||
];
|
||||
LIBRARY_PATH = "${config.deps.host.libc.package}/lib";
|
||||
};
|
||||
|
||||
hooks = ctx: {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ let
|
|||
platform = {
|
||||
build = lib.systems.withBuildInfo config.platform.build;
|
||||
host = lib.systems.withBuildInfo config.platform.host;
|
||||
target = lib.systems.withBuildInfo config.settings.target;
|
||||
};
|
||||
|
||||
patches = [
|
||||
|
|
@ -21,10 +22,10 @@ let
|
|||
];
|
||||
|
||||
gccFlags = [
|
||||
"-Wl,-dynamic-linker=${config.deps.host.glibc.dynamicLinker}"
|
||||
"-Wl,-rpath,${config.deps.host.glibc.package}/lib"
|
||||
"-L${config.deps.host.glibc.package}/lib"
|
||||
"-B${config.deps.host.glibc.package}/lib"
|
||||
"-Wl,-dynamic-linker=${config.deps.host.libc.dynamicLinker}"
|
||||
"-Wl,-rpath,${config.deps.host.libc.package}/lib"
|
||||
"-L${config.deps.host.libc.package}/lib"
|
||||
"-B${config.deps.host.libc.package}/lib"
|
||||
"-L${config.package.outPath}/lib"
|
||||
"-B${config.package.outPath}/lib"
|
||||
];
|
||||
|
|
@ -39,7 +40,7 @@ let
|
|||
"--disable-libsanitizer"
|
||||
"--disable-multilib"
|
||||
"--with-build-sysroot=/"
|
||||
"--with-native-system-header-dir=${config.deps.host.glibc.package}/include"
|
||||
"--with-native-system-header-dir=${config.deps.host.libc.package}/include"
|
||||
];
|
||||
in
|
||||
{
|
||||
|
|
@ -63,6 +64,16 @@ in
|
|||
type = lib.types.string;
|
||||
description = "Version of isl.";
|
||||
};
|
||||
|
||||
settings.target = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default.value = config.platform.host;
|
||||
description = "Target of the compiler";
|
||||
apply =
|
||||
value:
|
||||
assert (lib.systems.withBuildInfo value).triple == platform.host.triple;
|
||||
value;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
|
@ -146,17 +157,33 @@ in
|
|||
host =
|
||||
if (config.platform.build == "i686-linux") then
|
||||
{
|
||||
glibc = packages.foundation.glibc.versions."2.38-bootstrap";
|
||||
libc =
|
||||
if platform.host.libc == "glibc" then
|
||||
packages.foundation.glibc.versions."2.38-bootstrap"
|
||||
else
|
||||
packages.foundation.musl.versions."1.2.4-bootstrap";
|
||||
}
|
||||
else
|
||||
{
|
||||
glibc = packages.foundation.glibc.versions."2.38-stage1-passthrough";
|
||||
libc =
|
||||
if platform.host.libc == "glibc" then
|
||||
packages.foundation.glibc.versions."2.38-stage1-passthrough"
|
||||
else
|
||||
packages.foundation.musl.versions."1.2.4-stage1-passthrough";
|
||||
};
|
||||
};
|
||||
|
||||
env = {
|
||||
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.glibc.dynamicLinker}";
|
||||
LIBRARY_PATH = "${config.deps.host.glibc.package}/lib";
|
||||
CFLAGS_FOR_TARGET = builtins.concatStringsSep " " [
|
||||
"-Wl,-dynamic-linker=${config.deps.host.libc.dynamicLinker}"
|
||||
"-Wl,-rpath,${builtins.placeholder "out"}/lib"
|
||||
"-Wl,-rpath,${config.deps.host.libc.package}/lib"
|
||||
];
|
||||
LDFLAGS_FOR_TARGET = builtins.concatStringsSep " " [
|
||||
"-Wl,-rpath,${builtins.placeholder "out"}/lib"
|
||||
"-Wl,-rpath,${config.deps.host.libc.package}/lib"
|
||||
];
|
||||
LIBRARY_PATH = "${config.deps.host.libc.package}/lib";
|
||||
};
|
||||
|
||||
hooks = ctx: {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ in
|
|||
options = {
|
||||
dynamicLinker = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default = "ld-linux-x86-64.so.2";
|
||||
description = "The dynamic linker/loader to be used.";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ in
|
|||
options = {
|
||||
dynamicLinker = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default = "ld-linux-x86-64.so.2";
|
||||
default.value = "ld-linux-x86-64.so.2";
|
||||
description = "The dynamic linker/loader to be used.";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-passthrough".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
{ global }:
|
||||
{ config, global }:
|
||||
|
||||
let
|
||||
inherit (global) lib builders;
|
||||
inherit (global.internal.packages) foundation;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
dynamicLinker = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default.value = "${config.package.outPath}/lib/libc.so";
|
||||
description = "The dynamic linker/loader to be used.";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
meta = {
|
||||
description = "An efficient, small, quality libc implementation.";
|
||||
|
|
|
|||
|
|
@ -23,6 +23,14 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
dynamicLinker = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default.value = "${config.package.outPath}/lib/libc.so";
|
||||
description = "The dynamic linker/loader to be used.";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
meta = {
|
||||
description = "An efficient, small, quality libc implementation.";
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@ let
|
|||
|
||||
in
|
||||
{
|
||||
options = {
|
||||
dynamicLinker = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default.value = "${config.package.outPath}/lib/libc.so";
|
||||
description = "The dynamic linker/loader to be used.";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
meta = {
|
||||
description = "An efficient, small, quality libc implementation.";
|
||||
|
|
@ -67,16 +75,9 @@ in
|
|||
}
|
||||
)
|
||||
// lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
gcc = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
|
||||
binutils = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage1".target.${config.platform.host};
|
||||
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
|
||||
};
|
||||
# target = lib.attrs.when (config.platform.host != config.platform.target) {
|
||||
# gcc = packages.foundation.gcc.versions."13.2.0-stage2";
|
||||
# binutils = packages.foundation.binutils.versions."2.41-stage1";
|
||||
# };
|
||||
host = lib.attrs.when (config.platform.build != config.platform.host) {
|
||||
bash = packages.foundation.bash.versions."5.2.15-stage1";
|
||||
};
|
||||
};
|
||||
|
||||
phases = {
|
||||
|
|
@ -119,12 +120,9 @@ in
|
|||
install = ''
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install
|
||||
sed -i 's|/bin/sh|${
|
||||
if (config.platform.build != config.platform.host) then
|
||||
config.deps.host.bash.package
|
||||
else
|
||||
config.deps.build.bash.package
|
||||
}/bin/bash|' $out/bin/*
|
||||
${lib.strings.when (config.platform.build == config.platform.host) ''
|
||||
sed -i 's|/bin/sh|${config.deps.build.bash.package}/bin/bash|' $out/bin/*
|
||||
''}
|
||||
ln -s ../lib/libc.so $out/bin/ldd
|
||||
'';
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue