[svn:parrot] r41759 - in branches/detect_llvm: config/auto t/steps/auto
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Thu Oct 8 01:39:05 UTC 2009
Author: jkeenan
Date: Thu Oct 8 01:38:58 2009
New Revision: 41759
URL: https://trac.parrot.org/parrot/changeset/41759
Log:
Increase rigor of probe for functioning LLVM. Clear up some uninitialized values when LLVM not found.
Modified:
branches/detect_llvm/config/auto/llvm.pm
branches/detect_llvm/t/steps/auto/llvm-01.t
Modified: branches/detect_llvm/config/auto/llvm.pm
==============================================================================
--- branches/detect_llvm/config/auto/llvm.pm Thu Oct 8 00:18:28 2009 (r41758)
+++ branches/detect_llvm/config/auto/llvm.pm Thu Oct 8 01:38:58 2009 (r41759)
@@ -42,15 +42,16 @@
my $llvm_lacking = 0;
foreach my $prog ( @{ $self->{llvm_components} } ) {
- my $output = q{};
- $output = capture_output( $prog->[0], '--version' );
- print $output, "\n" if $verbose;
+ my $output = capture_output( $prog->[0], '--version' );
my $exp = $prog->[1];
- unless ( $output =~ m/$exp/s ) {
+ unless ( defined($output) and $output =~ m/$exp/s ) {
$llvm_lacking++;
print "Could not get expected '--version' output for $prog->[0]\n"
if $verbose;
}
+ else {
+ print $output, "\n" if $verbose;
+ }
}
my $output = q{};
$output = capture_output( 'llvm-gcc', '--version' );
@@ -75,8 +76,7 @@
}
if ( $llvm_lacking ) {
- $self->set_result('no');
- $conf->data->set( has_llvm => '' );
+ $self->_handle_result( $conf, 0 );
}
else {
@@ -93,17 +93,26 @@
my $sfile = qq|$stem.s|;
my $nativefile = qq|$stem.native|;
eval {
- system(qq{llvm-gcc -O3 -emit-llvm $fullcfile -c -o $bcfile});
+ system(qq{llvm-gcc -O3 -emit-llvm $fullcfile -c -o $bcfile});
};
if ($@) {
- print "Unable to compile C file into LLVM bitcode file\n"
- if $verbose;
- $self->set_result('no');
- $conf->data->set( has_llvm => '' );
+ print "Unable to compile C file into LLVM bitcode file\n"
+ if $verbose;
+ $self->_handle_result( $conf, 0 );
}
else {
- $self->set_result('yes');
- $conf->data->set( has_llvm => 1 );
+ my $output;
+ eval {
+ $output = capture_output( 'lli', $bcfile );
+ };
+ if ( $@ or $output !~ /hello world/ ) {
+ print "Unable to into LLVM bitcode file with 'lli'\n"
+ if $verbose;
+ $self->_handle_result( $conf, 0 );
+ }
+ else {
+ $self->_handle_result( $conf, 1 );
+ }
}
foreach my $f ( $bcfile, $sfile, $nativefile ) {
unlink $f if ( -e $f );
@@ -113,6 +122,18 @@
return 1;
}
+sub _handle_result {
+ my ($self, $conf, $result) = @_;
+ if ( $result ) {
+ $self->set_result('yes');
+ $conf->data->set( has_llvm => 1 );
+ }
+ else {
+ $self->set_result('no');
+ $conf->data->set( has_llvm => '' );
+ }
+ return 1;
+}
1;
=head1 AUTHOR
Modified: branches/detect_llvm/t/steps/auto/llvm-01.t
==============================================================================
--- branches/detect_llvm/t/steps/auto/llvm-01.t Thu Oct 8 00:18:28 2009 (r41758)
+++ branches/detect_llvm/t/steps/auto/llvm-01.t Thu Oct 8 01:38:58 2009 (r41759)
@@ -58,10 +58,14 @@
ok( $ret, "runstep() returned true value" );
like( $step->result(), qr/yes|no/,
"Result was either 'yes' or 'no'" );
- like( $stdout, qr/llvm-gcc/s,
- "Got expected verbose output" );
- like( $stdout, qr/Low Level Virtual Machine/s,
- "Got expected verbose output" );
+ SKIP: {
+ skip 'No sense testing for verbose output if LLVM not present',
+ 2 unless ( $step->result() =~ /yes/ );
+ like( $stdout, qr/llvm-gcc/s,
+ "Got expected verbose output" );
+ like( $stdout, qr/Low Level Virtual Machine/s,
+ "Got expected verbose output" );
+ }
}
$conf->replenish($serialized);
More information about the parrot-commits
mailing list