Merge pull request #140271 from sternenseemann/executable-cross
stdenv.mkDerivation: be less strict about check execution for cross
This commit is contained in:
commit
392b95da61
|
@ -34,8 +34,11 @@ 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;
|
||||||
|
isCompatible = _: throw "2022-05-23: isCompatible has been removed in favor of canExecute, refer to the 22.11 changelog for details";
|
||||||
# Derived meta-data
|
# Derived meta-data
|
||||||
libc =
|
libc =
|
||||||
/**/ if final.isDarwin then "libSystem"
|
/**/ if final.isDarwin then "libSystem"
|
||||||
|
|
|
@ -148,8 +148,10 @@ rec {
|
||||||
# Every CPU is compatible with itself.
|
# Every CPU is compatible with itself.
|
||||||
# - (transitivity)
|
# - (transitivity)
|
||||||
# If A is compatible with B and B is compatible with C then A is compatible with C.
|
# If A is compatible with B and B is compatible with C then A is compatible with C.
|
||||||
# - (compatible under multiple endianness)
|
#
|
||||||
# CPUs with multiple modes of endianness are pairwise compatible.
|
# Note: Since 22.11 the archs of a mode switching CPU are no longer considered
|
||||||
|
# pairwise compatible. Mode switching implies that binaries built for A
|
||||||
|
# and B respectively can't be executed at the same time.
|
||||||
isCompatible = a: b: with cpuTypes; lib.any lib.id [
|
isCompatible = a: b: with cpuTypes; lib.any lib.id [
|
||||||
# x86
|
# x86
|
||||||
(b == i386 && isCompatible a i486)
|
(b == i386 && isCompatible a i486)
|
||||||
|
@ -191,22 +193,13 @@ rec {
|
||||||
(b == aarch64 && a == armv8a)
|
(b == aarch64 && a == armv8a)
|
||||||
(b == armv8a && isCompatible a aarch64)
|
(b == armv8a && isCompatible a aarch64)
|
||||||
|
|
||||||
(b == aarch64 && a == aarch64_be)
|
|
||||||
(b == aarch64_be && isCompatible a aarch64)
|
|
||||||
|
|
||||||
# PowerPC
|
# PowerPC
|
||||||
(b == powerpc && isCompatible a powerpc64)
|
(b == powerpc && isCompatible a powerpc64)
|
||||||
(b == powerpcle && isCompatible a powerpc)
|
(b == powerpcle && isCompatible a powerpc64le)
|
||||||
(b == powerpc && a == powerpcle)
|
|
||||||
(b == powerpc64le && isCompatible a powerpc64)
|
|
||||||
(b == powerpc64 && a == powerpc64le)
|
|
||||||
|
|
||||||
# MIPS
|
# MIPS
|
||||||
(b == mips && isCompatible a mips64)
|
(b == mips && isCompatible a mips64)
|
||||||
(b == mips && a == mipsel)
|
(b == mipsel && isCompatible a mips64el)
|
||||||
(b == mipsel && isCompatible a mips)
|
|
||||||
(b == mips64 && a == mips64el)
|
|
||||||
(b == mips64el && isCompatible a mips64)
|
|
||||||
|
|
||||||
# RISCV
|
# RISCV
|
||||||
(b == riscv32 && isCompatible a riscv64)
|
(b == riscv32 && isCompatible a riscv64)
|
||||||
|
|
|
@ -13,8 +13,22 @@
|
||||||
<itemizedlist spacing="compact">
|
<itemizedlist spacing="compact">
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Please remove this line when you add the first item since
|
During cross-compilation, tests are now executed if the test
|
||||||
docbook requires the section to be non-empty
|
suite can be executed by the build platform. This is the case
|
||||||
|
when doing “native” cross-compilation where the build and host
|
||||||
|
platforms are largely the same, but the nixpkgs’ cross
|
||||||
|
compilation infrastructure is used, e.g.
|
||||||
|
<literal>pkgsStatic</literal> and <literal>pkgsLLVM</literal>.
|
||||||
|
Another possibility is that the build platform is a superset
|
||||||
|
of the host platform, e.g. when cross-compiling from
|
||||||
|
<literal>x86_64-unknown-linux</literal> to
|
||||||
|
<literal>i686-unknown-linux</literal>. The predicate gating
|
||||||
|
test suite execution is the newly added
|
||||||
|
<literal>canExecute</literal> predicate: You can e.g. check if
|
||||||
|
<literal>stdenv.buildPlatform</literal> can execute binaries
|
||||||
|
built for <literal>stdenv.hostPlatform</literal> (i.e.
|
||||||
|
produced by <literal>stdenv.cc</literal>) by evaluating
|
||||||
|
<literal>stdenv.buildPlatform.canExecute stdenv.hostPlatform</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
@ -35,8 +49,19 @@
|
||||||
<itemizedlist spacing="compact">
|
<itemizedlist spacing="compact">
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Please remove this line when you add the first item since
|
The <literal>isCompatible</literal> predicate checking CPU
|
||||||
docbook requires the section to be non-empty
|
compatibility is no longer exposed by the platform sets
|
||||||
|
generated using <literal>lib.systems.elaborate</literal>. In
|
||||||
|
most cases you will want to use the new
|
||||||
|
<literal>canExecute</literal> predicate instead which also
|
||||||
|
considers the kernel / syscall interface. It is briefly
|
||||||
|
described in the release’s
|
||||||
|
<link linkend="sec-release-22.11-highlights">highlights
|
||||||
|
section</link>.
|
||||||
|
<literal>lib.systems.parse.isCompatible</literal> still
|
||||||
|
exists, but has changed semantically: Architectures with
|
||||||
|
differing endianness modes are <emphasis>no longer considered
|
||||||
|
compatible</emphasis>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
|
@ -6,7 +6,16 @@ Support is planned until the end of June 2023, handing over to 23.05.
|
||||||
|
|
||||||
In addition to numerous new and upgraded packages, this release has the following highlights:
|
In addition to numerous new and upgraded packages, this release has the following highlights:
|
||||||
|
|
||||||
- Please remove this line when you add the first item since docbook requires the section to be non-empty
|
- During cross-compilation, tests are now executed if the test suite can be executed
|
||||||
|
by the build platform. This is the case when doing “native” cross-compilation
|
||||||
|
where the build and host platforms are largely the same, but the nixpkgs' cross
|
||||||
|
compilation infrastructure is used, e.g. `pkgsStatic` and `pkgsLLVM`. Another
|
||||||
|
possibility is that the build platform is a superset of the host platform, e.g. when
|
||||||
|
cross-compiling from `x86_64-unknown-linux` to `i686-unknown-linux`.
|
||||||
|
The predicate gating test suite execution is the newly added `canExecute`
|
||||||
|
predicate: You can e.g. check if `stdenv.buildPlatform` can execute binaries
|
||||||
|
built for `stdenv.hostPlatform` (i.e. produced by `stdenv.cc`) by evaluating
|
||||||
|
`stdenv.buildPlatform.canExecute stdenv.hostPlatform`.
|
||||||
|
|
||||||
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
|
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
|
||||||
|
|
||||||
|
@ -18,7 +27,14 @@ In addition to numerous new and upgraded packages, this release has the followin
|
||||||
|
|
||||||
## Backward Incompatibilities {#sec-release-22.11-incompatibilities}
|
## Backward Incompatibilities {#sec-release-22.11-incompatibilities}
|
||||||
|
|
||||||
- Please remove this line when you add the first item since docbook requires the section to be non-empty
|
- The `isCompatible` predicate checking CPU compatibility is no longer exposed
|
||||||
|
by the platform sets generated using `lib.systems.elaborate`. In most cases
|
||||||
|
you will want to use the new `canExecute` predicate instead which also
|
||||||
|
considers the kernel / syscall interface. It is briefly described in the
|
||||||
|
release's [highlights section](#sec-release-22.11-highlights).
|
||||||
|
`lib.systems.parse.isCompatible` still exists, but has changed semantically:
|
||||||
|
Architectures with differing endianness modes are *no longer considered compatible*.
|
||||||
|
|
||||||
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
|
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
|
||||||
|
|
||||||
## Other Notable Changes {#sec-release-22.11-notable-changes}
|
## Other Notable Changes {#sec-release-22.11-notable-changes}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
{ lib, stdenv, fetchurl, fetchpatch
|
{ lib, stdenv, fetchurl, fetchpatch
|
||||||
, autoreconfHook
|
, autoreconfHook
|
||||||
|
|
||||||
, doCheck ? true # test suite depends on dejagnu which cannot be used during bootstrapping
|
# test suite depends on dejagnu which cannot be used during bootstrapping
|
||||||
|
# dejagnu also requires tcl which can't be built statically at the moment
|
||||||
|
, doCheck ? !(stdenv.hostPlatform.isStatic)
|
||||||
, dejagnu
|
, dejagnu
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
|
|
@ -167,8 +167,8 @@ makeOverlayable (overrideAttrs:
|
||||||
let
|
let
|
||||||
# TODO(@oxij, @Ericson2314): This is here to keep the old semantics, remove when
|
# TODO(@oxij, @Ericson2314): This is here to keep the old semantics, remove when
|
||||||
# no package has `doCheck = true`.
|
# no package has `doCheck = true`.
|
||||||
doCheck' = doCheck && stdenv.hostPlatform == stdenv.buildPlatform;
|
doCheck' = doCheck && stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
||||||
doInstallCheck' = doInstallCheck && stdenv.hostPlatform == stdenv.buildPlatform;
|
doInstallCheck' = doInstallCheck && stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
||||||
|
|
||||||
separateDebugInfo' = separateDebugInfo && stdenv.hostPlatform.isLinux && !(stdenv.hostPlatform.useLLVM or false);
|
separateDebugInfo' = separateDebugInfo && stdenv.hostPlatform.isLinux && !(stdenv.hostPlatform.useLLVM or false);
|
||||||
outputs' = outputs ++ lib.optional separateDebugInfo' "debug";
|
outputs' = outputs ++ lib.optional separateDebugInfo' "debug";
|
||||||
|
|
|
@ -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