summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/perl/perl-5.12.2/parallel_build_fix_5.patch
blob: 70f71047841704f70d192e4f34892dda9ad99787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
Upstream-Status:Inappropriate [Backport]

Rebased by Nitin A Kamble <nitin.a.kamble@intel.com> on 3/11/2011

commit 5e4c4c91bd52a48de59520d5e9b4e3478e49c613
Author: Nicholas Clark <nick@ccl4.org>
Date:   Mon Feb 14 10:14:18 2011 +0000

    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.

Index: perl-5.12.2/Cross/Makefile-cross-SH
===================================================================
--- perl-5.12.2.orig/Cross/Makefile-cross-SH
+++ perl-5.12.2/Cross/Makefile-cross-SH
@@ -324,7 +324,7 @@ $spitshell >>$Makefile <<'!NO!SUBS!'
 
 CONFIGPM = xlib/$(CROSS_NAME)/Config.pm
 
-private = preplibrary $(CONFIGPM) $(CROSS_LIB)/Config.pod
+private = preplibrary $(CONFIGPM) $(CROSS_LIB)/Config.pod lib/buildcustomize.pl
 
 shextract = Makefile cflags config.h makeaperl makedepend \
 	makedir myconfig writemain pod/Makefile
@@ -752,6 +752,9 @@ lib/lib.pm:	miniperl $(CONFIGPM)
 	@-rm -f $@
 	$(LDLIBPTH) ./miniperl -Ilib -MCross lib/lib_pm.PL
 
+lib/buildcustomize.pl: $(MINIPERL_EXE) write_buildcustomize.pl
+	$(MINIPERL) write_buildcustomize.pl >lib/buildcustomize.pl
+
 unidatafiles $(unidatafiles): uni.data
 
 uni.data: miniperl$(EXE_EXT) $(CONFIGPM) lib/unicore/mktables
@@ -922,16 +925,16 @@ manicheck:	FORCE
 
 
 
-$(DYNALOADER):	preplibrary FORCE
+$(DYNALOADER): lib/buildcustomize.pl preplibrary FORCE
 	@$(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib make_ext.pl --cross $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
 
-d_dummy $(dynamic_ext):	miniperl$(EXE_EXT) preplibrary makeppport $(DYNALOADER) FORCE
+d_dummy $(dynamic_ext):	miniperl$(EXE_EXT) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE
 	@$(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib make_ext.pl --cross $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=dynamic
 
-s_dummy $(static_ext):	miniperl$(EXE_EXT) preplibrary makeppport $(DYNALOADER) FORCE
+s_dummy $(static_ext):	miniperl$(EXE_EXT) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE
 	@$(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib make_ext.pl --cross $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
 
-n_dummy $(nonxs_ext):	miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
+n_dummy $(nonxs_ext):	miniperl$(EXE_EXT) lib/buildcustomize.pl preplibrary $(DYNALOADER) FORCE
 	@$(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib make_ext.pl --cross $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
 !NO!SUBS!
 
Index: perl-5.12.2/MANIFEST
===================================================================
--- perl-5.12.2.orig/MANIFEST
+++ perl-5.12.2/MANIFEST
@@ -4747,6 +4747,7 @@ win32/wince.c			WinCE port
 win32/wince.h			WinCE port
 win32/wincesck.c		WinCE port
 writemain.SH			Generate perlmain.c from miniperlmain.c+extensions
+write_buildcustomize.pl		Generate lib/buildcustomize.pl
 x2p/a2p.c			Output of a2p.y run through byacc
 x2p/a2p.h			Global declarations
 x2p/a2p.pod			Pod for awk to perl translator
Index: perl-5.12.2/Makefile.SH
===================================================================
--- perl-5.12.2.orig/Makefile.SH
+++ perl-5.12.2/Makefile.SH
@@ -428,7 +428,7 @@ esac
 ## In the following dollars and backticks do not need the extra backslash.
 $spitshell >>$Makefile <<'!NO!SUBS!'
 
-private = preplibrary $(CONFIGPM) $(CONFIGPOD) lib/ExtUtils/Miniperl.pm git_version.h
+private = preplibrary $(CONFIGPM) $(CONFIGPOD) lib/ExtUtils/Miniperl.pm git_version.h lib/buildcustomize.pl
 
 # Files to be built with variable substitution before miniperl
 # is available.
@@ -991,6 +991,9 @@ $(plextract):	$(MINIPERL_EXE) $(CONFIGPM
 x2p/s2p: $(MINIPERL_EXE) $(CONFIGPM) $(dynamic_ext) x2p/s2p.PL
 	cd x2p; $(LDLIBPTH) $(MAKE) s2p
 
+lib/buildcustomize.pl: $(MINIPERL_EXE) write_buildcustomize.pl
+	$(MINIPERL) write_buildcustomize.pl >lib/buildcustomize.pl
+
 unidatafiles $(unidatafiles) pod/perluniprops.pod: uni.data
 
 uni.data: $(MINIPERL_EXE) $(CONFIGPM) lib/unicore/mktables $(nonxs_ext)
@@ -1160,16 +1163,16 @@ manicheck:	FORCE
 #
 # DynaLoader may be needed for extensions that use Makefile.PL.
 
-$(DYNALOADER):	$(MINIPERL_EXE) preplibrary FORCE $(nonxs_ext)
+$(DYNALOADER):	$(MINIPERL_EXE) lib/buildcustomize.pl preplibrary FORCE $(nonxs_ext)
 	$(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
 
-d_dummy $(dynamic_ext):	$(MINIPERL_EXE) preplibrary makeppport $(DYNALOADER) FORCE $(PERLEXPORT)
+d_dummy $(dynamic_ext):	$(MINIPERL_EXE) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE $(PERLEXPORT)
 	$(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=dynamic
 
-s_dummy $(static_ext):	$(MINIPERL_EXE) preplibrary makeppport $(DYNALOADER) FORCE
+s_dummy $(static_ext):	$(MINIPERL_EXE) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE
 	$(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
 
-n_dummy $(nonxs_ext):	$(MINIPERL_EXE) preplibrary FORCE
+n_dummy $(nonxs_ext):	$(MINIPERL_EXE) lib/buildcustomize.pl preplibrary FORCE
 	$(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
 !NO!SUBS!
 
Index: perl-5.12.2/installperl
===================================================================
--- perl-5.12.2.orig/installperl
+++ perl-5.12.2/installperl
@@ -714,6 +714,8 @@ sub installlib {
     # ignore the test extensions
     return if $dir =~ m{\bXS/(?:APItest|Typemap)\b};
     return if $name =~ m{\b(?:APItest|Typemap)\.pm$};
+    # ignore the build support code
+    return if $name =~ /\bbuildcustomize\.pl$/;
     # ignore the demo files
     return if $dir =~ /\b(?:demos?|eg)\b/;
 
Index: perl-5.12.2/make_ext.pl
===================================================================
--- perl-5.12.2.orig/make_ext.pl
+++ perl-5.12.2/make_ext.pl
@@ -4,11 +4,9 @@ use warnings;
 use Config;
 BEGIN {
     if ($^O eq 'MSWin32') {
-	unshift @INC, ('../cpan/Cwd', '../cpan/Cwd/lib');
-	require File::Spec::Functions;
+	unshift @INC, '../cpan/Cwd';
 	require FindExt;
-    }
-    else {
+    } else {
 	unshift @INC, 'cpan/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
-		   cpan/Cwd cpan/Cwd/lib
-		   cpan/ExtUtils-Command/lib
-		   dist/ExtUtils-Install/lib
-		   cpan/ExtUtils-MakeMaker/lib
-		   cpan/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) . ')';
 
@@ -295,16 +272,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) {
@@ -375,7 +343,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";
Index: perl-5.12.2/vms/descrip_mms.template
===================================================================
--- perl-5.12.2.orig/vms/descrip_mms.template
+++ perl-5.12.2/vms/descrip_mms.template
@@ -360,7 +360,7 @@ CRTLOPTS =,$(CRTL)/Options
 unidatadirs = lib/unicore/To lib/unicore/lib
 
 # Modules which must be installed before we can build extensions
-LIBPREREQ = $(ARCHDIR)Config.pm $(ARCHDIR)Config_heavy.pl [.lib.VMS]Filespec.pm $(ARCHDIR)vmspipe.com [.lib]re.pm
+LIBPREREQ = $(ARCHDIR)Config.pm $(ARCHDIR)Config_heavy.pl [.lib.VMS]Filespec.pm $(ARCHDIR)vmspipe.com [.lib]re.pm [.lib]buildcustomize.pl
 
 utils1 = [.lib.pods]perldoc.com [.lib.ExtUtils]Miniperl.pm [.utils]c2ph.com [.utils]h2ph.com 
 utils2 = [.utils]h2xs.com [.utils]libnetcfg.com [.lib]perlbug.com [.utils]dprofpp.com 
@@ -458,6 +458,9 @@ archcorefiles : $(ac) $(ARCHAUTO)time.st
 [.lib]re.pm  : [.ext.re]re.pm
 	Copy/NoConfirm/Log $(MMS$SOURCE) [.lib]
 
+[.lib]buildcustomize.pl : write_buildcustomize.pl $(MINIPERL_EXE)
+       $(MINIPERL) write_buildcustomize.pl > [.lib]buildcustomize.pl
+
 vmspipe.com : [.vms]vmspipe.com
 	Copy/NoConfirm/Log $(MMS$SOURCE) []
 
@@ -561,7 +564,7 @@ unidatafiles.ts : $(MINIPERL_EXE) [.lib]
 	@ If F$Search("$(MMS$TARGET)").nes."" Then Delete/NoLog/NoConfirm $(MMS$TARGET);*
 	@ Copy/NoConfirm _NLA0: $(MMS$TARGET)
  
-DynaLoader$(O) : $(ARCHDIR)Config.pm $(MINIPERL_EXE) [.lib.VMS]Filespec.pm 
+DynaLoader$(O) : [.lib]buildcustomize.pl $(ARCHDIR)Config.pm $(MINIPERL_EXE) [.lib.VMS]Filespec.pm
 	$(MINIPERL) make_ext.pl "MAKE=$(MMS)" "DynaLoader"
 
 dynext : $(LIBPREREQ) $(DBG)perlshr$(E) unidatafiles.ts DynaLoader$(O) preplibrary makeppport $(MINIPERL_EXE)
@@ -1856,6 +1859,7 @@ tidy : cleanlis
 	- If F$Search("[.utils]*.com;-1").nes."" Then Purge/NoConfirm/Log [.utils]*.com
 	- If F$Search("[.x2p]*.com;-1").nes."" Then Purge/NoConfirm/Log [.x2p]*.com
 	- If F$Search("[.lib.pods]*.com;-1").nes."" Then Purge/NoConfirm/Log [.lib.pods]*.com
+	- If F$Search("[.lib]buildcustomize.pl;-1").nes."" Then Purge/NoConfirm/Log [.lib]buildcustomize.pl
 
 clean : tidy cleantest
       	- $(MINIPERL) make_ext.pl "MAKE=$(MMS)" "--all" "--target=clean"
Index: perl-5.12.2/win32/Makefile
===================================================================
--- perl-5.12.2.orig/win32/Makefile
+++ perl-5.12.2/win32/Makefile
@@ -923,6 +923,9 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh c
 	-$(MINIPERL) -I..\lib $(ICWD) config_h.PL "INST_VER=$(INST_VER)"
 	if errorlevel 1 $(MAKE) /$(MAKEFLAGS) $(CONFIGPM)
 
+..\lib\buildcustomize.pl: $(MINIPERL) ..\write_buildcustomize.pl
+	$(MINIPERL) -I..\lib ..\write_buildcustomize.pl .. >..\lib\buildcustomize.pl
+
 $(MINIPERL) : $(MINIDIR) $(MINI_OBJ)
 	$(LINK32) -subsystem:console -out:$@ @<<
 	$(LINK_FLAGS) $(LIBFILES) $(MINI_OBJ)
@@ -1045,24 +1048,24 @@ MakePPPort: $(MINIPERL) $(CONFIGPM) Exte
 #-------------------------------------------------------------------------------
 # There's no direct way to mark a dependency on
 # DynaLoader.pm, so this will have to do
-Extensions: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
+Extensions: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic
 
-Extensions_reonly: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
+Extensions_reonly: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +re
 
-Extensions_static : ..\make_ext.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM)
+Extensions_static : ..\make_ext.pl ..\lib\buildcustomize.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM)
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static
 	$(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static
 
-Extensions_nonxs: ..\make_ext.pl $(PERLDEP) $(CONFIGPM)
+Extensions_nonxs: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM)
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs
 
-$(DYNALOADER) : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
+$(DYNALOADER) : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynaloader
 
@@ -1159,6 +1162,7 @@ distclean: realclean
 	-del /f $(LIBDIR)\Win32CORE.pm
 	-del /f $(LIBDIR)\Win32API\File.pm
 	-del /f $(LIBDIR)\Win32API\File\cFile.pc
+	-del /f $(LIBDIR)\buildcustomize.pl
 	-del /f $(DISTDIR)\XSLoader\XSLoader.pm
 	-if exist $(LIBDIR)\App rmdir /s /q $(LIBDIR)\App
 	-if exist $(LIBDIR)\Archive rmdir /s /q $(LIBDIR)\Archive
Index: perl-5.12.2/win32/makefile.mk
===================================================================
--- perl-5.12.2.orig/win32/makefile.mk
+++ perl-5.12.2/win32/makefile.mk
@@ -1215,6 +1215,10 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh c
 	$(MINIPERL) -I..\lib $(ICWD) config_h.PL "INST_VER=$(INST_VER)" \
 	    || $(MAKE) $(MAKEMACROS) $(CONFIGPM) $(MAKEFILE)
 
+..\lib\buildcustomize.pl: $(MINIPERL) ..\write_buildcustomize.pl
+	$(MINIPERL) -I..\lib ..\write_buildcustomize.pl .. >..\lib\buildcustomize.pl
+
+
 $(MINIPERL) : $(MINIDIR) $(MINI_OBJ) $(CRTIPMLIBS)
 .IF "$(CCTYPE)" == "BORLAND"
 	if not exist $(CCLIBDIR)\PSDK\odbccp32.lib \
@@ -1423,24 +1427,24 @@ MakePPPort: $(MINIPERL) $(CONFIGPM) Exte
 #-------------------------------------------------------------------------------
 # There's no direct way to mark a dependency on
 # DynaLoader.pm, so this will have to do
-Extensions : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
+Extensions : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic
 
-Extensions_reonly : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
+Extensions_reonly : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +re
 
-Extensions_static : ..\make_ext.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM)
+Extensions_static : ..\make_ext.pl ..\lib\buildcustomize.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM)
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static
 	$(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static
 
-Extensions_nonxs : ..\make_ext.pl $(PERLDEP) $(CONFIGPM)
+Extensions_nonxs : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM)
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs
 
-$(DYNALOADER) : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
+$(DYNALOADER) : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
 	$(XCOPY) ..\*.h $(COREDIR)\*.*
 	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynaloader
 
@@ -1534,6 +1538,7 @@ distclean: realclean
 	-del /f $(LIBDIR)\Win32CORE.pm
 	-del /f $(LIBDIR)\Win32API\File.pm
 	-del /f $(LIBDIR)\Win32API\File\cFile.pc
+	-del /f $(LIBDIR)\buildcustomize.pl
 	-del /f $(DISTDIR)\XSLoader\XSLoader.pm
 	-if exist $(LIBDIR)\App rmdir /s /q $(LIBDIR)\App
 	-if exist $(LIBDIR)\Archive rmdir /s /q $(LIBDIR)\Archive
Index: perl-5.12.2/write_buildcustomize.pl
===================================================================
--- /dev/null
+++ perl-5.12.2/write_buildcustomize.pl
@@ -0,0 +1,50 @@
+#!./miniperl -w
+
+use strict;
+if (@ARGV) {
+    my $dir = shift;
+    chdir $dir or die "Can't chdir '$dir': $!";
+    unshift @INC, 'lib';
+}
+
+unshift @INC, ('cpan/Cwd', 'cpan/Cwd/lib');
+require File::Spec::Functions;
+
+# 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.
+
+my @toolchain = qw(cpan/AutoLoader/lib
+		   cpan/Cwd cpan/Cwd/lib
+		   cpan/ExtUtils-Command/lib
+		   dist/ExtUtils-Install/lib
+		   cpan/ExtUtils-MakeMaker/lib
+		   cpan/ExtUtils-Manifest/lib
+		   cpan/File-Path/lib
+		   );
+
+# Used only in ExtUtils::Liblist::Kid::_win32_ext()
+push @toolchain, 'cpan/Text-ParseWords/lib' if $^O eq 'MSWin32';
+
+# lib must be last, as the the toolchain modules write themselves into it
+# as they build, and it's important that @INC order ensures that the partially
+# written files are always masked by the complete versions.
+
+my $inc = join ",\n        ",
+    map { "q\0$_\0" }
+    (map {File::Spec::Functions::rel2abs($_)} @toolchain, 'lib'), '.';
+
+# If any of the system's build tools are written in Perl, then this module
+# may well be loaded by a much older version than we are building. So keep it
+# as backwards compatible as is easy.
+print <<"EOT";
+#!perl
+
+# We are miniperl, building extensions
+# Reset \@INC completely, adding the directories we need, and removing the
+# installed directories (which we don't need to read, and may confuse us)
+\@INC = ($inc);
+EOT