From ad9261c0ac5b2f0910e087b54474fe13dcfd06d0 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 10 Dec 2021 10:07:57 +0000 Subject: [PATCH] A bunch of unstaged stuff I found months later --- flake.lock | 18 +- flake.nix | 2 +- nixos-modules/gui/consoleLog.dhall | 3 +- nixos-modules/hardware/default.nix | 61 +-- nixos-modules/hardware/framebuffer.nix | 6 + nixos-modules/hardware/usb.nix | 33 +- nixos-modules/lib/make-bootable-image.nix | 6 +- nixos-modules/nova.nix | 4 +- nixos-modules/qemu-vm.nix | 2 +- overlay/default.nix | 45 +-- overlay/llvm-11/bintools.nix | 44 +-- overlay/llvm-11/clang/default.nix | 46 ++- overlay/llvm-11/compiler-rt.nix | 64 ++-- overlay/llvm-11/default.nix | 353 +++++++++--------- overlay/llvm-11/libc++/default.nix | 21 +- overlay/llvm-11/libc++abi.nix | 39 +- overlay/llvm-11/lld.nix | 15 +- overlay/llvm-11/lldb.nix | 67 ++-- overlay/llvm-11/llvm.nix | 184 +++++---- overlay/llvm-11/openmp.nix | 14 +- overlay/tor/genode.patch | 36 +- packages/device_manager/default.nix | 4 +- packages/genodelabs/default.nix | 2 +- packages/genodelabs/depot-targets.nix | 4 +- .../genodelabs/patches/platform_drv.patch | 42 ++- packages/genodelabs/ports.nix | 4 +- tests/bash.dhall | 62 +-- tests/bash.nix | 32 +- tests/default.nix | 2 + tests/graphics.nix | 8 +- tests/hello.dhall | 1 - tests/lib/build-vms.nix | 10 +- tests/lib/test-driver.py | 2 +- tests/tor.nix | 16 +- 34 files changed, 634 insertions(+), 618 deletions(-) diff --git a/flake.lock b/flake.lock index 78ab190..53a6f39 100644 --- a/flake.lock +++ b/flake.lock @@ -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" } diff --git a/flake.nix b/flake.nix index 222a17b..185d9a7 100644 --- a/flake.nix +++ b/flake.nix @@ -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 diff --git a/nixos-modules/gui/consoleLog.dhall b/nixos-modules/gui/consoleLog.dhall index 1bd1033..9f8c7d2 100644 --- a/nixos-modules/gui/consoleLog.dhall +++ b/nixos-modules/gui/consoleLog.dhall @@ -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" } ) ] diff --git a/nixos-modules/hardware/default.nix b/nixos-modules/hardware/default.nix index 6166f15..e492204 100644 --- a/nixos-modules/hardware/default.nix +++ b/nixos-modules/hardware/default.nix @@ -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 diff --git a/nixos-modules/hardware/framebuffer.nix b/nixos-modules/hardware/framebuffer.nix index d136dd5..207d547 100644 --- a/nixos-modules/hardware/framebuffer.nix +++ b/nixos-modules/hardware/framebuffer.nix @@ -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" diff --git a/nixos-modules/hardware/usb.nix b/nixos-modules/hardware/usb.nix index d60d1ab..51f9112 100644 --- a/nixos-modules/hardware/usb.nix +++ b/nixos-modules/hardware/usb.nix @@ -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; diff --git a/nixos-modules/lib/make-bootable-image.nix b/nixos-modules/lib/make-bootable-image.nix index 9436980..87c4419 100644 --- a/nixos-modules/lib/make-bootable-image.nix +++ b/nixos-modules/lib/make-bootable-image.nix @@ -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 <> $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 - # doesn’t 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 + # doesn’t 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 diff --git a/overlay/llvm-11/libc++/default.nix b/overlay/llvm-11/libc++/default.nix index 021c979..84dbd39 100644 --- a/overlay/llvm-11/libc++/default.nix +++ b/overlay/llvm-11/libc++/default.nix @@ -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; }; diff --git a/overlay/llvm-11/libc++abi.nix b/overlay/llvm-11/libc++abi.nix index b3a684f..59c7af4 100644 --- a/overlay/llvm-11/libc++abi.nix +++ b/overlay/llvm-11/libc++abi.nix @@ -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; diff --git a/overlay/llvm-11/lld.nix b/overlay/llvm-11/lld.nix index d199017..5547187 100644 --- a/overlay/llvm-11/lld.nix +++ b/overlay/llvm-11/lld.nix @@ -1,11 +1,4 @@ -{ lib -, stdenv -, fetch -, cmake -, libxml2 -, llvm -, version -}: +{ lib, stdenv, fetch, cmake, libxml2, llvm, version }: stdenv.mkDerivation rec { pname = "lld"; @@ -29,8 +22,8 @@ stdenv.mkDerivation rec { meta = { description = "The LLVM Linker"; - homepage = "https://lld.llvm.org/"; - license = lib.licenses.ncsa; - platforms = lib.platforms.all; + homepage = "https://lld.llvm.org/"; + license = lib.licenses.ncsa; + platforms = lib.platforms.all; }; } diff --git a/overlay/llvm-11/lldb.nix b/overlay/llvm-11/lldb.nix index 642e4b7..89d5a0a 100644 --- a/overlay/llvm-11/lldb.nix +++ b/overlay/llvm-11/lldb.nix @@ -1,20 +1,5 @@ -{ stdenv -, fetch -, cmake -, zlib -, ncurses -, swig -, which -, libedit -, libxml2 -, llvm -, clang-unwrapped -, python3 -, version -, darwin -, lit -, enableManpages ? false -}: +{ stdenv, fetch, cmake, zlib, ncurses, swig, which, libedit, libxml2, llvm +, clang-unwrapped, python3, version, darwin, lit, enableManpages ? false }: stdenv.mkDerivation (rec { pname = "lldb"; @@ -25,23 +10,20 @@ stdenv.mkDerivation (rec { patches = [ ./lldb-procfs.patch ]; nativeBuildInputs = [ cmake python3 which swig lit ] - ++ lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; + ++ lib.optionals enableManpages [ + python3.pkgs.sphinx + python3.pkgs.recommonmark + ]; - buildInputs = [ - ncurses - zlib - libedit - libxml2 - llvm - ] - ++ lib.optionals stdenv.isDarwin [ - darwin.libobjc - darwin.apple_sdk.libs.xpc - darwin.apple_sdk.frameworks.Foundation - darwin.bootstrap_cmds - darwin.apple_sdk.frameworks.Carbon - darwin.apple_sdk.frameworks.Cocoa - ]; + buildInputs = [ ncurses zlib libedit libxml2 llvm ] + ++ lib.optionals stdenv.isDarwin [ + darwin.libobjc + darwin.apple_sdk.libs.xpc + darwin.apple_sdk.frameworks.Foundation + darwin.bootstrap_cmds + darwin.apple_sdk.frameworks.Carbon + darwin.apple_sdk.frameworks.Cocoa + ]; hardeningDisable = [ "format" ]; @@ -49,15 +31,14 @@ stdenv.mkDerivation (rec { "-DLLVM_ENABLE_RTTI=OFF" "-DClang_DIR=${clang-unwrapped}/lib/cmake" "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" - ] ++ lib.optionals stdenv.isDarwin [ - "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" - ] ++ lib.optionals (!stdenv.isDarwin) [ - "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic - ] ++ lib.optionals enableManpages [ - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - ]; + ] ++ lib.optionals stdenv.isDarwin [ "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" ] + ++ lib.optionals (!stdenv.isDarwin) [ + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic + ] ++ lib.optionals enableManpages [ + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + ]; enableParallelBuilding = true; @@ -82,7 +63,7 @@ stdenv.mkDerivation (rec { make docs-lldb-man ''; - propagatedBuildInputs = []; + propagatedBuildInputs = [ ]; installPhase = '' # manually install lldb man page diff --git a/overlay/llvm-11/llvm.nix b/overlay/llvm-11/llvm.nix index 41597cf..e9b2d38 100644 --- a/overlay/llvm-11/llvm.nix +++ b/overlay/llvm-11/llvm.nix @@ -1,26 +1,10 @@ -{ lib -, stdenv -, fetch -, cmake -, python3 -, libffi -, libbfd -, libpfm -, libxml2 -, ncurses -, version -, release_version -, zlib -, buildPackages -, debugVersion ? false -, enableManpages ? false -, enableSharedLibraries ? true -, enablePFM ? !(stdenv.isDarwin - || stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245 - || stdenv.isAarch32 # broken for the armv7l builder -) -, enablePolly ? false -}: +{ lib, stdenv, fetch, cmake, python3, libffi, libbfd, libpfm, libxml2, ncurses +, version, release_version, zlib, buildPackages, debugVersion ? false +, enableManpages ? false, enableSharedLibraries ? true, enablePFM ? + !(stdenv.isDarwin + || stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245 + || stdenv.isAarch32 # broken for the armv7l builder + ), enablePolly ? false }: let inherit (lib) optional optionals optionalString; @@ -34,7 +18,8 @@ in stdenv.mkDerivation (rec { inherit version; src = fetch pname "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"; - polly_src = fetch "polly" "0h442ivcslr3dv3q3g1nw5avh77f8cxsp6zild1hgspj266xpynw"; + polly_src = + fetch "polly" "0h442ivcslr3dv3q3g1nw5avh77f8cxsp6zild1hgspj266xpynw"; unpackPhase = '' unpackFile $src @@ -45,14 +30,14 @@ in stdenv.mkDerivation (rec { mv polly-* $sourceRoot/tools/polly ''; - outputs = [ "out" "python" ] - ++ optional enableSharedLibraries "lib"; + outputs = [ "out" "python" ] ++ optional enableSharedLibraries "lib"; - nativeBuildInputs = [ cmake python3 ] - ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; + nativeBuildInputs = [ cmake python3 ] ++ optionals enableManpages [ + python3.pkgs.sphinx + python3.pkgs.recommonmark + ]; - buildInputs = [ libxml2 libffi ] - ++ optional enablePFM libpfm; # exegesis + buildInputs = [ libxml2 libffi ] ++ optional enablePFM libpfm; # exegesis propagatedBuildInputs = [ ncurses zlib ]; @@ -63,34 +48,34 @@ in stdenv.mkDerivation (rec { --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ --replace 'set(_install_rpath "@loader_path/../lib''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' "" '' - # Patch llvm-config to return correct library path based on --link-{shared,static}. - + optionalString (enableSharedLibraries) '' - substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib - patch -p1 < ./llvm-outputs.patch - '' + '' - # FileSystem permissions tests fail with various special bits - substituteInPlace unittests/Support/CMakeLists.txt \ - --replace "Path.cpp" "" - rm unittests/Support/Path.cpp - '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../TLI-musl.patch} - substituteInPlace unittests/Support/CMakeLists.txt \ - --replace "add_subdirectory(DynamicLibrary)" "" - rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp - # valgrind unhappy with musl or glibc, but fails w/musl only - rm test/CodeGen/AArch64/wineh4.mir - '' + optionalString stdenv.hostPlatform.isAarch32 '' - # skip failing X86 test cases on 32-bit ARM - rm test/DebugInfo/X86/convert-debugloc.ll - rm test/DebugInfo/X86/convert-inlined.ll - rm test/DebugInfo/X86/convert-linked.ll - rm test/tools/dsymutil/X86/op-convert.test - '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") '' - # Seems to require certain floating point hardware (NEON?) - rm test/ExecutionEngine/frem.ll - '' + '' - patchShebangs test/BugPoint/compile-custom.ll.py - ''; + # Patch llvm-config to return correct library path based on --link-{shared,static}. + + optionalString (enableSharedLibraries) '' + substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib + patch -p1 < ./llvm-outputs.patch + '' + '' + # FileSystem permissions tests fail with various special bits + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "Path.cpp" "" + rm unittests/Support/Path.cpp + '' + optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -i ${../TLI-musl.patch} + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "add_subdirectory(DynamicLibrary)" "" + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp + # valgrind unhappy with musl or glibc, but fails w/musl only + rm test/CodeGen/AArch64/wineh4.mir + '' + optionalString stdenv.hostPlatform.isAarch32 '' + # skip failing X86 test cases on 32-bit ARM + rm test/DebugInfo/X86/convert-debugloc.ll + rm test/DebugInfo/X86/convert-inlined.ll + rm test/DebugInfo/X86/convert-linked.ll + rm test/tools/dsymutil/X86/op-convert.test + '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") '' + # Seems to require certain floating point hardware (NEON?) + rm test/ExecutionEngine/frem.ll + '' + '' + patchShebangs test/BugPoint/compile-custom.ll.py + ''; # hacky fix: created binaries need to be run before installation preBuild = '' @@ -99,34 +84,35 @@ in stdenv.mkDerivation (rec { ''; # E.g. mesa.drivers use the build-id as a cache key (see #93946): - LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) + "-Wl,--build-id=sha1"; - cmakeFlags = with stdenv; [ - "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" - "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc - "-DLLVM_BUILD_TESTS=ON" - "-DLLVM_ENABLE_FFI=ON" - "-DLLVM_ENABLE_RTTI=ON" - "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" - "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" - "-DLLVM_ENABLE_DUMP=ON" - ] ++ optionals enableSharedLibraries [ - "-DLLVM_LINK_LLVM_DYLIB=ON" - ] ++ optionals enableManpages [ - "-DLLVM_BUILD_DOCS=ON" - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" - ] ++ optionals (!isDarwin) [ - "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" - ] ++ optionals isDarwin [ - "-DLLVM_ENABLE_LIBCXX=ON" - "-DCAN_TARGET_i386=false" - ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-DCMAKE_CROSSCOMPILING=True" - "-DLLVM_TABLEGEN=${buildPackages.llvm_10}/bin/llvm-tblgen" - ]; + cmakeFlags = with stdenv; + [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_ENABLE_DUMP=ON" + ] ++ optionals enableSharedLibraries [ "-DLLVM_LINK_LLVM_DYLIB=ON" ] + ++ optionals enableManpages [ + "-DLLVM_BUILD_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] + ++ optionals (!isDarwin) [ "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" ] + ++ optionals isDarwin [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${buildPackages.llvm_10}/bin/llvm-tblgen" + ]; postBuild = '' rm -fR $out @@ -139,17 +125,18 @@ in stdenv.mkDerivation (rec { postInstall = '' mkdir -p $python/share mv $out/share/opt-viewer $python/share/opt-viewer - '' - + optionalString enableSharedLibraries '' + '' + optionalString enableSharedLibraries '' moveToOutput "lib/libLLVM-*" "$lib" moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" - '' - + optionalString (enableSharedLibraries && (!stdenv.isDarwin)) '' - substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + '' + optionalString (enableSharedLibraries && (!stdenv.isDarwin)) '' + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${ + if debugVersion then "debug" else "release" + }.cmake" \ --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" - '' - + optionalString (stdenv.isDarwin && enableSharedLibraries) '' - substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + '' + optionalString (stdenv.isDarwin && enableSharedLibraries) '' + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${ + if debugVersion then "debug" else "release" + }.cmake" \ --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib @@ -163,11 +150,12 @@ in stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; meta = { - description = "Collection of modular and reusable compiler and toolchain technologies"; - homepage = "https://llvm.org/"; - license = lib.licenses.ncsa; + description = + "Collection of modular and reusable compiler and toolchain technologies"; + homepage = "https://llvm.org/"; + license = lib.licenses.ncsa; maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ]; - platforms = lib.platforms.all; + platforms = lib.platforms.all; }; } // lib.optionalAttrs enableManpages { pname = "llvm-manpages"; @@ -176,7 +164,7 @@ in stdenv.mkDerivation (rec { make docs-llvm-man ''; - propagatedBuildInputs = []; + propagatedBuildInputs = [ ]; installPhase = '' make -C docs install diff --git a/overlay/llvm-11/openmp.nix b/overlay/llvm-11/openmp.nix index 1ad5353..92e02a6 100644 --- a/overlay/llvm-11/openmp.nix +++ b/overlay/llvm-11/openmp.nix @@ -1,10 +1,4 @@ -{ stdenv -, fetch -, cmake -, llvm -, perl -, version -}: +{ stdenv, fetch, cmake, llvm, perl, version }: stdenv.mkDerivation rec { pname = "openmp"; @@ -19,8 +13,8 @@ stdenv.mkDerivation rec { meta = { description = "Components required to build an executable OpenMP program"; - homepage = "https://openmp.llvm.org/"; - license = lib.licenses.mit; - platforms = lib.platforms.all; + homepage = "https://openmp.llvm.org/"; + license = lib.licenses.mit; + platforms = lib.platforms.all; }; } diff --git a/overlay/tor/genode.patch b/overlay/tor/genode.patch index 9023a3e..c7597a4 100644 --- a/overlay/tor/genode.patch +++ b/overlay/tor/genode.patch @@ -1,7 +1,7 @@ -From b361fa6da5a5892ada665dcabfc6a0327419db63 Mon Sep 17 00:00:00 2001 +From 3ea8cfd1fb61baccd38118331adb0b8fe1e7c7a9 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 2 Dec 2020 19:27:10 +0100 -Subject: [PATCH] Skip user/group checks for Genode hosts +Subject: [PATCH 1/2] Skip user/group checks for Genode hosts --- src/app/main/main.c | 4 ++++ @@ -10,10 +10,10 @@ Subject: [PATCH] Skip user/group checks for Genode hosts 3 files changed, 18 insertions(+) diff --git a/src/app/main/main.c b/src/app/main/main.c -index e7ffb31b4f..a1a9037f09 100644 +index 589d365add..22b5cdf89a 100644 --- a/src/app/main/main.c +++ b/src/app/main/main.c -@@ -670,6 +670,10 @@ static tor_lockfile_t *lockfile = NULL; +@@ -669,6 +669,10 @@ static tor_lockfile_t *lockfile = NULL; int try_locking(const or_options_t *options, int err_if_locked) { @@ -68,5 +68,31 @@ index 3cfd520a4f..bf1857ad2a 100644 const struct passwd *pw = NULL; uid_t old_uid; -- -2.29.2 +2.31.0 + + +From 453339560166101a6db53bb701d30184019d3bd9 Mon Sep 17 00:00:00 2001 +From: Emery Hemingway +Date: Fri, 16 Apr 2021 15:17:43 +0200 +Subject: [PATCH 2/2] scripts/build/combine_libs: use $AR rather than ar + +--- + scripts/build/combine_libs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/build/combine_libs b/scripts/build/combine_libs +index fb311552fe..9c87f68248 100755 +--- a/scripts/build/combine_libs ++++ b/scripts/build/combine_libs +@@ -25,7 +25,7 @@ for input in "$@"; do + dir="$TMPDIR"/$(basename "$input" .a) + mkdir "$dir" + cd "$dir">/dev/null +- ar x "$abs" ++ "${AR:-ar}" x "$abs" + done + + cd "$TMPDIR" >/dev/null +-- +2.31.0 diff --git a/packages/device_manager/default.nix b/packages/device_manager/default.nix index bc1ce78..fdc129a 100644 --- a/packages/device_manager/default.nix +++ b/packages/device_manager/default.nix @@ -7,8 +7,8 @@ stdenv.mkDerivation rec { src = fetchgit { url = "https://git.sr.ht/~ehmry/${pname}"; - rev = "018ec1ccb109b275a54462d85eb006bc51ea04ac"; - sha256 = "1aiygypkjh2r397xwzpccav4mmkdhx7mc580javsm4cr3hhkhbvj"; + rev = "4ff7d47b83255a437d862d16b8424a3c05e3eab1"; + sha256 = "0bmcl693w34ayrw77c6gicph43yfjfm800jwj57ryshr9fdh88dq"; }; nimFlags = with nimblePackages; diff --git a/packages/genodelabs/default.nix b/packages/genodelabs/default.nix index 1003b66..85cecf4 100644 --- a/packages/genodelabs/default.nix +++ b/packages/genodelabs/default.nix @@ -125,7 +125,7 @@ let find $CONTRIB_DIR/* -name '*.zip' -exec rm -rf {} \; || true mkdir $out - cp -a $CONTRIB_DIR/* $out/ + cp -av $CONTRIB_DIR/* $out/ runHook postInstall ''; diff --git a/packages/genodelabs/depot-targets.nix b/packages/genodelabs/depot-targets.nix index 823a9ac..fd30cc6 100644 --- a/packages/genodelabs/depot-targets.nix +++ b/packages/genodelabs/depot-targets.nix @@ -168,7 +168,7 @@ in { pcre = { }; pcre16 = { }; pdf_view = { }; - platform_drv.patches = [ ./patches/platform_drv.patch ]; + platform_drv = { }; # .patches = [ ./patches/platform_drv.patch ]; posix.depotInputs = with self; [ libc ]; ps2_drv = { }; qt5_base = { }; @@ -292,7 +292,7 @@ in { usb_block_drv = { }; usb_drv = { portInputs = with ports; [ dde_linux ]; - meta.broken = builtins.trace "usb_drv is broken! Use usb_host_drv!" true; + meta.broken = builtins.trace "usb_drv is broken! Use usb_host_drv!" false; }; usb_hid_drv.portInputs = with ports; [ dde_linux ]; usb_host_drv = { diff --git a/packages/genodelabs/patches/platform_drv.patch b/packages/genodelabs/patches/platform_drv.patch index 5e29960..53e88f6 100644 --- a/packages/genodelabs/patches/platform_drv.patch +++ b/packages/genodelabs/patches/platform_drv.patch @@ -1,4 +1,4 @@ -From f747e139da4fda694363a27010cb6d62c3b1e941 Mon Sep 17 00:00:00 2001 +From c6104cfcfb7c810fabb0fb26ec8162466ef9541b Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 10 Nov 2020 12:51:12 +0100 Subject: [PATCH 1/2] drivers/platform/x86: move PCI capabilities to PCI report @@ -9,10 +9,10 @@ Subject: [PATCH 1/2] drivers/platform/x86: move PCI capabilities to PCI report 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h -index a7439a224d..54b4492983 100644 +index ecca81032b..395ec71f16 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h +++ b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h -@@ -1110,7 +1110,9 @@ class Platform::Root : public Genode::Root_component +@@ -1169,7 +1169,9 @@ class Platform::Root : public Genode::Root_component for (Genode::uint16_t val = 0; cap; cap = val >> 8) { val = config.read(config_access, cap, Platform::Device::ACCESS_16BIT); @@ -24,10 +24,10 @@ index a7439a224d..54b4492983 100644 } catch (...) { xml.attribute("cap", "failed to read"); -- -2.28.0 +2.31.0 -From 1a687e4b6d3544bf369a01aeb1d8bdffc27139b1 Mon Sep 17 00:00:00 2001 +From 1713de41fd6a3eecfc917f1f709b6bb7a043624b Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 10 Nov 2020 14:46:59 +0100 Subject: [PATCH 2/2] drivers/platform/x86: assign device by optional index @@ -39,9 +39,9 @@ attribute on nodes. An index is not valid if the Fix #3946 --- - repos/os/src/drivers/platform/spec/x86/README | 13 +++++++----- - .../platform/spec/x86/pci_session_component.h | 20 +++++++++++++++---- - 2 files changed, 24 insertions(+), 9 deletions(-) + repos/os/src/drivers/platform/spec/x86/README | 13 ++++++---- + .../platform/spec/x86/pci_session_component.h | 24 ++++++++++++++----- + 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/repos/os/src/drivers/platform/spec/x86/README b/repos/os/src/drivers/platform/spec/x86/README index 83649f3b33..1c605e93fd 100644 @@ -68,19 +68,19 @@ index 83649f3b33..1c605e93fd 100644 By default the driver will try to use MSIs if the device and the used kernel diff --git a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h -index 54b4492983..b321df6fcb 100644 +index 395ec71f16..670179d79c 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h +++ b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h -@@ -379,7 +379,7 @@ class Platform::Session_component : public Genode::Rpc_object +@@ -370,7 +370,7 @@ class Platform::Session_component : public Genode::Rpc_object /** * Check according session policy device usage */ -- bool permit_device(Bdf const bdf, unsigned class_code) +- bool permit_device(Pci::Bdf const bdf, unsigned const class_code) + bool permit_device(Bdf const bdf, unsigned class_code, unsigned &class_index) { using namespace Genode; -@@ -404,6 +404,16 @@ class Platform::Session_component : public Genode::Rpc_object +@@ -397,6 +397,16 @@ class Platform::Session_component : public Genode::Rpc_object if (class_sub_prog && (class_sub_prog ^ class_code) >> DONT_CHECK_PROGIF) return; @@ -97,7 +97,7 @@ index 54b4492983..b321df6fcb 100644 /* if this bdf is used by some policy - deny */ if (find_dev_in_policy(bdf)) return; -@@ -535,9 +545,9 @@ class Platform::Session_component : public Genode::Rpc_object +@@ -544,9 +554,9 @@ class Platform::Session_component : public Genode::Rpc_object throw Genode::Service_denied(); } @@ -109,7 +109,7 @@ index 54b4492983..b321df6fcb 100644 Genode::error("'", _label, "' - attributes beside 'class' detected"); throw Genode::Service_denied(); } -@@ -663,6 +673,7 @@ class Platform::Session_component : public Genode::Rpc_object +@@ -702,6 +712,7 @@ class Platform::Session_component : public Genode::Rpc_object */ Device_config config; @@ -117,16 +117,20 @@ index 54b4492983..b321df6fcb 100644 while (true) { function += 1; if (!_pci_bus.find_next(bus, device, function, &config, -@@ -682,7 +693,8 @@ class Platform::Session_component : public Genode::Rpc_object - if (permit_device(Bdf { (unsigned)bus, - (unsigned)device, - (unsigned)function }, +@@ -719,9 +730,10 @@ class Platform::Session_component : public Genode::Rpc_object + + /* check that policy permit access to the matched device */ + if (permit_device(Pci::Bdf { (unsigned)bus, +- (unsigned)device, +- (unsigned)function }, - config.class_code())) ++ (unsigned)device, ++ (unsigned)function }, + config.class_code(), + class_index)) break; } -- -2.28.0 +2.31.0 diff --git a/packages/genodelabs/ports.nix b/packages/genodelabs/ports.nix index 15a6afa..8cf0964 100644 --- a/packages/genodelabs/ports.nix +++ b/packages/genodelabs/ports.nix @@ -13,8 +13,8 @@ with pkgs; coreutils.hash = "sha256-ZVlFfLghHcXxwwRsN5xw2bVdIvvXoCNj2oZniOlSXrg="; curl.hash = "sha256-5+nRKLrho9oO0XlzDO6ppZ2kLfWaIReY24YFYSQT7Xc="; dde_bsd.hash = "sha256-KPA/ua3jETcHgWzhfhFm6ppds55Xi5YXJKDJvufJmU8="; - dde_ipxe.hash = "sha256-NJ129+DkxFg1fFHJBABBFRRjqEVNSz6v2hEB80AuEM4="; - dde_linux.hash = "sha256-xHAgeKfArgMGKCGHi0762qkUcY97vbiAQYjM/ZRXCes="; + dde_ipxe.hash = "sha256-rnMbramSDYBEjfSMoNpFcUQ4jfJh6SIHMtieSy9/Fe4="; + dde_linux.hash = "sha256-PBj/pTbCTZVtqqppnQyFtwH3G5qrQABBKxK19uVuT8U="; dde_rump = { hash = "sha256-Wr5otGkWEa+5xImsFHQzwap5LckNEbyWA/7xbNcOreI="; nativeBuildInputs = [ subversion ]; diff --git a/tests/bash.dhall b/tests/bash.dhall index 156af1e..320d10e 100644 --- a/tests/bash.dhall +++ b/tests/bash.dhall @@ -12,7 +12,14 @@ let Init = Sigil.Init let Child = Init.Child -in λ(params : { bash : Text, coreutils : Text }) → +in λ ( params + : { bash : Text + , coreutils : Text + , cached_fs_rom : Text + , vfs : Text + , vfs_pipe : Text + } + ) → λ(binary : Text) → let init = Init::{ @@ -25,24 +32,30 @@ in λ(params : { bash : Text, coreutils : Text }) → { vfs = Child.flat Child.Attributes::{ - , binary = "vfs" + , binary = params.vfs , provides = [ "File_system" ] , resources = Sigil.Init.Resources::{ , caps = 256 , ram = Sigil.units.MiB 8 } , routes = - Prelude.List.map - Text - Init.ServiceRoute.Type - Init.ServiceRoute.parent - [ "File_system", "Rtc" ] + [ Init.ServiceRoute.parent "ROM" ] + # Prelude.List.map + Text + Init.ServiceRoute.Type + Init.ServiceRoute.parent + [ "File_system", "Rtc" ] , config = Init.Config::{ , content = [ VFS.vfs [ VFS.dir "dev" - [ VFS.dir "pipes" [ VFS.leaf "pipe" ] + [ VFS.dir + "pipes" + [ VFS.leafAttrs + "plugin" + (toMap { load = params.vfs_pipe }) + ] , VFS.leaf "log" , VFS.leaf "null" , VFS.leaf "rtc" @@ -78,11 +91,13 @@ in λ(params : { bash : Text, coreutils : Text }) → , label = Init.LabelSelector.prefix "shell" , attributes = toMap { root = "/", writeable = "yes" } + , diag = Some True } , Init.Config.Policy::{ , service = "File_system" , label = Init.LabelSelector.prefix "vfs_rom" , attributes = toMap { root = "/" } + , diag = Some True } ] } @@ -90,7 +105,7 @@ in λ(params : { bash : Text, coreutils : Text }) → , vfs_rom = Child.flat Child.Attributes::{ - , binary = "cached_fs_rom" + , binary = params.cached_fs_rom , provides = [ "ROM" ] , resources = Init.Resources::{ , caps = 256 @@ -101,6 +116,12 @@ in λ(params : { bash : Text, coreutils : Text }) → [ Init.Config.Policy::{ , service = "ROM" , label = Init.LabelSelector.prefix "shell" + , diag = Some True + } + , Init.Config.Policy::{ + , service = "ROM" + , label = Init.LabelSelector.prefix "/nix/store/" + , diag = Some True } ] } @@ -114,21 +135,6 @@ in λ(params : { bash : Text, coreutils : Text }) → , caps = 256 , ram = Sigil.units.MiB 8 } - , routes = - Prelude.List.map - Text - Init.ServiceRoute.Type - ( λ(label : Text) → - Init.ServiceRoute.parentLabel - "ROM" - (Some label) - (Some label) - ) - [ "libc.lib.so" - , "libm.lib.so" - , "posix.lib.so" - , "vfs.lib.so" - ] , config = ( Libc.toConfig Libc::{ @@ -144,6 +150,14 @@ in λ(params : { bash : Text, coreutils : Text }) → } ) with attributes = toMap { ld_verbose = "true" } + , routes = + [ { service = + { name = "ROM" + , label = Init.LabelSelector.prefix "urn:erisx2:" + } + , route = Init.Route.parent (None Text) + } + ] } } } diff --git a/tests/bash.nix b/tests/bash.nix index ebccc7c..d1959c3 100644 --- a/tests/bash.nix +++ b/tests/bash.nix @@ -1,21 +1,27 @@ { name = "bash"; - machine = { pkgs, ... }: { - genode.init.children.bash = { + machine = { config, lib, modulesPath, pkgs, ... }: { + genode.init.children.bash = let + extraErisInputs' = with pkgs.genodePackages; { + bash = lib.getEris "bin" pkgs.bash; + cached_fs_rom = lib.getEris "bin" cached_fs_rom; + vfs = lib.getEris "bin" vfs; + vfs_pipe = lib.getEris "lib" vfs_pipe; + }; + params = { + bash = "${pkgs.bash}"; + coreutils = "${pkgs.coreutils}"; + cached_fs_rom = extraErisInputs'.cached_fs_rom.cap; + vfs = extraErisInputs'.vfs.cap; + vfs_pipe = extraErisInputs'.vfs_pipe.cap; + }; + in { package = pkgs.genodePackages.init; + extraErisInputs = builtins.attrValues extraErisInputs'; configFile = pkgs.writeText "bash.child.dhall" '' - ${ - ./bash.dhall - } { bash = "${pkgs.bash}", coreutils = "${pkgs.coreutils}" } + ${./bash.dhall} ${lib.generators.toDhall params} ''; - extraInputs = with pkgs.genodePackages; [ - pkgs.bash - cached_fs_rom - libc - posix - vfs - vfs_pipe - ]; + extraInputs = with pkgs.genodePackages; [ pkgs.bash libc posix ]; }; }; testScript = '' diff --git a/tests/default.nix b/tests/default.nix index e92ca2f..c4c7e6c 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -16,9 +16,11 @@ let test = map (p: import p) [ ./ahci.nix ./bash.nix + ./graphics.nix ./hello.nix ./log.nix ./nim.nix + ./tor.nix ./usb.nix ./vmm_x86.nix ]; diff --git a/tests/graphics.nix b/tests/graphics.nix index bdeed69..2b58c8e 100644 --- a/tests/graphics.nix +++ b/tests/graphics.nix @@ -4,13 +4,7 @@ genode.gui.consoleLog.enable = true; - genode.core.storeBackend = "fs"; - hardware.genode.framebuffer.driver = "boot"; - hardware.genode.usb = { - enable = true; - biosHandoff = false; - storage.enable = true; - }; + hardware.genode.framebuffer.driver = "vesa"; genode.init.verbose = true; genode.init.children.hello = { diff --git a/tests/hello.dhall b/tests/hello.dhall index 66a9287..9dd3d8f 100644 --- a/tests/hello.dhall +++ b/tests/hello.dhall @@ -12,7 +12,6 @@ in λ(binary : Text) → Child.flat Child.Attributes::{ , binary - , exitPropagate = True , resources = Sigil.Init.Resources::{ , caps = 500 , ram = Sigil.units.MiB 10 diff --git a/tests/lib/build-vms.nix b/tests/lib/build-vms.nix index b736aa4..fdcf22a 100644 --- a/tests/lib/build-vms.nix +++ b/tests/lib/build-vms.nix @@ -35,10 +35,6 @@ rec { ../../nixos-modules/hardware ../../nixos-modules/qemu-vm.nix ../../nixos-modules/services - { - key = "no-manual"; - documentation.nixos.enable = false; - } { key = "qemu"; system.build.qemu = qemu; @@ -77,16 +73,14 @@ rec { address = "192.168.${toString fst}.${toString m.snd}"; prefixLength = 24; }]; - genode.driver = "virtio"; + # genode.driver = "virtio"; }); in { key = "ip-address"; config = { networking.hostName = mkDefault m.fst; - networking.interfaces = { - eth0.genode.driver = "virtio"; - } // listToAttrs interfaces; + networking.interfaces = listToAttrs interfaces; networking.primaryIPAddress = optionalString (interfaces != [ ]) (head (head interfaces).value.ipv4.addresses).address; diff --git a/tests/lib/test-driver.py b/tests/lib/test-driver.py index bcb9564..2848ba9 100644 --- a/tests/lib/test-driver.py +++ b/tests/lib/test-driver.py @@ -280,7 +280,7 @@ class Machine: if "usb" in args: start_command += ( - "-device piix3-usb-uhci -drive " + "-device piix3-usb-ehci -drive " + "id=usbdisk,file=" + args["usb"] + ",if=none,readonly " diff --git a/tests/tor.nix b/tests/tor.nix index 9b1a3d3..dcf25b9 100644 --- a/tests/tor.nix +++ b/tests/tor.nix @@ -2,26 +2,28 @@ name = "tor"; machine = { config, lib, pkgs, ... }: { - virtualisation.memorySize = 768; + documentation.nixos = { + enable = true; + includeAllModules = true; + }; + + environment.defaultPackages = { }; - genode.gui.consoleLog.enable = true; genode.core.storeBackend = "fs"; - hardware.genode.usb.enable = true; hardware.genode.usb.storage.enable = true; services.tor = { enable = true; client.enable = false; - extraConfig = '' - Log [general,net,config,fs]debug stdout - ''; + extraConfig = "Log [general,net,config,fs]debug stdout"; relay = { enable = true; - port = 80; role = "relay"; bridgeTransports = [ ]; }; }; + virtualisation.memorySize = 768; + }; }