Skip to content
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

perl: fix errant references when cross-compiling #65761

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions pkgs/development/interpreters/perl/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ config, lib, stdenv, fetchurl, pkgs, buildPackages, callPackage
, enableThreading ? stdenv ? glibc, makeWrapper
, enableThreading ? stdenv ? glibc, coreutils, makeWrapper
}:

with lib;
Expand Down Expand Up @@ -35,7 +35,7 @@ let

# TODO: Add a "dev" output containing the header files.
outputs = [ "out" "man" "devdoc" ] ++
stdenv.lib.optional crossCompiling "dev";
optional crossCompiling "dev";
setOutputFlags = false;

disallowedReferences = [ stdenv.cc ];
Expand All @@ -57,12 +57,20 @@ let
++ optionals stdenv.isDarwin [ ./cpp-precomp.patch ./sw_vers.patch ]
++ optional crossCompiling ./MakeMaker-cross.patch;

postPatch = ''
pwd="$(type -P pwd)"
# This is not done for native builds because pwd may need to come from
# bootstrap tools when building bootstrap perl.
postPatch = (if crossCompiling then ''
substituteInPlace dist/PathTools/Cwd.pm \
--replace "/bin/pwd" "$pwd"
'' + stdenv.lib.optionalString crossCompiling ''
--replace "/bin/pwd" '${coreutils}/bin/pwd'
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
Expand All @@ -85,7 +93,7 @@ let
++ optional stdenv.isSunOS "-Dcc=gcc"
++ optional enableThreading "-Dusethreads";

configureScript = stdenv.lib.optionalString (!crossCompiling) "${stdenv.shell} ./Configure";
configureScript = optionalString (!crossCompiling) "${stdenv.shell} ./Configure";

dontAddPrefix = !crossCompiling;

Expand Down Expand Up @@ -140,7 +148,7 @@ let
}" /no-such-path \
--replace "${stdenv.cc}" /no-such-path \
--replace "$man" /no-such-path
'' + stdenv.lib.optionalString crossCompiling
'' + optionalString crossCompiling
''
mkdir -p $dev/lib/perl5/cross_perl/${version}
for dir in cnf/{stub,cpan}; do
Expand Down Expand Up @@ -172,7 +180,7 @@ let
platforms = platforms.all;
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

perl-cross-src = fetchurl {
Expand Down