stdenv: Add updateAutoconfGnuConfigScriptsHook for aarch64

This is required for Aarch64 since a lot of source tarballs ship with
outdated configure scripts that don't recognize aarch64. Simply
replacing the config.guess and config.sub with new versions from
upstream makes them build again.

This same approach is used by at least Buildroot and Fedora. In
principle this could be enabled for all architectures but
conditionalizing this on aarch64 avoids a mass rebuild on x86.
This commit is contained in:
Tuomas Tynkkynen 2016-03-05 02:28:23 +02:00
parent 6e46dbf8e7
commit c909f1b18e
4 changed files with 27 additions and 4 deletions

View File

@ -0,0 +1,12 @@
preConfigurePhases+=" updateAutotoolsGnuConfigScriptsPhase"
updateAutotoolsGnuConfigScriptsPhase() {
if [ -n "$dontUpdateAutotoolsGnuConfigScripts" ]; then return; fi
for script in config.sub config.guess; do
for f in $(find . -name "$script"); do
echo "Updating Autotools / GNU config script to a newer upstream version: $f"
cp -f "@gnu_config@/$script" "$f"
done
done
}

View File

@ -92,6 +92,7 @@ rec {
# without proper `file` command, libtool sometimes fails # without proper `file` command, libtool sometimes fails
# to recognize 64-bit DLLs # to recognize 64-bit DLLs
++ stdenv.lib.optional (cross.config == "x86_64-w64-mingw32") pkgs.file ++ stdenv.lib.optional (cross.config == "x86_64-w64-mingw32") pkgs.file
++ stdenv.lib.optional (cross.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook
; ;
# Cross-linking dynamic libraries, every buildInput should # Cross-linking dynamic libraries, every buildInput should

View File

@ -214,7 +214,9 @@ in
isl = isl_0_14; isl = isl_0_14;
}; };
}; };
extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ]; extraBuildInputs = [ 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;
}) })
@ -241,7 +243,9 @@ in
shell = self.bash + "/bin/bash"; shell = self.bash + "/bin/bash";
}; };
}; };
extraBuildInputs = [ prevStage.patchelf prevStage.xz ]; extraBuildInputs = [ 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;
}) })
# Construct the final stdenv. It uses the Glibc and GCC, and adds # Construct the final stdenv. It uses the Glibc and GCC, and adds
@ -269,7 +273,9 @@ in
initialPath = initialPath =
((import ../common-path.nix) {pkgs = prevStage;}); ((import ../common-path.nix) {pkgs = prevStage;});
extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ]; extraBuildInputs = [ 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;
cc = prevStage.gcc; cc = prevStage.gcc;
@ -288,7 +294,7 @@ in
[ gzip bzip2 xz bash binutils coreutils diffutils findutils gawk [ gzip bzip2 xz bash binutils coreutils diffutils findutils gawk
glibc gnumake gnused gnutar gnugrep gnupatch patchelf attr acl glibc gnumake gnused gnutar gnugrep gnupatch patchelf attr acl
paxctl zlib pcre linuxHeaders ed gcc gcc.cc libsigsegv paxctl zlib pcre linuxHeaders ed gcc gcc.cc libsigsegv
]; ] ++ lib.optional (system == "aarch64-linux") prevStage.updateAutotoolsGnuConfigScriptsHook;
*/ */
overrides = self: super: { overrides = self: super: {

View File

@ -79,6 +79,10 @@ with pkgs;
} }
''); '');
updateAutotoolsGnuConfigScriptsHook = makeSetupHook
{ substitutions = { gnu_config = gnu-config;}; }
../build-support/setup-hooks/update-autotools-gnu-config-scripts.sh;
buildEnv = callPackage ../build-support/buildenv { }; # not actually a package buildEnv = callPackage ../build-support/buildenv { }; # not actually a package
buildFHSUserEnv = callPackage ../build-support/build-fhs-userenv { }; buildFHSUserEnv = callPackage ../build-support/build-fhs-userenv { };