git.iko.soy/typeable/nixpkgs
on master help sign in
cross stdenv: let build package's build deps resolve to native packages

This fixes the "sliding window" principle: 0. Run packages: build = native; host = foreign; target = foreign; 1. Build packages: build = native; host = native; target = foreign; 2. Vanilla packages: build = native; host = native; target = native; 3. Vanilla packages: build = native; host = native; target = native; n+3. ... Each stage's build dependencies are resolved against the previous stage, and the "foreigns" are shifted accordingly. Vanilla packages alone are built against themsevles, since there are no more "foreign"s to shift away. Before, build packages' build dependencies were resolved against themselves: 0. Run packages: build = native; host = foreign; target = foreign; 1. Build packages: build = native; host = native; target = foreign; 2. Build packages: build = native; host = native; target = foreign; n+2. ... This is wrong because that principle is violated by the target platform staying foreign. This will change the hashes of many build packages and run packages, but that is OK. This is an unavoidable cost of fixing cross compiling. The cross compilation docs have been updated to reflect this fix.

commit5eaea6cee01e9172ae65ccb6356861786a0f85cc authorJohn Ericson <Ericson2314@Yahoo.com> dateMon 26 Dec 2016, 14:32 (10 years ago) parent3ccc139
2 files changed+7−7
doc/cross-compilation.xml+6−5 pkgs/stdenv/cross/default.nix+1−2
doc/cross-compilation.xml+6−5
@@ -105,14 +105,15 @@
105105 This is the most important guiding principle behind cross-compilation with Nixpkgs, and will be called the <wordasword>sliding window principle</wordasword>.
106106 In this manner, given the 3 platforms for one package, we can determine the three platforms for all its transitive dependencies.
107107 </para>
108+ <para>
109+ Some examples will probably make this clearer.
110+ If a package is being built with a <literal>(build, host, target)</literal> platform triple of <literal>(foo, bar, bar)</literal>, then its build-time dependencies would have a triple of <literal>(foo, foo, bar)</literal>, and <emphasis>those packages'</emphasis> build-time dependencies would have triple of <literal>(foo, foo, foo)</literal>.
111+ In other words, it should take two "rounds" of following build-time dependency edges before one reaches a fixed point where, by the sliding window principle, the platform triple no longer changes.
112+ Indeed, this happens with cross compilation, where only rounds of native dependencies starting with the second necessarily coincide with native packages.
113+ </para>
108114 <note><para>
109115 The depending package's target platform is unconstrained by the sliding window principle, which makes sense in that one can in principle build cross compilers targeting arbitrary platforms.
110116 </para></note>
111− <warning><para>
112− From the above, one would surmise that if a package is being built with a <literal>(build, host, target)</literal> platform triple of <literal>(foo, bar, bar)</literal>, then its build-time dependencies would have a triple of <literal>(foo, foo, bar)</literal>, and <emphasis>those packages'</emphasis> build-time dependencies would have triple of <literal>(foo, foo, foo)</literal>.
113− In other words, it should take two "rounds" of following build-time dependency edges before one reaches a fixed point where, by the sliding window principle, the platform triple no longer changes.
114− Unfortunately, at the moment, we do <emphasis>not</emphasis> implement this correctly, and after only one round of following build-time dependencies is the fixed point reached, with target incorrectly kept different than the others.
115− </para></warning>
116117 <para>
117118 How does this work in practice? Nixpkgs is now structured so that build-time dependencies are taken from from <varname>buildPackages</varname>, whereas run-time dependencies are taken from the top level attribute set.
118119 For example, <varname>buildPackages.gcc</varname> should be used at build time, while <varname>gcc</varname> should be used at run time.
pkgs/stdenv/cross/default.nix+1−2
@@ -18,8 +18,7 @@ in bootStages ++ [
1818 hostPlatform = localSystem;
1919 targetPlatform = crossSystem;
2020 inherit config overlays;
21− # Should be false, but we're trying to preserve hashes for now
22− selfBuild = true;
21+ selfBuild = false;
2322 # It's OK to change the built-time dependencies
2423 allowCustomOverrides = true;
2524 stdenv = vanillaPackages.stdenv // {