From 738bb4777cf08625adf22f50227377003598f7ad Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 21 Sep 2017 11:16:25 -0400 Subject: [PATCH 1/3] stdenv: Update autotools scripts on all Aarch64, not just Linux This is needed when cross-compiling for iOS (Aarch64 + Darwin). I also changed the syntax of the Linux stdenv for visual consistency, though that has no effect on semantics as the os is already guaranteed to be Linux. --- pkgs/stdenv/adapters.nix | 2 +- pkgs/stdenv/linux/default.nix | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index ac382927b1b9..07d1c245b49c 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -105,7 +105,7 @@ rec { # without proper `file` command, libtool sometimes fails # to recognize 64-bit DLLs ++ stdenv.lib.optional (hostPlatform.config == "x86_64-w64-mingw32") pkgs.file - ++ stdenv.lib.optional (hostPlatform.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook + ++ stdenv.lib.optional hostPlatform.isAarch64 pkgs.updateAutotoolsGnuConfigScriptsHook ; # Cross-linking dynamic libraries, every buildInput should diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index fab1985b9765..e79ec48e9f42 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -219,7 +219,7 @@ in }; extraNativeBuildInputs = [ prevStage.patchelf prevStage.paxctl ] ++ # Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64. - lib.optional (system == "aarch64-linux") prevStage.updateAutotoolsGnuConfigScriptsHook; + lib.optional localSystem.isAarch64 prevStage.updateAutotoolsGnuConfigScriptsHook; }) @@ -251,7 +251,7 @@ in }; extraNativeBuildInputs = [ prevStage.patchelf prevStage.xz ] ++ # Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64. - lib.optional (system == "aarch64-linux") prevStage.updateAutotoolsGnuConfigScriptsHook; + lib.optional localSystem.isAarch64 prevStage.updateAutotoolsGnuConfigScriptsHook; }) # Construct the final stdenv. It uses the Glibc and GCC, and adds @@ -281,7 +281,7 @@ in extraNativeBuildInputs = [ prevStage.patchelf prevStage.paxctl ] ++ # Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64. - lib.optional (system == "aarch64-linux") prevStage.updateAutotoolsGnuConfigScriptsHook; + lib.optional localSystem.isAarch64 prevStage.updateAutotoolsGnuConfigScriptsHook; cc = prevStage.gcc; @@ -312,7 +312,7 @@ in glibc.out glibc.dev glibc.bin/*propagated from .dev*/ linuxHeaders gcc gcc.cc gcc.cc.lib gcc.expand-response-params ] - ++ lib.optionals (system == "aarch64-linux") + ++ lib.optionals localSystem.isAarch64 [ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ]; overrides = self: super: { From 05ef1034c7ebbe106ebd4615b06dcf421658c56c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 21 Sep 2017 14:52:07 -0400 Subject: [PATCH 2/3] stdenv cross adaptor: Add optional `overrides` parameter By default, all previous overrides are discarded as before, as they would only apply to the old host platform. But sometimes it is useful to add some new ones, and this optional parameter allows that. --- pkgs/stdenv/adapters.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 07d1c245b49c..b79ada60b3fd 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -59,17 +59,17 @@ rec { makeStdenvCross = { stdenv , cc , buildPlatform, hostPlatform, targetPlatform + , # Prior overrides are surely not valid as packages built + # with this run on a different platform, so disable by + # default. + overrides ? _: _: {} } @ overrideArgs: let stdenv = overrideArgs.stdenv.override { inherit buildPlatform hostPlatform targetPlatform - cc; + cc overrides; allowedRequisites = null; - - # Overrides are surely not valid as packages built with this run on a - # different platform. - overrides = _: _: {}; }; in stdenv // { mkDerivation = From 3af3d6efc23400613ef9301dfa67220b9e8ff647 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 21 Sep 2017 11:40:46 -0400 Subject: [PATCH 3/3] stdenv cross adapater: Remove old `extraBuildInputs` They, unlike their native counterparts, run on the wrong platform and are therefore invalid. --- pkgs/stdenv/adapters.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index b79ada60b3fd..25ee9adfd9d9 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -70,6 +70,7 @@ rec { cc overrides; allowedRequisites = null; + extraBuildInputs = [ ]; # Old ones run on wrong platform }; in stdenv // { mkDerivation =