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.
This commit is contained in:
parent
fe836f3564
commit
acb063701a
3 changed files with 7 additions and 5 deletions
|
@ -34,8 +34,10 @@ rec {
|
||||||
# Either of these can be losslessly-extracted from `parsed` iff parsing succeeds.
|
# Either of these can be losslessly-extracted from `parsed` iff parsing succeeds.
|
||||||
system = parse.doubleFromSystem final.parsed;
|
system = parse.doubleFromSystem final.parsed;
|
||||||
config = parse.tripleFromSystem final.parsed;
|
config = parse.tripleFromSystem final.parsed;
|
||||||
# Determine whether we are compatible with the provided CPU
|
# Determine whether we can execute binaries built for the provided platform.
|
||||||
isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu;
|
canExecute = platform:
|
||||||
|
parse.isCompatible final.parsed.cpu platform.parsed.cpu
|
||||||
|
&& final.parsed.kernel == platform.parsed.kernel;
|
||||||
# Derived meta-data
|
# Derived meta-data
|
||||||
libc =
|
libc =
|
||||||
/**/ if final.isDarwin then "libSystem"
|
/**/ if final.isDarwin then "libSystem"
|
||||||
|
|
|
@ -17,9 +17,9 @@ stdenv.mkDerivation rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ]
|
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.
|
# Upstream 77ac9154440bcc216fda1092fd5bb51da62ae09c, modified to apply to v0.9.1. Drop on update.
|
||||||
patches = lib.optional stdenv.hostPlatform.isMusl ./musl-no-fibers.patch;
|
patches = lib.optional stdenv.hostPlatform.isMusl ./musl-no-fibers.patch;
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
# compatible with or current architecture.
|
# compatible with or current architecture.
|
||||||
getCompatibleTools = lib.foldl (v: system:
|
getCompatibleTools = lib.foldl (v: system:
|
||||||
if v != null then v
|
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);
|
else null) null (lib.attrNames archLookupTable);
|
||||||
|
|
||||||
archLookupTable = table.${localSystem.libc}
|
archLookupTable = table.${localSystem.libc}
|
||||||
|
|
Loading…
Reference in a new issue