Author: chromatic
Date: Thu Aug 7 16:01:11 2008
New Revision: 30110
Modified:
trunk/config/inter/progs.pm
trunk/lib/Parrot/Configure/Compiler.pm
trunk/lib/Parrot/Configure/Utils.pm
Log:
[config] Improved test parallelization by appending PID to all generated
test.c, test.cco, test.ldo, and test exectuable files. This is a good target
for further refactoring:
- there's too much duplication of generated file names
- temporary names from File::Temp would be better
- building all files in a temporary directory would be even better
Modified: trunk/config/inter/progs.pm
==============================================================================
--- trunk/config/inter/progs.pm (original)
+++ trunk/config/inter/progs.pm Thu Aug 7 16:01:11 2008
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, The Perl Foundation.
+# Copyright (C) 2001-2008, The Perl Foundation.
# $Id$
=head1 NAME
@@ -128,7 +128,8 @@
grep { $conf->data->get_p5('OSNAME') =~ /VMS|MSWin/ ||
!/^-l(c|gdbm(_compat)?|dbm|ndbm|db)$/ }
split( q{ }, $libs );
$libs = integrate( $libs, $conf->options->get('libs') );
- $libs = prompt( "What libraries should your C compiler use?", $libs ) if
$ask;
+ $libs = prompt( "What libraries should your C compiler use?", $libs )
+ if $ask;
$conf->data->set( libs => $libs );
$cxx = integrate( $conf->data->get('cxx'), $conf->options->get('cxx') );
@@ -170,7 +171,7 @@
sub test_compiler {
my ($conf, $cc) = @_;
- open( my $out_fh, '>', 'test.c' ) or die "Unable to open 'test.c': [EMAIL
PROTECTED]";
+ open( my $out_fh, '>', "test_$$.c" ) or die "Unable to open 'test_$$.cb:
[EMAIL PROTECTED]";
print {$out_fh} <<END_C;
int main() {
return 0;
Modified: trunk/lib/Parrot/Configure/Compiler.pm
==============================================================================
--- trunk/lib/Parrot/Configure/Compiler.pm (original)
+++ trunk/lib/Parrot/Configure/Compiler.pm Thu Aug 7 16:01:11 2008
@@ -38,15 +38,15 @@
$conf->cc_gen($source)
-Generates F<test.c> from the specified source file.
+Generates F<test_$$.c> from the specified source file.
=cut
sub cc_gen {
- my $conf = shift;
+ my $conf = shift;
my $source = shift;
- $conf->genfile( $source, "test.c" );
+ $conf->genfile( $source, "test_$$.c" );
}
=item C<cc_build()>
@@ -57,7 +57,7 @@
$cc, $ccflags, $ldout, $o, $link, $linkflags, $cc_exe_out, $exe, $libs
-Calls the compiler and linker on F<test.c>.
+Calls the compiler and linker on F<test_$$.c>.
=cut
@@ -73,17 +73,20 @@
my ( $cc, $ccflags, $ldout, $o, $link, $linkflags, $cc_exe_out, $exe,
$libs ) =
$conf->data->get(qw(cc ccflags ld_out o link linkflags cc_exe_out exe
libs));
+ # unique test file name for parallel builds
+ my $test = 'test_' . $$;
my $compile_command = _build_compile_command( $cc, $ccflags, $cc_args );
- my $compile_result = _run_command( $compile_command, 'test.cco',
'test.cco', $verbose )
- and confess "C compiler failed (see test.cco)";
+ my $compile_result = _run_command( $compile_command, "$test.cco",
"$test.cco", $verbose );
+
if ($compile_result) {
+ confess "C compiler failed (see $test.cco)";
return $compile_result;
}
my $link_result =
- _run_command( "$link $linkflags test$o $link_args
${cc_exe_out}test$exe $libs",
- 'test.ldo', 'test.ldo', $verbose )
- and confess "Linker failed (see test.ldo)";
+ _run_command( "$link $linkflags $test$o $link_args
${cc_exe_out}${test}${exe} $libs",
+ "$test.ldo", "$test.ldo", $verbose )
+ and confess "Linker failed (see $test.ldo)";
if ($link_result) {
return $link_result;
}
@@ -103,18 +106,19 @@
my $exe = $conf->data->get('exe');
my $slash = $conf->data->get('slash');
my $verbose = $conf->options->get('verbose');
- my $test_exe = ".${slash}test${exe}";
+ my $test = 'test_' . $$;
+ my $test_exe = ".${slash}${test}${exe}";
my $run_error;
if ( defined( $_[0] ) && length( $_[0] ) ) {
local $" = ' ';
- $run_error = _run_command( "$test_exe @_", './test.out', undef,
$verbose );
+ $run_error = _run_command( "$test_exe @_", "./$test.out", undef,
$verbose );
}
else {
- $run_error = _run_command( "$test_exe", './test.out', undef, $verbose
);
+ $run_error = _run_command( $test_exe, "./$test.out", undef, $verbose );
}
- my $output = _slurp('./test.out');
+ my $output = _slurp("./$test.out");
return $output;
}
@@ -133,16 +137,17 @@
my $exe = $conf->data->get('exe');
my $slash = $conf->data->get('slash');
my $verbose = $conf->options->get('verbose');
+ my $test = 'test_' . $$;
if ( defined( $_[0] ) && length( $_[0] ) ) {
local $" = ' ';
- _run_command( ".${slash}test${exe} @_", './test.out', './test.out',
$verbose );
+ _run_command( ".${slash}$test${exe} @_", "./$test.out", "./$test.out",
$verbose );
}
else {
- _run_command( ".${slash}test${exe}", './test.out', './test.out',
$verbose );
+ _run_command( ".${slash}$test${exe}", "./$test.out", "./$test.out",
$verbose );
}
- my $output = _slurp('./test.out');
+ my $output = _slurp("./$test.out");
return $output;
}
@@ -157,7 +162,8 @@
sub cc_clean { ## no critic Subroutines::RequireFinalReturn
my $conf = shift;
- unlink map "test$_", qw( .c .cco .ldo .out), $conf->data->get(qw( o exe ));
+ unlink map "test_${$}$_", qw( .c .cco .ldo .out),
+ $conf->data->get(qw( o exe ));
}
=item C<genfile()>
Modified: trunk/lib/Parrot/Configure/Utils.pm
==============================================================================
--- trunk/lib/Parrot/Configure/Utils.pm (original)
+++ trunk/lib/Parrot/Configure/Utils.pm Thu Aug 7 16:01:11 2008
@@ -117,7 +117,7 @@
my ( $cc, $ccflags, $cc_args ) = @_;
$_ ||= '' for ( $cc, $ccflags, $cc_args );
- return "$cc $ccflags $cc_args -I./include -c test.c";
+ return "$cc $ccflags $cc_args -I./include -c test_$$.c";
}
=item C<integrate($orig, $new)>
@@ -240,7 +240,7 @@
# disable STDERR
open my $OLDERR, '>&', \*STDERR;
- open STDERR, '>', 'test.err';
+ open STDERR, '>', "test_$$.err";
my $output = `$command`;
my $retval = ( $? == -1 ) ? -1 : ( $? >> 8 );
@@ -250,10 +250,10 @@
open STDERR, '>&', $OLDERR;
# slurp stderr
- my $out_err = _slurp('./test.err');
+ my $out_err = _slurp("./test_$$.err");
# cleanup
- unlink "test.err";
+ unlink "test_$$.err";
return ( $output, $out_err, $retval ) if wantarray;
return $output;