2020-04-24 23:36:52 +00:00
|
|
|
{ runCommand,
|
|
|
|
clang,
|
|
|
|
gcc64,
|
|
|
|
gcc32,
|
|
|
|
glibc_multi
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
combine = basegcc: runCommand "combine-gcc-libc" {} ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -r ${basegcc.cc}/lib $out/lib
|
|
|
|
|
|
|
|
chmod u+rw -R $out/lib
|
|
|
|
cp -r ${basegcc.libc}/lib/* $(ls -d $out/lib/gcc/*/*)
|
|
|
|
'';
|
2021-02-05 17:12:51 +00:00
|
|
|
gcc_multi_sysroot = runCommand "gcc-multi-sysroot" {
|
|
|
|
passthru = {
|
|
|
|
inherit (gcc64) version;
|
|
|
|
lib = gcc_multi_sysroot;
|
|
|
|
};
|
|
|
|
} ''
|
2022-04-15 01:41:22 +00:00
|
|
|
mkdir -p $out/lib{,64}/gcc
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
ln -s ${combine gcc64}/lib/gcc/* $out/lib64/gcc/
|
2020-04-24 23:36:52 +00:00
|
|
|
ln -s ${combine gcc32}/lib/gcc/* $out/lib/gcc/
|
|
|
|
# XXX: This shouldn't be needed, clang just doesn't look for "i686-unknown"
|
|
|
|
ln -s $out/lib/gcc/i686-unknown-linux-gnu $out/lib/gcc/i686-pc-linux-gnu
|
|
|
|
|
|
|
|
|
|
|
|
# includes
|
2023-05-24 13:37:59 +00:00
|
|
|
mkdir -p $out/include
|
|
|
|
ln -s ${glibc_multi.dev}/include/* $out/include
|
|
|
|
ln -s ${gcc64.cc}/include/c++ $out/include/c++
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# dynamic linkers
|
|
|
|
mkdir -p $out/lib/32
|
|
|
|
ln -s ${glibc_multi.out}/lib/ld-linux* $out/lib
|
|
|
|
ln -s ${glibc_multi.out}/lib/32/ld-linux* $out/lib/32/
|
|
|
|
'';
|
|
|
|
|
|
|
|
clangMulti = clang.override {
|
2021-02-05 17:12:51 +00:00
|
|
|
# Only used for providing expected structure re:dynamic linkers, AFAIK Most
|
|
|
|
# of the magic is done by setting the --gcc-toolchain option via
|
|
|
|
# `gccForLibs`.
|
2020-04-24 23:36:52 +00:00
|
|
|
libc = gcc_multi_sysroot;
|
|
|
|
|
|
|
|
bintools = clang.bintools.override {
|
|
|
|
libc = gcc_multi_sysroot;
|
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
gccForLibs = gcc_multi_sysroot // {
|
|
|
|
inherit (glibc_multi) libgcc;
|
|
|
|
langCC =
|
|
|
|
assert (gcc64.cc.langCC != gcc32.cc.langCC)
|
|
|
|
-> throw "(gcc64.cc.langCC=${gcc64.cc.langCC}) != (gcc32.cc.langCC=${gcc32.cc.langCC})";
|
|
|
|
gcc64.cc.langCC;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in clangMulti
|