From acb063701a6a209a514bbdefacc9bce22332ef60 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Tue, 26 Apr 2022 22:17:48 +0200 Subject: [PATCH] lib.systems.elaborate: expose canExecute predicate over isCompatible canExecute is like isCompatible, but also checks that the Kernels are _equal_, i.e. that both platforms use the same syscall interface. This is crucial in order to actually be able to execute binaries for the other platform. isCompatible is dropped, since it has changed semantically and there's no use case left in nixpkgs. --- lib/systems/default.nix | 6 ++++-- pkgs/development/libraries/capnproto/default.nix | 4 ++-- pkgs/stdenv/linux/default.nix | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index e02890b11386..74f84914faab 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -34,8 +34,10 @@ rec { # Either of these can be losslessly-extracted from `parsed` iff parsing succeeds. system = parse.doubleFromSystem final.parsed; config = parse.tripleFromSystem final.parsed; - # Determine whether we are compatible with the provided CPU - isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu; + # Determine whether we can execute binaries built for the provided platform. + canExecute = platform: + parse.isCompatible final.parsed.cpu platform.parsed.cpu + && final.parsed.kernel == platform.parsed.kernel; # Derived meta-data libc = /**/ if final.isDarwin then "libSystem" diff --git a/pkgs/development/libraries/capnproto/default.nix b/pkgs/development/libraries/capnproto/default.nix index 75b5f14d67ce..aeb9728af826 100644 --- a/pkgs/development/libraries/capnproto/default.nix +++ b/pkgs/development/libraries/capnproto/default.nix @@ -17,9 +17,9 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ cmake ] - ++ lib.optional (!(stdenv.hostPlatform.isCompatible stdenv.buildPlatform)) capnproto; + ++ lib.optional (!(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) capnproto; - cmakeFlags = lib.optional (!(stdenv.hostPlatform.isCompatible stdenv.buildPlatform)) "-DEXTERNAL_CAPNP"; + cmakeFlags = lib.optional (!(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) "-DEXTERNAL_CAPNP"; # Upstream 77ac9154440bcc216fda1092fd5bb51da62ae09c, modified to apply to v0.9.1. Drop on update. patches = lib.optional stdenv.hostPlatform.isMusl ./musl-no-fibers.patch; diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 5c5ca64b1e95..ace0d704b721 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -31,7 +31,7 @@ # 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 if localSystem.canExecute (lib.systems.elaborate { inherit system; }) then archLookupTable.${system} else null) null (lib.attrNames archLookupTable); archLookupTable = table.${localSystem.libc}