stdenv: Force doCheck and doInstallCheck to be false when we are cross compiling

I hope this will be a temporary measure. If there is consensus around
issue #33599, then we can follow an explicit `dontCheck`, but default to
not checking during cross builds when none is given.
This commit is contained in:
John Ericson 2018-01-08 01:33:35 -05:00
parent b2cbffae64
commit 4e907dbca1
2 changed files with 33 additions and 15 deletions

View File

@ -995,13 +995,14 @@ but only if the <varname>doCheck</varname> variable is enabled.</para>
<varlistentry> <varlistentry>
<term><varname>doCheck</varname></term> <term><varname>doCheck</varname></term>
<listitem><para>If set to a non-empty string, the check phase is <listitem><para>
executed, otherwise it is skipped (default). Thus you should set Controls whether the check phase is executed.
By default it is skipped, but if <varname>doCheck</varname> is set to true, the check phase is usually executed.
<programlisting> Thus you should set <programlisting>doCheck = true;</programlisting> in the derivation to enable checks.
doCheck = true;</programlisting> The exception is cross compilation.
Cross compiled builds never run tests, no matter how <varname>doCheck</varname> is set,
in the derivation to enable checks.</para></listitem> as the newly-built program won't run on the platform used to build it.
</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -1280,12 +1281,14 @@ installcheck</command>.</para>
<varlistentry> <varlistentry>
<term><varname>doInstallCheck</varname></term> <term><varname>doInstallCheck</varname></term>
<listitem><para>If set to a non-empty string, the installCheck phase is <listitem><para>
executed, otherwise it is skipped (default). Thus you should set Controls whether the installCheck phase is executed.
By default it is skipped, but if <varname>doInstallCheck</varname> is set to true, the installCheck phase is usually executed.
<programlisting>doInstallCheck = true;</programlisting> Thus you should set <programlisting>doInstallCheck = true;</programlisting> in the derivation to enable install checks.
The exception is cross compilation.
in the derivation to enable install checks.</para></listitem> Cross compiled builds never run tests, no matter how <varname>doInstallCheck</varname> is set,
as the newly-built program won't run on the platform used to build it.
</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -36,6 +36,7 @@ rec {
, depsTargetTarget ? [] # 1 -> 1 , depsTargetTarget ? [] # 1 -> 1
, depsTargetTargetPropagated ? [] # 1 -> 1 , depsTargetTargetPropagated ? [] # 1 -> 1
# Configure Phase
, configureFlags ? [] , configureFlags ? []
, # Target is not included by default because most programs don't care. , # Target is not included by default because most programs don't care.
# Including it then would cause needless mass rebuilds. # Including it then would cause needless mass rebuilds.
@ -44,6 +45,13 @@ rec {
configurePlatforms ? lib.optionals configurePlatforms ? lib.optionals
(stdenv.hostPlatform != stdenv.buildPlatform) (stdenv.hostPlatform != stdenv.buildPlatform)
[ "build" "host" ] [ "build" "host" ]
# Check phase
, doCheck ? false
# InstallCheck phase
, doInstallCheck ? false
, crossConfig ? null , crossConfig ? null
, meta ? {} , meta ? {}
, passthru ? {} , passthru ? {}
@ -60,6 +68,7 @@ rec {
, hardeningEnable ? [] , hardeningEnable ? []
, hardeningDisable ? [] , hardeningDisable ? []
, ... } @ attrs: , ... } @ attrs:
# TODO(@Ericson2314): Make this more modular, and not O(n^2). # TODO(@Ericson2314): Make this more modular, and not O(n^2).
@ -178,9 +187,15 @@ rec {
"/bin/sh" "/bin/sh"
]; ];
__propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps; __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps;
} // (if outputs' != [ "out" ] then { } // lib.optionalAttrs (outputs' != [ "out" ]) {
outputs = outputs'; outputs = outputs';
} else { })); } // lib.optionalAttrs (attrs ? doCheck) {
# TODO(@Ericson2314): Make unconditional / resolve #33599
doCheck = doCheck && (stdenv.hostPlatform == stdenv.targetPlatform);
} // lib.optionalAttrs (attrs ? doInstallCheck) {
# TODO(@Ericson2314): Make unconditional / resolve #33599
doInstallCheck = doInstallCheck && (stdenv.hostPlatform == stdenv.targetPlatform);
});
# The meta attribute is passed in the resulting attribute set, # The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not # but it's not part of the actual derivation, i.e., it's not