diff options
author | Shea Levy <shea@shealevy.com> | 2018-02-28 12:00:03 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2018-02-28 15:01:32 -0500 |
commit | 306d5cdf03ad6375861a20b8885ef38699ca3c23 (patch) | |
tree | e117b9fbf1c63aa95a92efd8e47204d694527cf0 /pkgs/development/interpreters/perl/default.nix | |
parent | 8e6520540e6ab0ce5d265cf4bcf68bf8e4ec64a5 (diff) | |
download | nixlib-306d5cdf03ad6375861a20b8885ef38699ca3c23.tar nixlib-306d5cdf03ad6375861a20b8885ef38699ca3c23.tar.gz nixlib-306d5cdf03ad6375861a20b8885ef38699ca3c23.tar.bz2 nixlib-306d5cdf03ad6375861a20b8885ef38699ca3c23.tar.lz nixlib-306d5cdf03ad6375861a20b8885ef38699ca3c23.tar.xz nixlib-306d5cdf03ad6375861a20b8885ef38699ca3c23.tar.zst nixlib-306d5cdf03ad6375861a20b8885ef38699ca3c23.zip |
perlPackages: Add cross-compilation support.
This involved: * Installing miniperl as $dev/bin/perl * Setting miniperl to take INC from lib/perl5/{site_perl/,}cross_perl/${version} as well as lib/perl5/{site_perl/,}/${version}/${runtimeArch}, in that order. miniperl taking from runtimeArch is not really correct, but it works in some pure-perl cases (e.g. Config.pm) and can be overridden with the cross_perl variant. * Installing perl-cross's stubs into $dev/lib/perl5/cross_perl/${version} * Patching MakeMaker.pm to gracefully degrade (very slightly) if B.pm can't be loaded, which it can't in cross-compilation. * Passing the right build-time and runtime perls to Makefile.PL
Diffstat (limited to 'pkgs/development/interpreters/perl/default.nix')
-rw-r--r-- | pkgs/development/interpreters/perl/default.nix | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/pkgs/development/interpreters/perl/default.nix b/pkgs/development/interpreters/perl/default.nix index f7324fc6d01a..0fd55bd8d71b 100644 --- a/pkgs/development/interpreters/perl/default.nix +++ b/pkgs/development/interpreters/perl/default.nix @@ -1,4 +1,6 @@ -{ lib, stdenv, fetchurlBoot, buildPackages, enableThreading ? stdenv ? glibc, fetchpatch }: +{ lib, stdenv, fetchurlBoot, buildPackages +, enableThreading ? stdenv ? glibc, fetchpatch, makeWrapper +}: with lib; @@ -29,7 +31,8 @@ let }; # TODO: Add a "dev" output containing the header files. - outputs = [ "out" "man" "devdoc" ]; + outputs = [ "out" "man" "devdoc" ] ++ + stdenv.lib.optional crossCompiling "dev"; setOutputFlags = false; patches = @@ -45,7 +48,8 @@ let }) ++ optional stdenv.isSunOS ./ld-shared.patch ++ optional stdenv.isDarwin ./cpp-precomp.patch - ++ optional (stdenv.isDarwin && versionAtLeast version "5.24") ./sw_vers.patch; + ++ optional (stdenv.isDarwin && versionAtLeast version "5.24") ./sw_vers.patch + ++ optional crossCompiling ./MakeMaker-cross.patch; postPatch = '' pwd="$(type -P pwd)" @@ -117,6 +121,28 @@ let if stdenv.cc.cc or null != null then stdenv.cc.cc else "/no-such-path" }" /no-such-path \ --replace "$man" /no-such-path + '' + stdenv.lib.optionalString crossCompiling + '' + mkdir -p $dev/lib/perl5/cross_perl/${version} + for dir in cnf/{stub,cpan}; do + cp -r $dir/* $dev/lib/perl5/cross_perl/${version} + done + + mkdir -p $dev/bin + install -m755 miniperl $dev/bin/perl + + export runtimeArch="$(ls $out/lib/perl5/site_perl/${version})" + # wrapProgram should use a runtime-native SHELL by default, but + # it actually uses a buildtime-native one. If we ever fix that, + # we'll need to fix this to use a buildtime-native one. + # + # Adding the arch-specific directory is morally incorrect, as + # miniperl can't load the native modules there. However, it can + # (and sometimes needs to) load and run some of the pure perl + # code there, so we add it anyway. When needed, stubs can be put + # into $dev/lib/perl5/cross_perl/${version}. + wrapProgram $dev/bin/perl --prefix PERL5LIB : \ + "$dev/lib/perl5/cross_perl/${version}:$out/lib/perl5/${version}:$out/lib/perl5/${version}/$runtimeArch" ''; # */ meta = { @@ -139,7 +165,7 @@ let sha256 = "1gh8w9m5if2s0lrx2x8f8grp74d1l6d46m8jglpjm5a1kf55j810"; }; - depsBuildBuild = [ buildPackages.stdenv.cc ]; + depsBuildBuild = [ buildPackages.stdenv.cc makeWrapper ]; postUnpack = '' unpackFile ${perl-cross-src} @@ -150,6 +176,11 @@ let ''; configurePlatforms = [ "build" "host" "target" ]; + + inherit version; + + # TODO merge setup hooks + setupHook = ./setup-hook-cross.sh; }); in rec { perl = perl524; |