stdenv.cc: add proper C++ support

This commit is contained in:
Emery Hemingway 2021-02-18 15:35:02 +01:00
parent bf93a9d05e
commit a9b18e95c4
4 changed files with 41 additions and 4 deletions

View File

@ -79,6 +79,11 @@ in nullPkgs // {
# keep libposix NEEDED # keep libposix NEEDED
}) coreutils); }) coreutils);
gccForLibs = if targetPlatform.isGenode then
final.genodePackages.genodeSources.toolchain.cc
else
prev.gccForLibs;
gdb = addPatchesTarget [ ./gdb/genode.patch ] gdb; gdb = addPatchesTarget [ ./gdb/genode.patch ] gdb;
genodeLibcCross = callPackage ./libc { }; genodeLibcCross = callPackage ./libc { };
@ -93,10 +98,6 @@ in nullPkgs // {
else else
prev.grub2; prev.grub2;
libconfig =
overrideAttrsHost (attrs: { configureFlags = [ "--disable-examples" ]; })
libconfig;
libcCrossChooser = name: libcCrossChooser = name:
if stdenv.targetPlatform.isGenode then if stdenv.targetPlatform.isGenode then
targetPackages.genodeLibcCross targetPackages.genodeLibcCross

View File

@ -0,0 +1,16 @@
{ genodePackages, symlinkJoin }:
let inherit (genodePackages) genodeSources;
in symlinkJoin {
name = "libcxx";
paths = with genodePackages; [ stdcxx ];
postBuild = ''
local headerDir="''${!outputDev}/include"
mkdir -p "$headerDir"
pushd ${genodeSources.ports.stdcxx}/*
cp -r \
include/include/stdcxx/* \
${genodeSources}/repos/libports/include/stdcxx \
"$headerDir"
popd
'';
}

View File

@ -96,12 +96,25 @@ let
lldClang = if stdenv.targetPlatform.isGenode then lldClang = if stdenv.targetPlatform.isGenode then
wrapCCWith rec { wrapCCWith rec {
cc = tools.clang-unwrapped; cc = tools.clang-unwrapped;
gccForLibs = genodePackages.genodeSources.toolchain.cc;
bintools = wrapBintoolsWith { inherit (tools) bintools; }; bintools = wrapBintoolsWith { inherit (tools) bintools; };
extraBuildCommands = with genodePackages.genodeSources; '' extraBuildCommands = with genodePackages.genodeSources; ''
echo "--gcc-toolchain=${toolchain.cc}" >> $out/nix-support/cc-cflags echo "--gcc-toolchain=${toolchain.cc}" >> $out/nix-support/cc-cflags
echo "--sysroot=${genodeBase}" >> $out/nix-support/cc-cflags echo "--sysroot=${genodeBase}" >> $out/nix-support/cc-cflags
echo "-I${genodeBase}/include" >> $out/nix-support/cc-cflags echo "-I${genodeBase}/include" >> $out/nix-support/cc-cflags
echo "-L ${genodeBase}" >> $out/nix-support/cc-cflags echo "-L ${genodeBase}" >> $out/nix-support/cc-cflags
for dir in ${gccForLibs}/${stdenv.targetPlatform.config}/include/c++/*; do
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
done
echo "-isystem ${genodePackages.genodeSources}/repos/libports/include/stdcxx" >> $out/nix-support/libcxx-cxxflags
for dir in ${genodePackages.genodeSources.ports.stdcxx}/*/include/stdcxx; do
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
echo "-isystem $dir/std" >> $out/nix-support/libcxx-cxxflags
echo "-isystem $dir/c_global" >> $out/nix-support/libcxx-cxxflags
done
echo "${genodePackages.stdcxx}/lib/stdcxx.lib.so" >> $out/nix-support/libcxx-ldflags
''; '';
} }
else else

View File

@ -62,8 +62,15 @@ let
makeWrapper ''${BIN} x86_64-unknown-genode-''${BIN#$out/bin/genode-x86-} makeWrapper ''${BIN} x86_64-unknown-genode-''${BIN#$out/bin/genode-x86-}
done done
popd popd
ln -s $out/aarch64-none-elf $out/aarch64-unknown-genode
ln -s $out/arm-none-eabi $out/arm-unknown-genode
ln -s $out/riscv64-unknown-elf $out/riscv-unknown-genode
ln -s $out/x86_64-pc-elf $out/x86_64-unknown-genode
''; '';
} // { } // {
# Needed by the GCC wrapper.
langC = true;
langCC = true;
isGNU = true; isGNU = true;
targetPrefix = { targetPrefix = {
aarch64-genode = "genode-arm-"; aarch64-genode = "genode-arm-";