summaryrefslogtreecommitdiff
path: root/make_ext.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-02-14 10:14:18 +0000
committerNicholas Clark <nick@ccl4.org>2011-02-15 14:10:05 +0000
commit5e4c4c91bd52a48de59520d5e9b4e3478e49c613 (patch)
treef48289786af8d9237deb0640edf73e19f7dfda34 /make_ext.pl
parent43c0c913165d6abe1bc0cb45a784eb1c32c3700b (diff)
downloadperl-5e4c4c91bd52a48de59520d5e9b4e3478e49c613.tar.gz
Use a buildcustomize.pl to set @INC in miniperl when building extensions.
With the build tools now shipped in various subdirectories of cpan/ and dist/ we need to add several paths to @INC when invoking MakeMaker (etc) to build extensions. The previous approach of using $ENV{PERL5LIB} was fragile, because: a: It was hitting the length limit for %ENV variables on VMS b: It was running the risk of race conditions in a parallel build - ExtUtils::Makemaker "knows" to add -I../..lib, which puts lib at the *front* of @INC, but if one parallel process happens to copy a module into lib/ whilst another is searching for it, the second may get a partial read c: Overwriting $ENV{PERL5LIB} breaks any system where any of the installed build tools are actually implemented in Perl, if they are relying on $ENV{PERL5LIB} for setup This approach a: Doesn't have %ENV length limits b: Ensures that lib/ is last, so copy targets are always shadowing copy sources c: Only affects miniperl, and doesn't touch $ENV{PERL5LIB} Approaches that turned out to have fatal flaws: 1: Using $ENV{PERL5OPT} with a module fails because ExtUtils::MakeMaker searches for the build perl without setting lib, and treats the error caused by a failed -M as "not a valid perl 5 binary" 2: Refactoring ExtUtils::MakeMaker to *not* use -I for lib, and instead rely on $ENV{PERL5LIB} [which includes "../../lib"] fails because: some extensions have subdirectories, and on these EU::MM correctly uses -I../../../lib, where as $ENV{PERL5LIB} only has space for relative paths, and only with two levels. This approach actually takes advantage of ExtUtils::MakeMaker setting an -I option correct for the depth of directory being built.
Diffstat (limited to 'make_ext.pl')
-rw-r--r--make_ext.pl38
1 files changed, 3 insertions, 35 deletions
diff --git a/make_ext.pl b/make_ext.pl
index b780ec9dab..13a15b4601 100644
--- a/make_ext.pl
+++ b/make_ext.pl
@@ -4,11 +4,9 @@ use warnings;
use Config;
BEGIN {
if ($^O eq 'MSWin32') {
- unshift @INC, ('../dist/Cwd', '../dist/Cwd/lib');
- require File::Spec::Functions;
+ unshift @INC, '../dist/Cwd';
require FindExt;
- }
- else {
+ } else {
unshift @INC, 'dist/Cwd';
}
}
@@ -18,27 +16,6 @@ my $is_Win32 = $^O eq 'MSWin32';
my $is_VMS = $^O eq 'VMS';
my $is_Unix = !$is_Win32 && !$is_VMS;
-# To clarify, this isn't the entire suite of modules considered "toolchain"
-# It's not even all modules needed to build ext/
-# It's just the source paths of the (minimum complete set of) modules in ext/
-# needed to build the nonxs modules
-# After which, all nonxs modules are in lib, which was always sufficient to
-# allow miniperl to build everything else.
-
-# This list cannot get any longer without overflowing the length limit for
-# environment variables on VMS
-my @toolchain = qw(cpan/AutoLoader/lib
- dist/Cwd dist/Cwd/lib
- dist/ExtUtils-Command/lib
- dist/ExtUtils-Install/lib
- cpan/ExtUtils-MakeMaker/lib
- dist/ExtUtils-Manifest/lib
- cpan/File-Path/lib
- );
-
-# Used only in ExtUtils::Liblist::Kid::_win32_ext()
-push @toolchain, 'cpan/Text-ParseWords/lib' if $is_Win32;
-
my @ext_dirs = qw(cpan dist ext);
my $ext_dirs_re = '(?:' . join('|', @ext_dirs) . ')';
@@ -296,16 +273,7 @@ sub build_extension {
$perl ||= "$up/miniperl";
my $return_dir = $up;
my $lib_dir = "$up/lib";
- # $lib_dir must be last, as we're copying files into it, and in a parallel
- # make there's a race condition if one process tries to open a module that
- # another process has half-written.
- my @new_inc = ((map {"$up/$_"} @toolchain), $lib_dir);
- if ($is_Win32) {
- @new_inc = map {File::Spec::Functions::rel2abs($_)} @new_inc;
- }
- $ENV{PERL5LIB} = join $Config{path_sep}, @new_inc;
$ENV{PERL_CORE} = 1;
- # warn $ENV{PERL5LIB};
my $makefile;
if ($is_VMS) {
@@ -421,7 +389,7 @@ EOM
@cross = '-MCross';
}
- my @args = (@cross, 'Makefile.PL');
+ my @args = ("-I$lib_dir", @cross, 'Makefile.PL');
if ($is_VMS) {
my $libd = VMS::Filespec::vmspath($lib_dir);
push @args, "INST_LIB=$libd", "INST_ARCHLIB=$libd";