Permalink
Browse files

Merge branch 'rurban/llvm-gh853' of github.com:parrot/parrot into rur…

…ban/llvm-gh853

Fixed conflicts: (in favor of rurban/llvm-gh853)
	config/auto/llvm.pm
	t/steps/auto/llvm-01.t
  • Loading branch information...
2 parents c59b533 + 132f7c7 commit 25ee7936972247c79c5867fde856be9d4e6cfcfd Reini Urban committed Oct 2, 2012
View
@@ -22,7 +22,10 @@
have been fixed. There are only some remaining platforms errors on
darwin/x86.
- Libraries
- + Fixed Mime/Base64 encode_base64. Split long lines at 76 chars. [GH #826]
+ + Fixed Mime::Base64: Split long lines at 76 chars. [GH #826]
+ Support multi-byte codepoints. Use binary encoding,
+ encoded files are now endian specific [GH #813 + #814],
+ Added 2nd optional encoding arg to decode_base64().
- Documentation
+ Cleaned up removed parrot cmdline options -D/-O/-v from --help output and
running.pod [GH #838]
View
@@ -583,6 +583,8 @@ examples/library/getopt_demo.pir [examples]
examples/library/md5sum.pir [examples]
examples/library/ncurses_life.pir [examples]
examples/library/pcre.pir [examples]
+examples/library/utf8_base64.pir [examples]
+examples/library/utf8_base64.pl [examples]
examples/mops/README.pod [examples]
examples/mops/mops.c [examples]
examples/mops/mops.cs [examples]
@@ -1731,6 +1733,7 @@ t/library/llvm/99-example.t [test]
t/library/lwp.t [test]
t/library/md5.t [test]
t/library/mime_base64.t [test]
+t/library/mime_base64u.t [test]
t/library/nciutils.t [test]
t/library/osutils.t [test]
t/library/p6object.t [test]
@@ -2020,6 +2023,7 @@ t/src/misc.t [test]
t/src/pointer_array.t [test]
t/src/threads_io.t [test]
t/src/warnings.t [test]
+t/steps/auto/alignof-01.t [test]
t/steps/auto/arch-01.t [test]
t/steps/auto/attributes-01.t [test]
t/steps/auto/backtrace-01.t [test]
View
@@ -6,9 +6,10 @@ config/auto/alignof.pm - clang++ offsetof values
=head1 DESCRIPTION
-Determines the offsetof() values of our types, if the compiler cannot do compile-time ALIGNOF
-definitions via offsetof(). clang++ or strict C++ compilers need this step, to calculate these
-pre-compiled PARROT_ALIGNOF_* definitions.
+Determines the offsetof() values of our types, if the compiler cannot do
+compile-time ALIGNOF definitions via offsetof(). clang++ or strict C++
+compilers need this step, to calculate these pre-compiled PARROT_ALIGNOF_*
+definitions.
=cut
@@ -34,11 +35,11 @@ sub runstep {
# This step only needed for clang++
if (test_if_needed($conf)) {
- # Can do compile-time ALIGNOF definitions via offsetof()
- $conf->data->set( 'HAS_COMPILER_OFFSETOF_ALIGNOF' => 1 );
+ # Can do compile-time ALIGNOF definitions via offsetof()
+ $conf->data->set( 'HAS_COMPILER_OFFSETOF_ALIGNOF' => 1 );
$conf->debug("DEBUG: auto::alignof is only needed for clang++\n");
$self->set_result('skipped');
- return 1;
+ return 1;
}
# Need pre-compiled PARROT_ALIGNOF_* definitions
$conf->data->set( 'HAS_COMPILER_OFFSETOF_ALIGNOF' => 0 );
@@ -81,6 +82,7 @@ sub runstep {
}
}
$conf->data->set( 'alignof' => $alignof );
+ $self->set_result('done');
return 1;
}
@@ -90,6 +92,7 @@ sub runstep {
sub test_if_needed {
my ($conf) = @_;
+ $conf->data->set( TEMP_type => 'int' );
my ($cc_inc, $ccflags) = $conf->data->get( 'cc_inc', 'ccflags' );
$conf->cc_gen('config/auto/alignof/test_c.in');
eval { $conf->cc_build("$cc_inc -DCHECK_COMPILER_OFFSETOF_ALIGNOF") };
View
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2011, Parrot Foundation.
+# Copyright (C) 2009-2012, Parrot Foundation.
=head1 NAME
@@ -46,13 +46,21 @@ sub runstep {
# runstep() with a value of 1. If a given probe does not rule out LLVM,
# we will proceed onward.
- my ($llvm_bindir, $llvm_config);
- for my $bin (qw(llvm-config llvm-config-3.0 llvm-config-2.9 llvm-config-2.8)) {
- $llvm_bindir = capture_output( $bin, "--bindir" ) || '';
+ my $llvm_config = $conf->options->get( 'llvm-config' );
+ my $llvm_bindir;
+ if ( $llvm_config and -e "$llvm_config" ) {
+ $llvm_bindir = capture_output( $llvm_config, "--bindir" ) || '';
chomp $llvm_bindir;
- if ( $llvm_bindir ) {
- $llvm_config = $bin;
- last;
+ }
+ else {
+ for my $ver ('',qw(-3.2 -3.1 -3.0 -2.9 -2.8 -2.7)) {
+ my $bin = 'llvm-config'.$ver;
+ $llvm_bindir = capture_output( $bin, "--bindir" ) || '';
+ chomp $llvm_bindir;
+ if ( $llvm_bindir ) {
+ $llvm_config = $bin;
+ last;
+ }
}
}
if (! $llvm_bindir ) {
@@ -65,31 +73,25 @@ sub runstep {
chomp(@output = `"$llvm_bindir/lli" --version`);
my $rv = $self->version_check($conf, \@output, $verbose);
return 1 unless $rv;
+ my $version = $rv;
- # Find lib
- my $ldd = `ldd "$llvm_bindir/lli"`;
- if ($ldd =~ /(libLLVM[^ ]+)(.*)/m){
- my $lib = $1;
- my $path = (split(' ',$2))[1];
- $conf->data->set( llvm_shared => $path );
- if ($lib =~ /lib(LLVM.*)\.(so|dll)/){
- $conf->data->add( ' ', libs => "-l$1" );
- }
- else {
- if ($verbose) {
- print "Found 'lli' version $version\n";
- }
- }
+ # Find flags
+ my ($cflags, $cxxflags, $ldflags, $libs);
+ if ($ldflags = $self->_llvm_config($llvm_config, '--ldflags')) {
+ $conf->data->set( llvm_ldflags => $ldflags );
}
- else {
- print "Unable to extract version for LLVM component 'lli'\n"
- if $verbose;
- $self->_handle_result( $conf, 0 );
- return 1;
+ if ($libs = $self->_llvm_config($llvm_config, '--libs')) {
+ $conf->data->set( llvm_libs => $libs );
+ }
+ if ($cflags = $self->_llvm_config($llvm_config, '--cflags')) {
+ $conf->data->set( llvm_cflags => $cflags );
+ }
+ if ($cxxflags = $self->_llvm_config($llvm_config, '--cxxflags')) {
+ $conf->data->set( llvm_cxxflags => $cxxflags );
}
- $self->_handle_result($conf, $rv);
- return 1;
+ # $self->_handle_result($conf, $version);
+ # return 1;
# Having gotten this far, we will take a simple C file, compile it into
# an LLVM bitcode file, execute it as bitcode, then compile it to native
@@ -103,11 +105,22 @@ sub runstep {
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});
- };
- $rv = '';
- if ($@) {
+ unlink $bcfile;
+ for my $cc ($conf->data->get('cc'),
+ "$llvm_bindir/clang", "$llvm_bindir/llvm-gcc",
+ qw(llvm-gcc clang))
+ {
+ # Note: gcc and g++ with -c just skips over -emit-llvm and produce native code
+ # without -c: ld: warning: cannot find entry symbol 'mit-llvm'
+ eval {
+ system(qq{$cc -emit-llvm -O3 $fullcfile -c -o $bcfile});
+ };
+ if (!$@ and -e $bcfile and $self->_check_bcfile($bcfile)) {
+ $conf->data->set( llvm_gcc => $cc );
+ last;
+ }
+ }
+ if (! $conf->data->get( 'llvm_gcc' )) {
$rv = $self->_handle_failure_to_compile_into_bitcode(
$conf,
$verbose,
@@ -120,7 +133,7 @@ sub runstep {
else {
my $output;
eval {
- $output = capture_output( 'lli', $bcfile );
+ $output = capture_output( "$llvm_bindir/lli", $bcfile );
};
if ( $@ or $output !~ /hello world/ ) {
$rv = $self->_handle_failure_to_execute_bitcode( $conf, $verbose );
@@ -131,7 +144,7 @@ sub runstep {
}
else {
eval {
- system(qq{llc $bcfile -o $sfile});
+ system(qq{"$llvm_bindir/llc" $bcfile -o $sfile});
};
if ( $@ or (! -e $sfile) ) {
$rv = $self->_handle_failure_to_compile_to_assembly(
@@ -163,7 +176,7 @@ sub runstep {
$output = capture_output(qq{./$nativefile});
};
$self->_handle_native_assembly_output(
- $conf, $output, $verbose
+ $conf, $output, $verbose, $version
);
}
}
@@ -177,10 +190,26 @@ sub runstep {
return 1;
}
+sub _check_bcfile {
+ my ($self, $bcfile) = @_;
+ open my $fh, '<', $bcfile or return;
+ my $read = read $fh, my $bytes, 2;
+ my $result = 1 if $read == 2 and $bytes eq 'BC';
+ close $fh;
+ return $result;
+}
+
+sub _llvm_config {
+ my ($self, $llvm_config, $arg) = @_;
+ my $result = `"$llvm_config" $arg`;
+ chomp $result;
+ return $result;
+}
+
sub version_check {
my ($self, $conf, $outputref, $verbose) = @_;
my $version;
- if ( $outputref->[1] =~ m/llvm\sversion\s(\d+\.\d+)/s ) {
+ if ( $outputref->[1] =~ m/llvm\sversion\s(\d+\.\d+)/is ) {
$version = $1;
if ($version < $self->{lli_min_version}) {
if ($verbose) {
@@ -238,7 +267,12 @@ sub _handle_failure_to_assemble_assembly {
sub _handle_result {
my ($self, $conf, $result) = @_;
if ( $result ) {
- $self->set_result( "yes, ".$result );
+ if ($result == 1) {
+ $self->set_result( "yes" );
+ }
+ else {
+ $self->set_result( "yes, ".$result );
+ }
$conf->data->set( has_llvm => 1 );
}
else {
@@ -249,14 +283,14 @@ sub _handle_result {
}
sub _handle_native_assembly_output {
- my ($self, $conf, $output, $verbose) = @_;
+ my ($self, $conf, $output, $verbose, $rv) = @_;
if ( $@ or ( $output !~ /hello world/ ) ) {
print "Unable to execute native assembly program successfully\n"
if $verbose;
$self->_handle_result( $conf, 0 );
}
else {
- $self->_handle_result( $conf, 1 );
+ $self->_handle_result( $conf, $rv );
}
}
@@ -276,7 +310,7 @@ sub _cleanup_llvm_files {
=head1 AUTHOR
-James E Keenan
+James E Keenan, Reini Urban
=cut
View
@@ -43,16 +43,19 @@ sub runstep {
$parrot_is_shared = 0 unless $conf->data->get('has_dynamic_linking');
# Parrot can't necessarily handle a pre-existing installed shared
- # libparrot.so. At this point, we don't know the actual name
- # of the shared parrot library. So we try some candidates.
+ # libparrot.so without rpath.
+ # At this point, we don't know the actual name of the shared parrot
+ # library. So we try some candidates.
my @libs = get_libs();
my @libpaths = get_libpaths($conf);
- foreach my $f (@libs) {
- foreach my $d (@libpaths) {
- my $oldversion = File::Spec->catfile($d, $f);
- if (-e $oldversion) {
- warn("\nWarning: Building a shared parrot library may conflict " .
- "with your previously-installed $oldversion\n");
+ if ($disable_rpath or !$conf->data->get('rpath')) {
+ foreach my $f (@libs) {
+ foreach my $d (@libpaths) {
+ my $oldversion = File::Spec->catfile($d, $f);
+ if (-e $oldversion) {
+ warn("\nWarning: Building a shared parrot library may conflict " .
+ "with your previously-installed $oldversion\n");
+ }
}
}
}
@@ -0,0 +1,57 @@
+#!./parrot
+# Copyright (C) 2012, Parrot Foundation.
+
+=head1 NAME
+
+examples/mime_base64/utf_base64.pir - Conformant MIME::Base64 utf8 handling
+
+=head1 SYNOPSIS
+
+ % ./parrot examples/mime_base64/utf_base64.pir
+
+=head1 DESCRIPTION
+
+Compare conformant coreutils C<base64> and F<examples/mime_base64/utf_base64.pl>
+against ours.
+See L<https://github.com/parrot/parrot/issues/814>
+
+=cut
+
+.sub main :main
+ load_bytecode 'MIME/Base64.pbc'
+
+ .local pmc enc_sub
+ enc_sub = get_global [ "MIME"; "Base64" ], 'encode_base64'
+
+ .local string result_encode
+ # GH 814
+ result_encode = enc_sub(utf8:"\x{a2}")
+ say "encode: utf8:\"\\x{a2}\""
+ say "expected: wqI="
+ print "result: "
+ say result_encode
+
+ # GH 813
+ result_encode = enc_sub(utf8:"\x{203e}")
+ say "encode: utf8:\"\\x{203e}\""
+ say "expected: 4oC+"
+ print "result: "
+ say result_encode
+
+.end
+
+=head1 AUTHOR
+
+ronaldxs
+
+=head1 SEE ALSO
+
+F<examples/mime_base64/utf8_base64.pl>,
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
Oops, something went wrong.

0 comments on commit 25ee793

Please sign in to comment.