[svn:parrot] r41758 - in branches/detect_llvm: . config/auto config/auto/llvm t/steps/auto
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Thu Oct 8 00:18:30 UTC 2009
Author: jkeenan
Date: Thu Oct 8 00:18:28 2009
New Revision: 41758
URL: https://trac.parrot.org/parrot/changeset/41758
Log:
Begin adding functionality to determine whether the LLVM, if installed, actually works. Delete commented-out code in test file.
Added:
branches/detect_llvm/config/auto/llvm/
branches/detect_llvm/config/auto/llvm/hello.c (contents, props changed)
Modified:
branches/detect_llvm/MANIFEST
branches/detect_llvm/config/auto/llvm.pm
branches/detect_llvm/t/steps/auto/llvm-01.t
Modified: branches/detect_llvm/MANIFEST
==============================================================================
--- branches/detect_llvm/MANIFEST Wed Oct 7 23:39:00 2009 (r41757)
+++ branches/detect_llvm/MANIFEST Thu Oct 8 00:18:28 2009 (r41758)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Oct 7 01:41:24 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Wed Oct 7 21:06:54 2009 UT
#
# See below for documentation on the format of this file.
#
@@ -258,6 +258,7 @@
config/auto/isreg/test_c.in []
config/auto/jit.pm []
config/auto/llvm.pm []
+config/auto/llvm/hello.c []
config/auto/memalign.pm []
config/auto/memalign/test2_c.in []
config/auto/memalign/test_c.in []
Modified: branches/detect_llvm/config/auto/llvm.pm
==============================================================================
--- branches/detect_llvm/config/auto/llvm.pm Wed Oct 7 23:39:00 2009 (r41757)
+++ branches/detect_llvm/config/auto/llvm.pm Thu Oct 8 00:18:28 2009 (r41758)
@@ -27,6 +27,11 @@
my %data;
$data{description} = q{Is LLVM installed};
$data{result} = q{};
+ $data{llvm_components} = [
+ [ 'llvm-gcc' => 'llvm-gcc' ],
+ [ 'lli' => 'Low Level Virtual Machine' ],
+ [ 'llc' => 'Low Level Virtual Machine' ],
+ ];
return \%data;
}
@@ -35,23 +40,41 @@
my $verbose = $conf->options->get( 'verbose' );
- my @llvm_components = (
- [ 'llvm-gcc' => 'llvm-gcc' ],
- [ 'lli' => 'Low Level Virtual Machine' ],
- [ 'llc' => 'Low Level Virtual Machine' ],
- );
- my $sanity_check = 0;
- foreach my $prog (@llvm_components) {
- my $output = capture_output( $prog->[0], '--version' );
+ 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 $exp = $prog->[1];
unless ( $output =~ m/$exp/s ) {
- $sanity_check++;
+ $llvm_lacking++;
print "Could not get expected '--version' output for $prog->[0]\n"
if $verbose;
}
}
- if ( $sanity_check ) {
+ my $output = q{};
+ $output = capture_output( 'llvm-gcc', '--version' );
+ if (! $output) {
+ $llvm_lacking++;
+ }
+ else {
+ my @line = split /\n+/, $output;
+ if ( $line[0] =~ m/\b(\d+)\.(\d+)\.(\d+)\b/ ) {
+ my @version = ($1, $2, $3);
+ if ($version[0] < 4) {
+ print "llvm-gcc must be at least major version 4\n"
+ if $verbose;
+ $llvm_lacking++;
+ }
+ }
+ else {
+ print "Unable to extract llvm-gcc major, minor and patch versions\n"
+ if $verbose;
+ $llvm_lacking++;
+ }
+ }
+
+ if ( $llvm_lacking ) {
$self->set_result('no');
$conf->data->set( has_llvm => '' );
}
@@ -63,8 +86,28 @@
# language file into a program and execute it. Cf.:
# http://llvm.org/releases/2.5/docs/GettingStarted.html#overview
- $self->set_result('yes');
- $conf->data->set( has_llvm => 1 );
+ my $stem = q|hello|;
+ my $cfile = qq|$stem.c|;
+ my $fullcfile = qq|config/auto/llvm/$cfile|;
+ my $bcfile = qq|$stem.bc|;
+ my $sfile = qq|$stem.s|;
+ my $nativefile = qq|$stem.native|;
+ eval {
+ 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 => '' );
+ }
+ else {
+ $self->set_result('yes');
+ $conf->data->set( has_llvm => 1 );
+ }
+ foreach my $f ( $bcfile, $sfile, $nativefile ) {
+ unlink $f if ( -e $f );
+ }
}
return 1;
Added: branches/detect_llvm/config/auto/llvm/hello.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/detect_llvm/config/auto/llvm/hello.c Thu Oct 8 00:18:28 2009 (r41758)
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main() {
+ printf("hello world\n");
+ return 0;
+}
Modified: branches/detect_llvm/t/steps/auto/llvm-01.t
==============================================================================
--- branches/detect_llvm/t/steps/auto/llvm-01.t Wed Oct 7 23:39:00 2009 (r41757)
+++ branches/detect_llvm/t/steps/auto/llvm-01.t Thu Oct 8 00:18:28 2009 (r41758)
@@ -5,7 +5,7 @@
use strict;
use warnings;
-use Test::More qw(no_plan); # tests => 28;
+use Test::More tests => 14;
use Carp;
use lib qw( lib t/configure/testlib );
use_ok('config::auto::llvm');
@@ -36,88 +36,35 @@
my $step = test_step_constructor_and_description($conf);
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
-ok(defined($step->result()), "Result was defined");
-#ok($possible_llvm{$conf->data->get('llvm')},
-# "Acceptable value for 'llvm' attribute was set");
-#
-#$conf->replenish($serialized);
-#
-########### --verbose ##########
-#
-#($args, $step_list_ref) = process_options( {
-# argv => [ q{--verbose} ],
-# mode => q{configure},
-#} );
-#$conf->options->set( %{$args} );
-#$step = test_step_constructor_and_description($conf);
-#{
-# my $stdout;
-# my $ret = capture(
-# sub { $step->runstep($conf) },
-# \$stdout
-# );
-# ok( $ret, "runstep() returned true value" );
-# ok( defined $step->result(), "Result was defined");
-# ok($possible_llvm{$conf->data->get('llvm')},
-# "Acceptable value for 'llvm' attribute was set");
-#}
-#
-#$conf->replenish($serialized);
-#
-########### _evaluate_llvm() ##########
-#
-#($args, $step_list_ref) = process_options( {
-# argv => [ ],
-# mode => q{configure},
-#} );
-#$conf->options->set( %{$args} );
-#$step = test_step_constructor_and_description($conf);
-#
-#$conf->replenish($serialized);
-#
-#my $pseudo_llvm;
-#$pseudo_llvm = q{alpha};
-#$step->_evaluate_llvm($conf, $pseudo_llvm, 1);
-#is($conf->data->get('llvm'), $pseudo_llvm,
-# "'llvm' attribute was set as expected");
-#is($step->result(), q{yes}, "Got expected result");
-#
-#$pseudo_llvm = q{alpha};
-#$step->_evaluate_llvm($conf, $pseudo_llvm, 0);
-#is($conf->data->get('llvm'), 'llvm',
-# "'llvm' attribute was set as expected");
-#is($step->result(), q{no}, "Got expected result");
-#
-#$conf->replenish($serialized);
-#
-########### _probe_for_llvm_output() ##########
-#
-#($args, $step_list_ref) = process_options( {
-# argv => [ ],
-# mode => q{configure},
-#} );
-#$conf->options->set( %{$args} );
-#$step = test_step_constructor_and_description($conf);
-#ok(auto::llvm::_probe_for_llvm_output('Exuberant Ctags', 0),
-# "Probe returned true when output matched");
-#ok(! auto::llvm::_probe_for_llvm_output('alpha', 0),
-# "Probe returned false when output matched");
-#{
-# my $stdout;
-# my $rv = capture(
-# sub { auto::llvm::_probe_for_llvm_output('Exuberant Ctags', 1) },
-# \$stdout
-# );
-# ok($rv, "Probe returned true when output matched");
-#}
-#{
-# my $stdout;
-# my $rv = capture(
-# sub { auto::llvm::_probe_for_llvm_output('alpha', 1) },
-# \$stdout
-# );
-# ok(! $rv, "Probe returned false when output matched");
-#}
+like( $step->result(), qr/yes|no/,
+ "Result was either 'yes' or 'no'" );
+
+$conf->replenish($serialized);
+
+########## --verbose ##########
+
+($args, $step_list_ref) = process_options( {
+ argv => [ q{--verbose} ],
+ mode => q{configure},
+} );
+$conf->options->set( %{$args} );
+$step = test_step_constructor_and_description($conf);
+{
+ my $stdout;
+ my $ret = capture(
+ sub { $step->runstep($conf) },
+ \$stdout
+ );
+ 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" );
+}
+
+$conf->replenish($serialized);
pass("Completed all tests in $0");
@@ -137,7 +84,7 @@
=head1 AUTHOR
-Paul Cochrane <paultcochrane at gmail dot com>
+James E Keenan
=cut
More information about the parrot-commits
mailing list