A bunch of unstaged stuff I found months later

eris-update
Emery Hemingway 2021-12-10 10:07:57 +00:00
parent 2b1c9d710a
commit ad9261c0ac
34 changed files with 634 additions and 618 deletions

View File

@ -5,11 +5,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1615634419,
"narHash": "sha256-VSPhQ2wvwrPbnfxPGsXQe3lTEsTOk9mUjfD/WVDPskM=",
"lastModified": 1617699750,
"narHash": "sha256-jVsaLrPxppRW40hob3OR1tspdWcWXRwvu2mGVGqH/2Y=",
"owner": "nix-community",
"repo": "flake-nimble",
"rev": "79d42ec0ba0349a967b38db70ae2e3e2f6d9c3e2",
"rev": "5d7a9c0d28472ad2ded4c3c335b8d3b1f6a65e6d",
"type": "github"
},
"original": {
@ -33,16 +33,16 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1617984351,
"narHash": "sha256-mo/tmR1sVmQ+4uziIAZpdNnr9AG0NAAo9Md3tucf73k=",
"owner": "NixOS",
"lastModified": 1618995560,
"narHash": "sha256-pqMtPTgqWatdhIPBxENaZPKSirJ2AMYegkNBnD9ur4A=",
"owner": "ehmry",
"repo": "nixpkgs",
"rev": "842f900e73c7ce985218cc4f455e34d1d56475c1",
"rev": "efc09182fa0cc67721c878d6da48ea968c99984e",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"owner": "ehmry",
"ref": "sigil",
"repo": "nixpkgs",
"type": "github"
}

View File

@ -1,7 +1,7 @@
{
description = "Nix flavored Genode distribution";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.nixpkgs.url = "github:ehmry/nixpkgs/sigil";
outputs = { self, nixpkgs, nimble }:
let

View File

@ -30,6 +30,7 @@ in λ ( params
λ(binary : Text) →
Init.toChild
Init::{
, verbose = True
, routes = [ Init.ServiceRoute.parent "Timer" ]
, children = toMap
{ terminal =
@ -99,7 +100,7 @@ in λ ( params
( toMap
{ name = "regular"
, path = params.fontFile
, size_px = "10"
, size_px = "8"
}
)
]

View File

@ -5,29 +5,34 @@ let toDhall = lib.generators.toDhall { };
in {
imports = [ ./ahci.nix ./framebuffer.nix ./nic.nix ./usb.nix ];
options.hardware.genode.platform.policies = lib.mkOption {
type = with types; listOf path;
default = [ ];
description = ''
List of policies to append to the Genode platform driver.
Type is Init.Config.Policy.Type.
'';
options.hardware.genode = {
verbose = lib.mkEnableOption "verbose drivers";
platform.policies = lib.mkOption {
type = with types; listOf path;
default = [ ];
description = ''
List of policies to append to the Genode platform driver.
Type is Init.Config.Policy.Type.
'';
};
};
config = let
deviceManagerEnable = config.hardware.genode.ahci.enable
|| config.hardware.genode.usb.enable;
cfg = config.hardware.genode;
deviceManagerEnable = cfg.ahci.enable || cfg.usb.enable;
ahciEris = lib.getEris "bin" pkgs.genodePackages.ahci_drv;
partBlockEris = lib.getEris "bin" pkgs.genodePackages.part_block;
usbEris = lib.attrsets.mapAttrs (_: lib.getEris "bin") {
inherit (pkgs.genodePackages) usb_block_drv usb_drv;
usb_block_drv = cfg.usb.storage.package;
usb_host_drv = cfg.usb.host.package;
};
ahciConfig = with config.hardware.genode.ahci;
ahciConfig = with cfg.ahci;
lib.optionalString enable ''
, ahci_driver = Some ${
, ahci_drv = Some ${
toDhall {
binary = ahciEris.cap;
atapi = atapiSupport;
@ -35,20 +40,20 @@ in {
}
'';
usbConfig = with config.hardware.genode.usb;
lib.optionalString enable ''
, usb_block = Some { binary = "${usbEris.usb_block_drv.cap}" }
, usb_driver = Some ${
toDhall {
binary = usbEris.usb_drv.cap;
bios_handoff = biosHandoff;
ehci = ehciSupport;
ohci = ohciSupport;
uhci = uhciSupport;
xhci = xhciSupport;
}
usbConfig = lib.optionalString cfg.usb.enable ''
, usb_block_drv = Some { binary = "${usbEris.usb_block_drv.cap}" }
, usb_host_drv = Some ${
with cfg.usb.host;
toDhall {
binary = usbEris.usb_host_drv.cap;
bios_handoff = biosHandoff;
ehci = ehciSupport;
ohci = ohciSupport;
uhci = uhciSupport;
xhci = xhciSupport;
}
'';
}
'';
managerConfig = pkgs.writeText "device_manager.dhall" ''
let Manager = ${pkgs.genodePackages.device_manager.dhall}/package.dhall
@ -58,6 +63,7 @@ in {
, part_block.binary = "${partBlockEris.cap}"
${ahciConfig}
${usbConfig}
, verbose = ${toDhall cfg.verbose}
}
'';
in {
@ -124,9 +130,8 @@ in {
genode.core.children.drivers = lib.mkIf deviceManagerEnable {
package = pkgs.genodePackages.init;
extraErisInputs = [ partBlockEris ]
++ lib.optional config.hardware.genode.ahci.enable ahciEris
++ lib.optionals config.hardware.genode.usb.enable
(builtins.attrValues usbEris);
++ lib.optional cfg.ahci.enable ahciEris
++ lib.optionals cfg.usb.enable (builtins.attrValues usbEris);
configFile = pkgs.writeText "drivers.dhall" ''
let Sigil = env:DHALL_SIGIL

View File

@ -42,6 +42,12 @@ in {
Init.Child.flat
Init.Child.Attributes::{
, binary
, config = Init.Config::{
, attributes = toMap
{ width = "1024"
, height = "768"
}
}
, resources = Init.Resources::{ caps = 256, ram = Sigil.units.MiB 32 }
, routes =
[ Init.ServiceRoute.parent "IO_MEM"

View File

@ -10,21 +10,32 @@ in {
options.hardware.genode.usb = {
enable = lib.mkEnableOption "USB driver";
storage.enable = lib.mkEnableOption "USB mass storage driver";
biosHandoff = mkEnableOption' "perform the BIOS handoff procedure" true;
host = {
package = lib.mkOption {
type = types.package;
default = pkgs.genodePackages.usb_host_drv;
description = "USB host driver package.";
};
biosHandoff = mkEnableOption' "perform the BIOS handoff procedure" true;
ehciSupport = mkEnableOption' "EHCI support" true;
ohciSupport = mkEnableOption' "OHCI support" true;
uhciSupport = mkEnableOption' "UHCI support" true;
xhciSupport = mkEnableOption' "XHCI support" true;
};
storage = {
enable = lib.mkEnableOption "USB mass storage driver";
package = lib.mkOption {
type = types.package;
default = pkgs.genodePackages.usb_block_drv;
description = "USB mass storage driver package.";
};
};
ehciSupport = mkEnableOption' "EHCI support" true;
ohciSupport = mkEnableOption' "OHCI support" true;
uhciSupport = mkEnableOption' "UHCI support" false;
xhciSupport = mkEnableOption' "XHCI support" true;
};
config = let
cfg = config.hardware.genode.usb;
usbEris = lib.attrsets.mapAttrs (_: lib.getEris "bin") {
inherit (pkgs.genodePackages) part_block usb_block_drv usb_drv;
};
config = let cfg = config.hardware.genode.usb;
in {
hardware.genode.usb.enable = lib.mkDefault cfg.storage.enable;

View File

@ -1,8 +1,6 @@
# Builds a compressed EFI System Partition image
{ config, lib, pkgs }:
with config.block.partitions;
pkgs.stdenv.mkDerivation {
name = "boot.qcow2";
@ -40,8 +38,8 @@ pkgs.stdenv.mkDerivation {
sfdisk $img <<EOF
label: gpt
label-id: $disklabel
start=$(( $storeByteOffset / $sectorSize )), uuid=${store.guid}, type=${store.gptType}
start=$(( $espByteOffset / $sectorSize )), uuid=${esp.guid}, type=${esp.gptType}
start=$(( $storeByteOffset / $sectorSize )), uuid=${config.block.partitions.store.guid}, type=${store.gptType}
start=$(( $espByteOffset / $sectorSize )), uuid=${config.block.partitions.esp.guid}, type=${esp.gptType}
EOF
sfdisk --reorder $img

View File

@ -51,9 +51,9 @@ in {
boot.loader.grub = {
extraEntries = ''
menuentry 'Genode on NOVA' {
insmod multiboot2
menuentry 'sigil-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}' {
insmod gzio
insmod multiboot2
multiboot2 /boot/bender.gz serial_fallback
module2 /boot/hypervisor.gz hypervisor iommu logmem novga novpid serial
module2 /boot/image.elf.gz image.elf

View File

@ -5,7 +5,7 @@ with import ../tests/lib/qemu-flags.nix { inherit pkgs; };
let
qemu = config.system.build.qemu;
qemu = pkgs.buildPackages.buildPackages.qemu;
cfg = config.virtualisation;

View File

@ -3,7 +3,7 @@ final: prev:
with prev;
let
# Helper functions to override package dependant
# Helper functions to override package dependent
# on whether the host or target system is Genode.
overrideHost = attrs: drv:
@ -32,8 +32,8 @@ let
if hostPlatform.isGenode then
builtins.listToAttrs (map (name: {
inherit name;
value = null;
}) [ "iproute2" ])
value = final.hello;
}) [ "iproute2" "strace" ])
else
{ };
@ -43,7 +43,7 @@ in nullPkgs // {
configureFlags = attrs.configureFlags
++ [ "--without-bash-malloc" ]; # no sbrk please
postPatch = "sed '/check_dev_tty/d' shell.c";
}) bash;
}) prev.bash;
binutils-unwrapped = overrideAttrsTarget (attrs: {
patches = attrs.patches ++ [
@ -52,7 +52,7 @@ in nullPkgs // {
];
nativeBuildInputs = attrs.nativeBuildInputs
++ [ final.updateAutotoolsGnuConfigScriptsHook ];
}) binutils-unwrapped;
}) prev.binutils-unwrapped;
cmake =
# TODO: upstream
@ -67,7 +67,7 @@ in nullPkgs // {
fi
cp ${./cmake/Genode.cmake} $MODULE
'';
}) cmake;
}) prev.cmake;
coreutils = overrideHost {
gmp = null;
@ -82,7 +82,7 @@ in nullPkgs // {
];
LDFLAGS = [ "-Wl,--no-as-needed" ];
# keep libposix NEEDED
}) coreutils);
}) prev.coreutils);
erisPatchHook = final.callPackage ./eris-patch-hook {
patchelf = prev.patchelf.overrideAttrs (attrs: {
@ -97,7 +97,7 @@ in nullPkgs // {
gdb = addPatchesTarget [
./gdb/genode.patch
# Upstreamed, remove at next release.
] gdb;
] prev.gdb;
genodeLibcCross = callPackage ./libc { };
@ -126,11 +126,11 @@ in nullPkgs // {
./libsodium/genode.patch
# https://github.com/jedisct1/libsodium/pull/1006
];
}) libsodium;
}) prev.libsodium;
libkrb5 =
# Do not want.
autoreconfHost libkrb5;
autoreconfHost prev.libkrb5;
libtool =
# Autotools related nonesense. Better to compile
@ -139,24 +139,27 @@ in nullPkgs // {
nativeBuildInputs = with final;
attrs.nativeBuildInputs ++ [ autoconf automake115x ];
patches = ./libtool/genode.patch;
}) libtool;
}) prev.libtool;
libtoxcore = overrideHost {
libopus = null;
libvpx = null;
} libtoxcore;
} prev.libtoxcore;
linuxPackages =
# Dummy package.
if hostPlatform.isGenode then {
extend = _: final.linuxPackages;
features = { };
kernel.config = {
isEnabled = _: false;
isYes = _: false;
kernel = {
version = "999";
config = {
isEnabled = _: false;
isYes = _: false;
};
};
} else
linuxPackages;
prev.linuxPackages;
llvmPackages_11 = if targetPlatform.isGenode then
# A copy of the LLVM expressions from Nixpkgs.
@ -175,7 +178,7 @@ in nullPkgs // {
ncurses =
# https://invisible-island.net/autoconf/
# Stay clear of upstream on this one.
addPatchesHost [ ./ncurses/genode.patch ] ncurses;
addPatchesHost [ ./ncurses/genode.patch ] prev.ncurses;
nim-unwrapped =
# Fixes to the compiler and standard libary.
@ -211,7 +214,7 @@ in nullPkgs // {
configureFlags = attrs.configureFlags ++ [ "no-devcryptoeng" ];
postInstall =
"rm $out/bin/c_rehash"; # eliminate the perl runtime dependency
}) openssl);
}) prev.openssl);
patchelf = addPatchesTarget [
./patchelf/dynstr.patch
@ -231,14 +234,12 @@ in nullPkgs // {
}) prev.stdenv;
tor = overrideAttrsHost (attrs: {
configureFlags = attrs.configureFlags or [ ]
++ [ "--disable-tool-name-check" ];
patches = attrs.patches or [ ] ++ [
./tor/genode.patch
# We don't do users and groups here.
];
postPatch = null; # Avoid torsocks patching
}) tor;
}) prev.tor;
zlib = overrideAttrsHost (attrs: {
postInstall = attrs.postInstall or "" + ''
@ -247,7 +248,7 @@ in nullPkgs // {
mv libz.so.* libz.so
popd
'';
}) zlib;
}) prev.zlib;
zstd = let
static = true;

View File

@ -1,29 +1,29 @@
{ runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = if stdenv.hostPlatform != stdenv.targetPlatform then
"${stdenv.targetPlatform.config}-"
else
"";
in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } ''
mkdir -p $out/bin
for prog in ${lld}/bin/*; do
ln -s $prog $out/bin/${prefix}$(basename $prog)
done
for prog in ${llvm}/bin/*; do
ln -sf $prog $out/bin/${prefix}$(basename $prog)
done
mkdir -p $out/bin
for prog in ${lld}/bin/*; do
ln -s $prog $out/bin/${prefix}$(basename $prog)
done
for prog in ${llvm}/bin/*; do
ln -sf $prog $out/bin/${prefix}$(basename $prog)
done
ln -s ${llvm}/bin/llvm-ar $out/bin/${prefix}ar
ln -s ${llvm}/bin/llvm-as $out/bin/${prefix}as
ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp
ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm
ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy
ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump
ln -s ${llvm}/bin/llvm-ranlib $out/bin/${prefix}ranlib
ln -s ${llvm}/bin/llvm-readelf $out/bin/${prefix}readelf
ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size
ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip
ln -s ${llvm}/bin/llvm-ar $out/bin/${prefix}ar
ln -s ${llvm}/bin/llvm-as $out/bin/${prefix}as
ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp
ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm
ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy
ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump
ln -s ${llvm}/bin/llvm-ranlib $out/bin/${prefix}ranlib
ln -s ${llvm}/bin/llvm-readelf $out/bin/${prefix}readelf
ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size
ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip
ln -s ${lld}/bin/lld $out/bin/${prefix}ld
ln -s ${lld}/bin/lld $out/bin/${prefix}ld
''

View File

@ -1,7 +1,5 @@
{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
, fixDarwinDylibNames
, enableManpages ? false
}:
{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src
, python3, lld, fixDarwinDylibNames, enableManpages ? false }:
let
self = stdenv.mkDerivation ({
@ -25,16 +23,14 @@ let
buildInputs = [ libxml2 llvm ];
cmakeFlags = [
"-DCMAKE_CXX_FLAGS=-std=c++14"
"-DCLANGD_BUILD_XPC=OFF"
] ++ lib.optionals enableManpages [
"-DCLANG_INCLUDE_DOCS=ON"
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
];
cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++14" "-DCLANGD_BUILD_XPC=OFF" ]
++ lib.optionals enableManpages [
"-DCLANG_INCLUDE_DOCS=ON"
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
];
patches = [
./purity.patch
@ -49,12 +45,13 @@ let
# Patch for standalone doc building
sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
'' + lib.optionalString (stdenv.hostPlatform.isMusl || stdenv.targetPlatform.isGenode) ''
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace tools/extra/clangd/CMakeLists.txt \
--replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
'';
'' + lib.optionalString
(stdenv.hostPlatform.isMusl || stdenv.targetPlatform.isGenode) ''
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace tools/extra/clangd/CMakeLists.txt \
--replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
'';
outputs = [ "out" "lib" "python" ];
@ -90,10 +87,11 @@ let
};
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
description =
"A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
};
} // lib.optionalAttrs enableManpages {
pname = "clang-manpages";

View File

@ -6,9 +6,7 @@ let
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
inherit (stdenv.hostPlatform) isMusl;
in
stdenv.mkDerivation rec {
in stdenv.mkDerivation rec {
pname = "compiler-rt";
inherit version;
src = fetch pname "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip";
@ -24,36 +22,35 @@ stdenv.mkDerivation rec {
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
"-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
"-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
] ++ lib.optionals (stdenv.isDarwin) [
"-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
] ++ lib.optionals (useLLVM || bareMetal || isMusl) [
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ lib.optionals (useLLVM || bareMetal) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
] ++ lib.optionals (useLLVM) [
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
"-DCMAKE_C_FLAGS=-nodefaultlibs"
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ lib.optionals (bareMetal) [
"-DCOMPILER_RT_OS_DIR=baremetal"
];
] ++ lib.optionals (stdenv.isDarwin)
[ "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON" ]
++ lib.optionals (useLLVM || bareMetal || isMusl) [
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ lib.optionals (useLLVM || bareMetal) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
"-DCMAKE_SIZEOF_VOID_P=${
toString (stdenv.hostPlatform.parsed.cpu.bits / 8)
}"
] ++ lib.optionals (useLLVM) [
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
"-DCMAKE_C_FLAGS=-nodefaultlibs"
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ lib.optionals (bareMetal) [ "-DCOMPILER_RT_OS_DIR=baremetal" ];
outputs = [ "out" "dev" ];
patches = [
./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
./compiler-rt-X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
] # ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
++ lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
@ -77,14 +74,15 @@ stdenv.mkDerivation rec {
'';
# Hack around weird upsream RPATH bug
postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
ln -s "$out/lib"/*/* "$out/lib"
'' + lib.optionalString (useLLVM) ''
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
'';
postInstall = lib.optionalString
(stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
ln -s "$out/lib"/*/* "$out/lib"
'' + lib.optionalString (useLLVM) ''
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
'';
enableParallelBuilding = true;
}

View File

@ -1,219 +1,220 @@
{ lib, lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildPackages
{ lib, lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs, libxml2, python3, isl
, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith, buildPackages
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
, erisPatchHook, genodePackages ? null
}:
, erisPatchHook, genodePackages ? null }:
let
release_version = "11.0.0";
version = release_version; # differentiating these (variables) is important for RCs
version =
release_version; # differentiating these (variables) is important for RCs
targetConfig = stdenv.targetPlatform.config;
fetch = name: sha256: fetchurl {
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${release_version}/${name}-${version}.src.tar.xz";
inherit sha256;
};
clang-tools-extra_src = fetch "clang-tools-extra" "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy";
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
mkExtraBuildCommands = cc: ''
rsrc="$out/resource-root"
mkdir "$rsrc"
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {
llvm = callPackage ./llvm.nix { };
clang-unwrapped = callPackage ./clang {
inherit (tools) lld;
inherit clang-tools-extra_src;
fetch = name: sha256:
fetchurl {
url =
"https://github.com/llvm/llvm-project/releases/download/llvmorg-${release_version}/${name}-${version}.src.tar.xz";
inherit sha256;
};
# disabled until recommonmark supports sphinx 3
#Llvm-manpages = lowPrio (tools.llvm.override {
# enableManpages = true;
# python3 = pkgs.python3; # don't use python-boot
#});
clang-tools-extra_src = fetch "clang-tools-extra"
"02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy";
clang-manpages = lowPrio (tools.clang-unwrapped.override {
enableManpages = true;
python3 = pkgs.python3; # don't use python-boot
});
tools = lib.makeExtensible (tools:
let
callPackage = newScope (tools // {
inherit stdenv cmake libxml2 python3 isl release_version version fetch;
});
mkExtraBuildCommands = cc:
''
rsrc="$out/resource-root"
mkdir "$rsrc"
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + lib.optionalString (stdenv.targetPlatform.isLinux
&& !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {
# disabled until recommonmark supports sphinx 3
# lldb-manpages = lowPrio (tools.lldb.override {
# enableManpages = true;
# python3 = pkgs.python3; # don't use python-boot
# });
llvm = callPackage ./llvm.nix { };
libclang = tools.clang-unwrapped.lib;
clang-unwrapped = callPackage ./clang {
inherit (tools) lld;
inherit clang-tools-extra_src;
};
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
# disabled until recommonmark supports sphinx 3
#Llvm-manpages = lowPrio (tools.llvm.override {
# enableManpages = true;
# python3 = pkgs.python3; # don't use python-boot
#});
libstdcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
libcxx = null;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
};
clang-manpages = lowPrio (tools.clang-unwrapped.override {
enableManpages = true;
python3 = pkgs.python3; # don't use python-boot
});
libcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
};
# disabled until recommonmark supports sphinx 3
# lldb-manpages = lowPrio (tools.lldb.override {
# enableManpages = true;
# python3 = pkgs.python3; # don't use python-boot
# });
lld = callPackage ./lld.nix {};
libclang = tools.clang-unwrapped.lib;
lldb = callPackage ./lldb.nix {};
clang =
if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
# Below, is the LLVM bootstrapping logic. It handles building a
# fully LLVM toolchain from scratch. No GCC toolchain should be
# pulled in. As a consequence, it is very quick to build different
# targets provided by LLVM and we can also build for what GCC
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools.nix {};
lldClang = if stdenv.targetPlatform.isGenode then
wrapCCWith rec {
libstdcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
gccForLibs = genodePackages.genodeSources.toolchain.cc;
bintools = wrapBintoolsWith { inherit (tools) bintools; };
extraBuildCommands = with genodePackages.genodeSources; ''
echo "--gcc-toolchain=${toolchain.cc}" >> $out/nix-support/cc-cflags
echo "--sysroot=${genodeBase}" >> $out/nix-support/cc-cflags
echo "-I${genodeBase}/include" >> $out/nix-support/cc-cflags
echo "-L ${genodeBase}" >> $out/nix-support/cc-ldflags
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
libcxx = null;
extraPackages = [ targetLlvmLibraries.compiler-rt ];
extraBuildCommands = mkExtraBuildCommands cc;
};
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
wrapCCWith rec {
libcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
bintools = wrapBintoolsWith { inherit (tools) bintools; };
extraPackages =
[ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]
++ lib.optionals (!stdenv.targetPlatform.isWasm)
[ targetLlvmLibraries.libunwind ];
[ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ];
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld.nix { };
lldb = callPackage ./lldb.nix { };
# Below, is the LLVM bootstrapping logic. It handles building a
# fully LLVM toolchain from scratch. No GCC toolchain should be
# pulled in. As a consequence, it is very quick to build different
# targets provided by LLVM and we can also build for what GCC
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools.nix { };
lldClang = if stdenv.targetPlatform.isGenode then
wrapCCWith rec {
cc = tools.clang-unwrapped;
gccForLibs = genodePackages.genodeSources.toolchain.cc;
bintools = wrapBintoolsWith { inherit (tools) bintools; };
extraBuildCommands = with genodePackages.genodeSources; ''
echo "--gcc-toolchain=${toolchain.cc}" >> $out/nix-support/cc-cflags
echo "--sysroot=${genodeBase}" >> $out/nix-support/cc-cflags
echo "-I${genodeBase}/include" >> $out/nix-support/cc-cflags
echo "-L ${genodeBase}" >> $out/nix-support/cc-ldflags
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
wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
bintools = wrapBintoolsWith { inherit (tools) bintools; };
extraPackages =
[ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]
++ lib.optionals (!stdenv.targetPlatform.isWasm)
[ targetLlvmLibraries.libunwind ];
extraBuildCommands = ''
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
lldClangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith { inherit (tools) bintools; };
extraPackages = [ targetLlvmLibraries.compiler-rt ];
extraBuildCommands = ''
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
echo "-nostdlib++" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
lldClangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
lldClangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
extraPackages = [ targetLlvmLibraries.compiler-rt ];
extraBuildCommands = ''
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
extraPackages = [
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = ''
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
echo "-nostdlib++" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
lldClangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
lldClangNoCompilerRt = wrapCCWith {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
'';
};
extraPackages = [
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = ''
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
lldClangNoCompilerRt = wrapCCWith {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
'';
};
});
});
libraries = lib.makeExtensible (libraries:
let
callPackage = newScope (libraries // buildLlvmTools // {
inherit stdenv cmake libxml2 python3 isl release_version version fetch;
});
in {
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt.nix ({ }
// (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
}));
compiler-rt = callPackage ./compiler-rt.nix ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
}));
stdenv = overrideCC stdenv buildLlvmTools.clang;
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ ({ }
// (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxx = callPackage ./libc++ ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxxabi = callPackage ./libc++abi.nix ({ }
// (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
libcxxabi = callPackage ./libc++abi.nix ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
openmp = callPackage ./openmp.nix { };
openmp = callPackage ./openmp.nix {};
libunwind = callPackage ./libunwind.nix ({ }
// (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libunwind = callPackage ./libunwind.nix ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
});
});
in { inherit tools libraries; } // libraries // tools

View File

@ -1,5 +1,5 @@
{ lib, stdenv, fetch, cmake, python3, libcxxabi, llvm, fixDarwinDylibNames, version
, enableShared ? true }:
{ lib, stdenv, fetch, cmake, python3, libcxxabi, llvm, fixDarwinDylibNames
, version, enableShared ? true }:
stdenv.mkDerivation {
pname = "libc++";
@ -23,11 +23,11 @@ stdenv.mkDerivation {
buildInputs = [ libcxxabi ];
cmakeFlags = [
"-DLIBCXX_CXX_ABI=libcxxabi"
] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
++ lib.optional stdenv.hostPlatform.isWasm [
cmakeFlags = [ "-DLIBCXX_CXX_ABI=libcxxabi" ]
++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi)
"-DLIBCXX_HAS_MUSL_LIBC=1"
++ lib.optional (stdenv.hostPlatform.useLLVM or false)
"-DLIBCXX_USE_COMPILER_RT=ON" ++ lib.optional stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
@ -35,13 +35,12 @@ stdenv.mkDerivation {
enableParallelBuilding = true;
passthru = {
isLLVM = true;
};
passthru = { isLLVM = true; };
meta = {
homepage = "https://libcxx.llvm.org/";
description = "A new implementation of the C++ standard library, targeting C++11";
description =
"A new implementation of the C++ standard library, targeting C++11";
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.all;
};

View File

@ -5,10 +5,13 @@ stdenv.mkDerivation {
pname = "libc++abi";
inherit version;
src = fetch "libcxxabi" "05ac7rkjbla03bc0lf92f901dfjgxdvp8cr9fpn59a5p4x27ssaq";
src =
fetch "libcxxabi" "05ac7rkjbla03bc0lf92f901dfjgxdvp8cr9fpn59a5p4x27ssaq";
nativeBuildInputs = [ cmake ];
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
buildInputs = lib.optional
(!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm)
libunwind;
cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLLVM_ENABLE_LIBCXX=ON"
@ -16,9 +19,7 @@ stdenv.mkDerivation {
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
] ++ lib.optionals (!enableShared) [ "-DLIBCXXABI_ENABLE_SHARED=OFF" ];
patches = [ ./libcxxabi-no-threads.patch ];
@ -35,20 +36,19 @@ stdenv.mkDerivation {
patch -p1 -d llvm -i ${./libcxxabi-wasm.patch}
'';
installPhase = if stdenv.isDarwin
then ''
for file in lib/*.dylib; do
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
install_name_tool -id $out/$file $file
done
make install
install -d 755 $out/include
install -m 644 ../include/*.h $out/include
installPhase = if stdenv.isDarwin then ''
for file in lib/*.dylib; do
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
install_name_tool -id $out/$file $file
done
make install
install -d 755 $out/include
install -m 644 ../include/*.h $out/include
'' else
''
else ''
install -d -m 755 $out/include $out/lib
install -m 644 lib/libc++abi.a $out/lib
install -m 644 ../include/cxxabi.h $out/include
@ -60,7 +60,8 @@ stdenv.mkDerivation {
meta = {
homepage = "https://libcxxabi.llvm.org/";
description = "A new implementation of low level support for a standard C++ library";
description =
"A new implementation of low level support for a standard C++ library";
license = with lib.licenses; [ ncsa mit ];
maintainers = with lib.maintainers; [ vlstill ];
platforms = lib.platforms.all;