From fb3df59c6b00577a98bc6f0721c8a27d2f450759 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 19 Apr 2019 11:15:40 -0400 Subject: [PATCH 1/9] aws-c-common: add libexecinfo on musl Fixes #56106 --- pkgs/development/libraries/aws-c-common/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/aws-c-common/default.nix b/pkgs/development/libraries/aws-c-common/default.nix index 682a74593fdc..5404c0a1fdfc 100644 --- a/pkgs/development/libraries/aws-c-common/default.nix +++ b/pkgs/development/libraries/aws-c-common/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, cmake }: +{ lib, stdenv, fetchFromGitHub, cmake, libexecinfo }: stdenv.mkDerivation rec { pname = "aws-c-common"; @@ -13,6 +13,8 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; + buildInputs = lib.optional stdenv.hostPlatform.isMusl libexecinfo; + NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [ "-Wno-nullability-extension" "-Wno-typedef-redefinition" From 65f2b0a2a32bb0d84f55ca7bb8c9a33e8ba28713 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 19 Apr 2019 11:55:38 -0400 Subject: [PATCH 2/9] spidermonkey: fix host, target settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit spidermonkey doesn’t use the autotools build, host, target convention. Instead it considers ‘--host’ to be the autotools’ ‘--build’ and ‘--target’ to be the autotools’ ‘--host’! As a result, we cannot safely use “configurePlatforms”. Instead, we must manually set these flags. /cc @illegalprime --- pkgs/development/interpreters/spidermonkey/52.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/interpreters/spidermonkey/52.nix b/pkgs/development/interpreters/spidermonkey/52.nix index 1d7a11df5a41..feac99b2d8e5 100644 --- a/pkgs/development/interpreters/spidermonkey/52.nix +++ b/pkgs/development/interpreters/spidermonkey/52.nix @@ -31,7 +31,7 @@ in stdenv.mkDerivation rec { }) ]; - configurePlatforms = [ "host" "target" ]; + configurePlatforms = [ ]; preConfigure = '' export CXXFLAGS="-fpermissive" @@ -51,7 +51,11 @@ in stdenv.mkDerivation rec { "--with-intl-api" "--enable-readline" "--enable-shared-js" - ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-jemalloc"; + ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-jemalloc" + ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "--host=${stdenv.buildPlatform.config}" + "--target=${stdenv.hostPlatform.config}" + ]; makeFlags = [ "HOST_CC=${buildPackages.stdenv.cc}/bin/cc" From 59bb1dcbfb81fee9b727200ffc064cc6b2f05d59 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 10 Apr 2019 17:16:48 -0400 Subject: [PATCH 3/9] systems/parse.nix: fixup arm compatibilities --- lib/systems/parse.nix | 46 +++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index 8cc7d3ae271f..3e23a721f0d9 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -127,22 +127,42 @@ rec { (b == i386 && isCompatible a i486) (b == i486 && isCompatible a i586) (b == i586 && isCompatible a i686) - # NOTE: Not true in some cases. Like in WSL mode. + + # XXX: Not true in some cases. Like in WSL mode. (b == i686 && isCompatible a x86_64) - # ARM + # ARMv4 (b == arm && isCompatible a armv5tel) - (b == armv5tel && isCompatible a armv6m) - (b == armv6m && isCompatible a armv6l) - (b == armv6l && isCompatible a armv7a) - (b == armv7a && isCompatible a armv7r) - (b == armv7r && isCompatible a armv7m) - (b == armv7m && isCompatible a armv7l) - (b == armv7l && isCompatible a armv8a) - (b == armv8a && isCompatible a armv8r) - (b == armv8r && isCompatible a armv8m) - # NOTE: not always true! Some arm64 cpus don’t support arm32 mode. - (b == armv8m && isCompatible a aarch64) + + # ARMv5 + (b == armv5tel && isCompatible a armv6l) + + # ARMv6 + (b == armv6l && isCompatible a armv6m) + (b == armv6m && isCompatible a armv7l) + + # ARMv7 + (b == armv7l && isCompatible a armv7a) + (b == armv7l && isCompatible a armv7r) + (b == armv7l && isCompatible a armv7m) + (b == armv7a && isCompatible a armv8a) + (b == armv7r && isCompatible a armv8a) + (b == armv7m && isCompatible a armv8a) + (b == armv7a && isCompatible a armv8r) + (b == armv7r && isCompatible a armv8r) + (b == armv7m && isCompatible a armv8r) + (b == armv7a && isCompatible a armv8m) + (b == armv7r && isCompatible a armv8m) + (b == armv7m && isCompatible a armv8m) + + # ARMv8 + (b == armv8r && isCompatible a armv8a) + (b == armv8m && isCompatible a armv8a) + + # XXX: not always true! Some arm64 cpus don’t support arm32 mode. + (b == aarch64 && a == armv8a) + (b == armv8a && isCompatible a aarch64) + (b == aarch64 && a == aarch64_be) (b == aarch64_be && isCompatible a aarch64) From dd584d8eeb8c76d82cbac50ace0f7a08586a31e9 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 10 Apr 2019 18:38:20 -0400 Subject: [PATCH 4/9] stdenv/linux: use isCompatible to find bootstrap tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids part of the issue where things like armv7a don’t work because the system doesn’t realize it can use the armv7l bootstrap tools. --- pkgs/stdenv/default.nix | 6 ++++++ pkgs/stdenv/linux/default.nix | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 4313a617f784..1f752f021524 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -43,8 +43,14 @@ in "x86_64-linux" = stagesLinux; "armv5tel-linux" = stagesLinux; "armv6l-linux" = stagesLinux; + "armv6m-linux" = stagesLinux; "armv7a-linux" = stagesLinux; "armv7l-linux" = stagesLinux; + "armv7r-linux" = stagesLinux; + "armv7m-linux" = stagesLinux; + "armv8a-linux" = stagesLinux; + "armv8r-linux" = stagesLinux; + "armv8m-linux" = stagesLinux; "aarch64-linux" = stagesLinux; "mipsel-linux" = stagesLinux; "powerpc-linux" = /* stagesLinux */ stagesNative; diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 457e1671e260..2bccd620436a 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -13,7 +13,6 @@ "x86_64-linux" = import ./bootstrap-files/x86_64.nix; "armv5tel-linux" = import ./bootstrap-files/armv5tel.nix; "armv6l-linux" = import ./bootstrap-files/armv6l.nix; - "armv7a-linux" = import ./bootstrap-files/armv7l.nix; "armv7l-linux" = import ./bootstrap-files/armv7l.nix; "aarch64-linux" = import ./bootstrap-files/aarch64.nix; "mipsel-linux" = import ./bootstrap-files/loongson2f.nix; @@ -26,10 +25,19 @@ "powerpc64le-linux" = import ./bootstrap-files/ppc64le-musl.nix; }; }; + + # Try to find an architecture compatible with our current system. We + # just try every bootstrap we’ve got and test to see if it is + # compatible with or current architecture. + getCompatibleTools = lib.foldl (v: system: + if v != null then v + else if localSystem.isCompatible (lib.systems.elaborate { inherit system; }) then archLookupTable.${system} + else null) null (lib.attrNames archLookupTable); + archLookupTable = table.${localSystem.libc} or (abort "unsupported libc for the pure Linux stdenv"); - files = archLookupTable.${localSystem.system} - or (abort "unsupported platform for the pure Linux stdenv"); + files = archLookupTable.${localSystem.system} or (if getCompatibleTools != null then getCompatibleTools + else (abort "unsupported platform for the pure Linux stdenv")); in files }: From 23560ea057024811dfeea8be0b7bd9b7a3d63b31 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 17 Apr 2019 16:41:33 -0400 Subject: [PATCH 5/9] systems: fix emulator identity Squashed to fix shell quoting, thanks @Ericson2314 --- lib/systems/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 52b9bd46e600..dd4f85c17cb4 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -103,7 +103,7 @@ rec { in if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name && pkgs.stdenv.hostPlatform.isCompatible final - then "${pkgs.runtimeShell} -c" + then "${pkgs.runtimeShell} -c '\"$@\"' --" else if final.isWindows then "${wine}/bin/${wine-name}" else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux From 5eea6587786edc63f9442f9c32703e62ba1729bb Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 17 Apr 2019 13:09:34 -0400 Subject: [PATCH 6/9] systems: correct qemu architectures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ppc64le and ppc64 are different targets in the configure script. We can’t use the same one. TODO: canonicalize similar ones based on qemu’s configure script. --- lib/systems/default.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index dd4f85c17cb4..8eeab67f7f33 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -78,10 +78,9 @@ rec { else if final.isx86 then "i386" else { "powerpc" = "ppc"; + "powerpcle" = "ppc"; "powerpc64" = "ppc64"; - "powerpc64le" = "ppc64"; - "mips64" = "mips"; - "mipsel64" = "mipsel"; + "powerpc64le" = "ppc64le"; }.${final.parsed.cpu.name} or final.parsed.cpu.name; emulator = pkgs: let From 97a3c7f5a3a1d4dfd91dcf96664bc11a376bfd96 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 2 Mar 2019 16:41:26 -0500 Subject: [PATCH 7/9] top-level/impure.nix: expose crossOverlays --- pkgs/top-level/impure.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix index b0532ceb5db4..da288f15d2e2 100644 --- a/pkgs/top-level/impure.nix +++ b/pkgs/top-level/impure.nix @@ -72,6 +72,8 @@ in else overlays homeOverlaysDir else [] +, crossOverlays ? [] + , ... } @ args: @@ -80,7 +82,7 @@ in assert args ? localSystem -> !(args ? system || args ? platform); import ./. (builtins.removeAttrs args [ "system" "platform" ] // { - inherit config overlays crossSystem; + inherit config overlays crossSystem crossOverlays; # Fallback: Assume we are building packages on the current (build, in GNU # Autotools parlance) system. localSystem = (if args ? localSystem then {} From d8934feba1399d220550b81dceeb6da35149cf02 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 19 Apr 2019 14:51:25 -0400 Subject: [PATCH 8/9] kernel-headers: infer ARCH from config triple This makes us less reliant on the systems/examples.nix. You should be able to cross compile with just your triple: $ nix build --arg crossSystem '{ config = "armv6l-unknown-linux-gnueabi"; }' stdenv --- lib/systems/default.nix | 7 +++++++ pkgs/os-specific/linux/kernel-headers/default.nix | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 8eeab67f7f33..b45a5fd8d2ba 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -72,6 +72,13 @@ rec { release = null; }; + kernelArch = + if final.isAarch32 then "arm" + else if final.isAarch64 then "arm64" + else if final.isx86_32 then "x86" + else if final.isx86_64 then "ia64" + else final.parsed.cpu.name; + qemuArch = if final.isArm then "arm" else if final.isx86_64 then "x86_64" diff --git a/pkgs/os-specific/linux/kernel-headers/default.nix b/pkgs/os-specific/linux/kernel-headers/default.nix index c00fc1761d59..ea4e041d43a0 100644 --- a/pkgs/os-specific/linux/kernel-headers/default.nix +++ b/pkgs/os-specific/linux/kernel-headers/default.nix @@ -12,7 +12,7 @@ let inherit sha256; }; - ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or (throw "missing kernelArch"); + ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or stdenvNoCC.hostPlatform.kernelArch; # It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc. # We do this so we have a build->build, not build->host, C compiler. From 4224b034cc9cf415517f5779c7a6fc5fda2ff635 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 20 Apr 2019 16:39:12 -0400 Subject: [PATCH 9/9] systemd: use lib.getBin for utillinux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit it’s almost always a better idea to use getBin instead of .bin. Otherwise, we could get an evaluation error if utillinux is missing the bin otuput. --- pkgs/os-specific/linux/systemd/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index d54972c055be..bc071d21ce43 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -129,12 +129,12 @@ in stdenv.mkDerivation rec { test -e $i substituteInPlace $i \ --replace /usr/bin/getent ${getent}/bin/getent \ - --replace /sbin/swapon ${utillinux.bin}/sbin/swapon \ - --replace /sbin/swapoff ${utillinux.bin}/sbin/swapoff \ - --replace /sbin/fsck ${utillinux.bin}/sbin/fsck \ + --replace /sbin/swapon ${lib.getBin utillinux}/sbin/swapon \ + --replace /sbin/swapoff ${lib.getBin utillinux}/sbin/swapoff \ + --replace /sbin/fsck ${lib.getBin utillinux}/sbin/fsck \ --replace /bin/echo ${coreutils}/bin/echo \ --replace /bin/cat ${coreutils}/bin/cat \ - --replace /sbin/sulogin ${utillinux.bin}/sbin/sulogin \ + --replace /sbin/sulogin ${lib.getBin utillinux}/sbin/sulogin \ --replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck \ --replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency done