-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
Make cross-compiling with the crossSystem argument work (v2) #21388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| { stdenv, lib, fetchurl, zlib, xz, python2, findXMLCatalogs, libiconv, fetchpatch | ||
| , pythonSupport ? (! stdenv ? cross) }: | ||
|
|
||
| let | ||
| python = python2; | ||
| in stdenv.mkDerivation rec { | ||
| , pythonSupport ? null }: | ||
|
|
||
| stdenv.mkDerivationWithCrossArg(cross: | ||
| let | ||
| pythonSupportReally = if pythonSupport != null then pythonSupport | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do something like |
||
| else cross == null; | ||
| python = assert pythonSupportReally; python2; | ||
| in rec { | ||
| name = "libxml2-${version}"; | ||
| version = "2.9.4"; | ||
|
|
||
|
|
@@ -28,18 +31,18 @@ in stdenv.mkDerivation rec { | |
| }; | ||
|
|
||
| outputs = [ "bin" "dev" "out" "doc" ] | ||
| ++ lib.optional pythonSupport "py"; | ||
| propagatedBuildOutputs = "out bin" + lib.optionalString pythonSupport " py"; | ||
| ++ lib.optional pythonSupportReally "py"; | ||
| propagatedBuildOutputs = "out bin" + lib.optionalString pythonSupportReally " py"; | ||
|
|
||
| buildInputs = lib.optional pythonSupport python | ||
| buildInputs = lib.optional pythonSupportReally python | ||
| # Libxml2 has an optional dependency on liblzma. However, on impure | ||
| # platforms, it may end up using that from /usr/lib, and thus lack a | ||
| # RUNPATH for that, leading to undefined references for its users. | ||
| ++ lib.optional stdenv.isFreeBSD xz; | ||
|
|
||
| propagatedBuildInputs = [ zlib findXMLCatalogs ]; | ||
|
|
||
| configureFlags = lib.optional pythonSupport "--with-python=${python}" | ||
| configureFlags = lib.optional pythonSupportReally "--with-python=${python}" | ||
| ++ [ "--exec_prefix=$dev" ]; | ||
|
|
||
| enableParallelBuilding = true; | ||
|
|
@@ -55,9 +58,9 @@ in stdenv.mkDerivation rec { | |
| propagatedBuildInputs = [ findXMLCatalogs libiconv ]; | ||
| }; | ||
|
|
||
| preInstall = lib.optionalString pythonSupport | ||
| preInstall = lib.optionalString pythonSupportReally | ||
| ''substituteInPlace python/libxml2mod.la --replace "${python}" "$py"''; | ||
| installFlags = lib.optionalString pythonSupport | ||
| installFlags = lib.optionalString pythonSupportReally | ||
| ''pythondir="$(py)/lib/${python.libPrefix}/site-packages"''; | ||
|
|
||
| postFixup = '' | ||
|
|
@@ -75,4 +78,4 @@ in stdenv.mkDerivation rec { | |
| platforms = lib.platforms.unix; | ||
| maintainers = [ lib.maintainers.eelco ]; | ||
| }; | ||
| } | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4674,18 +4674,18 @@ in | |
|
|
||
| gccApple = throw "gccApple is no longer supported"; | ||
|
|
||
| gccCrossStageStatic = let | ||
| libcCross1 = | ||
| if stdenv.cross.libc == "msvcrt" then windows.mingw_w64_headers | ||
| else if stdenv.cross.libc == "libSystem" then darwin.xcode | ||
| else null; | ||
| in wrapGCCCross { | ||
| gcc = forceNativeDrv (gcc.cc.override { | ||
| gccCrossStageStatic = | ||
| wrapGCCCross { | ||
| gcc = forceNativeDrv (callPackage ../development/compilers/gcc/5 { | ||
| cross = crossSystem; | ||
| crossStageStatic = true; | ||
| langCC = false; | ||
| noSysDirs = true; | ||
| isl = isl_0_14; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok for now, see |
||
| libcCross = libcCross1; | ||
| enableShared = false; | ||
| langCC = false; | ||
| langObjC = false; | ||
| langObjCpp = false; | ||
| }); | ||
| libc = libcCross1; | ||
| binutils = binutilsCross; | ||
|
|
@@ -4701,13 +4701,19 @@ in | |
| }; | ||
|
|
||
| gccCrossStageFinal = wrapGCCCross { | ||
| gcc = forceNativeDrv (gcc.cc.override { | ||
| gcc = forceNativeDrv (callPackage ../development/compilers/gcc/5 { | ||
| cross = crossSystem; | ||
| crossStageStatic = false; | ||
| noSysDirs = true; | ||
| isl = isl_0_14; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok for now, but we should figure out why this can't be the default so this and the Linux stdenv don't need to special case. |
||
| libcCross = libcCross; | ||
|
|
||
| # XXX: We have troubles cross-compiling libstdc++ on MinGW (see | ||
| # <http://hydra.nixos.org/build/4268232>), so don't even try. | ||
| langCC = crossSystem.config != "i686-pc-mingw32"; | ||
|
|
||
| langObjC = false; | ||
| langObjCpp = false; | ||
| }); | ||
| libc = libcCross; | ||
| binutils = binutilsCross; | ||
|
|
@@ -7184,8 +7190,13 @@ in | |
| linuxHeaders = linuxHeadersCross; | ||
| }); | ||
|
|
||
| # We can choose: | ||
| libcCrossChooser = name: if name == "glibc" then glibcCross | ||
| libcCross1 = | ||
| if stdenv.cross.libc == "msvcrt" then windows.mingw_w64_headers | ||
| else if stdenv.cross.libc == "libSystem" then darwin.xcode | ||
| else null; | ||
|
|
||
| libcCrossChooser = name: | ||
| if name == "glibc" then glibcCross | ||
| else if name == "uclibc" then uclibcCross | ||
| else if name == "msvcrt" then windows.mingw_w64 | ||
| else if name == "libSystem" then darwin.xcode | ||
|
|
@@ -8081,14 +8092,17 @@ in | |
|
|
||
| # glibc provides libiconv so systems with glibc don't need to build libiconv | ||
| # separately, but we also provide libiconvReal, which will always be a | ||
| # standalone libiconv, just in case you want it | ||
| libiconv = if crossSystem != null then | ||
| (if crossSystem.libc == "glibc" then libcCross | ||
| else if crossSystem.libc == "libSystem" then darwin.libiconv | ||
| else libiconvReal) | ||
| else if stdenv.isGlibc then glibcIconv stdenv.cc.libc | ||
| else if stdenv.isDarwin then darwin.libiconv | ||
| else libiconvReal; | ||
| # standalone libiconv, just in case you want it. | ||
| libiconv = | ||
| let | ||
| nativeDrv = if stdenv.isGlibc then stdenv.cc.libc | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
| else if stdenv.isDarwin then darwin.libiconv | ||
| else libiconvReal; | ||
| crossDrv = | ||
| if crossSystem.libc == "glibc" then libcCross | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, please use |
||
| else if crossSystem.libc == "libSystem" then darwin.libiconv | ||
| else libiconvReal.crossDrv; | ||
| in nativeDrv // { inherit crossDrv nativeDrv; }; | ||
|
|
||
| glibcIconv = libc: let | ||
| inherit (builtins.parseDrvName libc.name) name version; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,15 +58,11 @@ let | |
|
|
||
| aliases = self: super: import ./aliases.nix super; | ||
|
|
||
| # stdenvOverrides is used to avoid circular dependencies for building | ||
| # the standard build environment. This mechanism uses the override | ||
| # mechanism to implement some staged compilation of the stdenv. | ||
| # | ||
| # We don't want stdenv overrides in the case of cross-building, or | ||
| # otherwise the basic overridden packages will not be built with the | ||
| # crossStdenv adapter. | ||
| # stdenvOverrides is used to avoid having multiple of versions | ||
| # of certain dependencies that were used in bootstrapping the | ||
| # standard environment. | ||
| stdenvOverrides = self: super: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #21415 will imminently do half of this. See |
||
| lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides) | ||
| lib.optionalAttrs (super.stdenv ? overrides) | ||
| (super.stdenv.overrides super); | ||
|
|
||
| # Allow packages to be overridden globally via the `packageOverrides' | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please comment when
targetCrossSystemis non-null, I presume this is is a function ofbuildandhostandtargetbeing equal or not equal in some combination.