Merge pull request #65761 from lopsided98/perl-cross-references

perl: fix errant references when cross-compiling
This commit is contained in:
John Ericson 2019-11-05 14:26:36 -05:00 committed by GitHub
commit f11ed19450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
{ config, lib, stdenv, fetchurl, pkgs, buildPackages, callPackage { config, lib, stdenv, fetchurl, pkgs, buildPackages, callPackage
, enableThreading ? stdenv ? glibc, makeWrapper , enableThreading ? stdenv ? glibc, coreutils, makeWrapper
}: }:
with lib; with lib;
@ -35,7 +35,7 @@ let
# TODO: Add a "dev" output containing the header files. # TODO: Add a "dev" output containing the header files.
outputs = [ "out" "man" "devdoc" ] ++ outputs = [ "out" "man" "devdoc" ] ++
stdenv.lib.optional crossCompiling "dev"; optional crossCompiling "dev";
setOutputFlags = false; setOutputFlags = false;
disallowedReferences = [ stdenv.cc ]; disallowedReferences = [ stdenv.cc ];
@ -57,12 +57,20 @@ let
++ optionals stdenv.isDarwin [ ./cpp-precomp.patch ./sw_vers.patch ] ++ optionals stdenv.isDarwin [ ./cpp-precomp.patch ./sw_vers.patch ]
++ optional crossCompiling ./MakeMaker-cross.patch; ++ optional crossCompiling ./MakeMaker-cross.patch;
postPatch = '' # This is not done for native builds because pwd may need to come from
pwd="$(type -P pwd)" # bootstrap tools when building bootstrap perl.
postPatch = (if crossCompiling then ''
substituteInPlace dist/PathTools/Cwd.pm \ substituteInPlace dist/PathTools/Cwd.pm \
--replace "/bin/pwd" "$pwd" --replace "/bin/pwd" '${coreutils}/bin/pwd'
'' + stdenv.lib.optionalString crossCompiling ''
substituteInPlace cnf/configure_tool.sh --replace "cc -E -P" "cc -E" substituteInPlace cnf/configure_tool.sh --replace "cc -E -P" "cc -E"
'' else ''
substituteInPlace dist/PathTools/Cwd.pm \
--replace "/bin/pwd" "$(type -P pwd)"
'') +
# Perl's build system uses the src variable, and its value may end up in
# the output in some cases (when cross-compiling)
''
unset src
''; '';
# Build a thread-safe Perl with a dynamic libperls.o. We need the # Build a thread-safe Perl with a dynamic libperls.o. We need the
@ -85,7 +93,7 @@ let
++ optional stdenv.isSunOS "-Dcc=gcc" ++ optional stdenv.isSunOS "-Dcc=gcc"
++ optional enableThreading "-Dusethreads"; ++ optional enableThreading "-Dusethreads";
configureScript = stdenv.lib.optionalString (!crossCompiling) "${stdenv.shell} ./Configure"; configureScript = optionalString (!crossCompiling) "${stdenv.shell} ./Configure";
dontAddPrefix = !crossCompiling; dontAddPrefix = !crossCompiling;
@ -140,7 +148,7 @@ let
}" /no-such-path \ }" /no-such-path \
--replace "${stdenv.cc}" /no-such-path \ --replace "${stdenv.cc}" /no-such-path \
--replace "$man" /no-such-path --replace "$man" /no-such-path
'' + stdenv.lib.optionalString crossCompiling '' + optionalString crossCompiling
'' ''
mkdir -p $dev/lib/perl5/cross_perl/${version} mkdir -p $dev/lib/perl5/cross_perl/${version}
for dir in cnf/{stub,cpan}; do for dir in cnf/{stub,cpan}; do
@ -172,7 +180,7 @@ let
platforms = platforms.all; platforms = platforms.all;
priority = 6; # in `buildEnv' (including the one inside `perl.withPackages') the library files will have priority over files in `perl` priority = 6; # in `buildEnv' (including the one inside `perl.withPackages') the library files will have priority over files in `perl`
}; };
} // stdenv.lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) rec { } // optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) rec {
crossVersion = "980998f7d11baf97284426ca91f84681d49a08f5"; # Jul 20, 2019 crossVersion = "980998f7d11baf97284426ca91f84681d49a08f5"; # Jul 20, 2019
perl-cross-src = fetchurl { perl-cross-src = fetchurl {