diff --git a/config/auto/cpu/amd64/auto.pm b/config/auto/cpu/amd64/auto.pm index 5ba74a2446..a540901d33 100644 --- a/config/auto/cpu/amd64/auto.pm +++ b/config/auto/cpu/amd64/auto.pm @@ -20,15 +20,18 @@ sub runstep { # AMD64 on gcc has cmpxchg my $gcc = $conf->data->get('gccversion'); - $conf->debug("gccversion: $gcc\n"); if ( defined $gcc ) { + $conf->debug("gccversion: $gcc\n"); # HAS_foo defines PARROT_HAS_`uc foo` $conf->data->set( "HAS_I386_gcc_cmpxchg" => '1', "HAS_AMD64_gcc_cmpxchg" => '1', ); $conf->debug(" (gcc_cmpxchg)\n"); - } + } + else { + $conf->debug("gccversion: (none)\n"); + } } 1; diff --git a/config/auto/msvc.pm b/config/auto/msvc.pm index 4618a6e331..892ecb64ab 100644 --- a/config/auto/msvc.pm +++ b/config/auto/msvc.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2005-2007, Parrot Foundation. +# Copyright (C) 2005-2015, Parrot Foundation. =head1 NAME @@ -38,9 +38,7 @@ sub runstep { return 1; } my $msvcref = _probe_for_msvc($conf); - $self->_evaluate_msvc($conf, $msvcref); - return 1; } @@ -74,12 +72,10 @@ sub _evaluate_msvc { return 1 if $status; my $msvcversion = $self->_compose_msvcversion($major, $minor); - $conf->data->set( msvcversion => $msvcversion ); # Add Visual C++ specifics here if ( $msvcversion >= 14.00 ) { - # Version 14 (aka Visual C++ 2005) warns about unsafe, deprecated # functions with the following message. # diff --git a/config/init/hints/mswin32.pm b/config/init/hints/mswin32.pm index ea41e213b2..a36494724b 100644 --- a/config/init/hints/mswin32.pm +++ b/config/init/hints/mswin32.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2005-2014, Parrot Foundation. +# Copyright (C) 2005-2015, Parrot Foundation. package init::hints::mswin32; @@ -32,15 +32,17 @@ sub runstep { ); my $build_dir = $conf->data->get('build_dir'); - if ( $build_dir =~ /\s/ ) { - $conf->data->set( build_dir => Win32::GetShortPathName($build_dir) ); + $build_dir = Win32::GetShortPathName($build_dir); + $conf->debug(" build_dir => $build_dir, "); + $conf->data->set( build_dir => $build_dir ); } my $bindir = $conf->data->get('bindir'); - if ( $bindir =~ /\s/ ) { - $conf->data->set( bindir => Win32::GetShortPathName($bindir) ); + $bindir = Win32::GetShortPathName($bindir); + $conf->debug(" bindir => $bindir, "); + $conf->data->set( bindir => $bindir ); } $conf->data->set( clock_best => ' ' ); @@ -60,15 +62,6 @@ sub runstep { my $cc_output = `$cc /? 2>&1` || ''; $ccflags =~ s/-O1 // if $cc_output =~ m/Standard/ || $cc_output =~ m{/ZI}; unless ($msvcversion) { $cc_output =~ m/Version (\d+)/; $msvcversion = $1; } - $ccflags =~ s/-Gf/-GF/ if $msvcversion >= 13; - - # override perl's warnings level - $ccflags =~ s/-W\d/-W4/; - - # if we want pbc_to_exe to work, need to let some versions of the - # compiler use more memory than they normally would - $ccflags .= " -Zm1500 " if $msvcversion < 13; - my $ccwarn = ''; # disable certain very noisy warnings if ($msvcversion >= 13) { @@ -78,6 +71,49 @@ sub runstep { } my $disable_static = $conf->options->get('disable-static'); + my $debugging = $conf->options->get('debugging'); + my $optimize = $conf->data->get('optimize_provisional'); + + # 'link' needs to be link.exe, not cl.exe. + # This makes 'link' and 'ld' the same. + # Note that on win64 we mostly only have a strawberry perl, thus g++ as ld. + my $ld = $conf->option_or_data('ld'); + my $ldflags = $conf->option_or_data('ldflags'); + if ($ld =~ /g\+\+/) { + # now we are sure that we have to convert from a strawberry mingw perl to msvc + if ($ccflags !~ /nologo/) { + $ccflags = "-nologo -GF -W4 -MD -DWIN32 -D_CONSOLE -DNO_STRICT"; + $optimize =~ s/-s //; + $optimize =~ s/-O3/-O2/; + $conf->debug(" optimize => '$optimize', "); + $conf->data->set('optimize_provisional', $optimize); + } + $ld = 'link'; + $conf->data->set( ld => $ld ); + my $link = $conf->options->get('link'); + $conf->data->set( link => $ld ) unless $link; + if ($link =~ /cl(\.exe)?$/i) { + $conf->data->set( link => $ld ); + $conf->debug(" link => '$ld', "); + } + $conf->debug(" ld => '$ld', "); + $conf->debug(" ldflags => '$ldflags', "); + } + + $ccflags =~ s/-Gf/-GF/ if $msvcversion >= 13; + # override perl's warnings level + $ccflags =~ s/-W\d/-W4/; + # if we want pbc_to_exe to work, need to let some versions of the + # compiler use more memory than they normally would + $ccflags .= " -Zm1500 " if $msvcversion < 13; + + $conf->data->set( cxx => $conf->data->get('cc') ) unless $conf->options->get('cxx'); + my $linkflags = $ldflags; + # advapi32 needed for src/platform/win32/entropy.c + my $libs = 'kernel32.lib ws2_32.lib msvcrt.lib oldnames.lib advapi32.lib '; + $conf->debug(" ccflags => '$ccflags', "); + $conf->debug(" libs => '$libs', "); + $conf->data->set( share_ext => '.dll', load_ext => '.dll', @@ -85,21 +121,21 @@ sub runstep { o => '.obj', cc_o_out => '-Fo', cc_exe_out => '-out:', - cc_ldflags => '/link', + cc_ldflags => '-link', make_c => q{$(PERL) -e "chdir shift @ARGV;} . q{system '$(MAKE)', '-nologo', @ARGV; exit $$? >> 8;"}, make => 'nmake', - # ZI messes with __LINE__ + # ZI messes with __LINE__, /Z7 is preferred for gdb cc_debug => '-Zi', ld_debug => '-debug', ld_share_flags => '-dll', ld_load_flags => '-dll', ld_out => '-out:', - ldflags => '-nologo -nodefaultlib', - # advapi32 needed for src/platform/win32/entropy.c - libs => 'kernel32.lib ws2_32.lib msvcrt.lib oldnames.lib advapi32.lib ', + ldflags => $ldflags, + linkflags => $linkflags, + libs => $libs, libparrot_static => $disable_static ? '' : 'libparrot' . $conf->data->get('a'), libparrot_shared => "libparrot$share_ext", ar => 'lib', @@ -123,12 +159,8 @@ sub runstep { $conf->data->set( inst_libparrot_ldflags => "\"$bindir\\libparrot.lib\"" ); $conf->data->set( inst_libparrot_linkflags => "\"$bindir\\libparrot.lib\"" ); - # 'link' needs to be link.exe, not cl.exe. - # This makes 'link' and 'ld' the same. - $conf->data->set( link => $conf->data->get('ld') ); - # We can't use -opt: and -debug together. - if ( $conf->data->get('ld_debug') =~ /-debug/ ) { + if ( $debugging ) { my $linkflags = $conf->option_or_data('linkflags'); $linkflags =~ s/-opt:\S+//; $conf->data->set( linkflags => $linkflags ); @@ -142,7 +174,7 @@ sub runstep { o => '.obj', cc_o_out => '-Fo', cc_exe_out => '-out:', - cc_ldflags => '/link', + cc_ldflags => '-link', # ZI messes with __LINE__ cc_debug => '-Zi', diff --git a/config/inter/progs.pm b/config/inter/progs.pm index b922b2d499..e886a9556d 100644 --- a/config/inter/progs.pm +++ b/config/inter/progs.pm @@ -35,19 +35,16 @@ sub runstep { my $ask = _prepare_for_interactivity($conf); - my $cc; - ($conf, $cc) = _get_programs($conf, $ask); + _get_programs($conf, $ask); my $debug = _get_debug($conf, $ask); my $debug_validity = _is_debug_setting_valid($debug); return unless defined $debug_validity; - $conf = _set_debug_and_warn($conf, $debug); + _set_debug_and_warn($conf, $debug); - # Beware! Inside test_compiler(), cc_build() and cc_run() both silently - # reference the Parrot::Configure object ($conf) at its current state. - test_compiler($conf, $cc); + test_compiler($conf); return 1; } @@ -89,8 +86,7 @@ sub _get_programs { $ld = prompt( "What program do you want to use to build shared libraries?", $ld ) if $ask; $conf->data->set( ld => $ld ); - $ccflags = integrate( $conf->data->get('ccflags'), - $conf->options->get('ccflags') ); + $ccflags = integrate( $conf->data->get('ccflags'), $conf->options->get('ccflags') ); # Remove some perl5-isms. $ccflags =~ s/-D((PERL|HAVE)_\w+\s*|USE_PERLIO)//g; @@ -140,7 +136,6 @@ sub _get_programs { $cxx = integrate( $conf->data->get('cxx'), $conf->options->get('cxx') ); $cxx = prompt( "What C++ compiler do you want to use?", $cxx ) if $ask; $conf->data->set( cxx => $cxx ); - return ($conf, $cc); } sub _get_debug { @@ -178,19 +173,28 @@ sub _set_debug_and_warn { } sub test_compiler { - my ($conf, $cc) = @_; + my ($conf) = @_; + my ($cc, $link) = $conf->data->get('cc', 'link'); open( my $out_fh, '>', "test_$$.c" ) or die "Unable to open 'test_$$.c': $@\n"; print {$out_fh} < int main() { + puts("ok"); return 0; } END_C close $out_fh; + $conf->debug("\ncc=$cc, link=$link\n"); unless ( eval { $conf->cc_build(); 1 } ) { - warn "Compilation failed with '$cc'\n"; + if ($cc eq $link) { + warn "Compilation failed with '$cc''\n"; + } + else { + warn "Compilation failed with '$cc' and '$link'\n"; + } exit 1; } diff --git a/lib/Parrot/Configure/Compiler.pm b/lib/Parrot/Configure/Compiler.pm index 777fe61886..1e6b7f6919 100644 --- a/lib/Parrot/Configure/Compiler.pm +++ b/lib/Parrot/Configure/Compiler.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2014, Parrot Foundation. +# Copyright (C) 2001-2015, Parrot Foundation. =head1 NAME @@ -86,6 +86,8 @@ These items are used from current config settings: Calls the compiler and linker on F. +Returns the last error code. + =cut sub cc_build { @@ -117,6 +119,7 @@ sub cc_build { if ($link_result) { return $link_result; } + return undef; } =item C @@ -126,6 +129,8 @@ sub cc_build { Calls the F (or F) executable. Any output is directed to F. +Returns the captured stdout, and in array context with the additional exit code. + =cut sub cc_run { @@ -146,8 +151,7 @@ sub cc_run { } my $output = _slurp("./$test.out"); - - return $output; + return wantarray ? ($output, $run_error) : $output; } =item C @@ -157,6 +161,9 @@ sub cc_run { Same as C except that warnings and errors are also directed to F. +Returns the captured stdout combined with stderr, and in array context +with the additional exit code. + =cut sub cc_run_capture { @@ -165,18 +172,18 @@ sub cc_run_capture { my $slash = $conf->data->get('slash'); my $verbose = $conf->options->get('verbose'); my $test = 'test_' . $$; + my $run_error; if ( defined( $_[0] ) && length( $_[0] ) ) { local $" = ' '; - _run_command( ".${slash}$test${exe} @_", "./$test.out", "./$test.out", $verbose ); + $run_error = _run_command( ".${slash}$test${exe} @_", "./$test.out", "./$test.out", $verbose ); } else { - _run_command( ".${slash}$test${exe}", "./$test.out", "./$test.out", $verbose ); + $run_error = _run_command( ".${slash}$test${exe}", "./$test.out", "./$test.out", $verbose ); } my $output = _slurp("./$test.out"); - - return $output; + return wantarray ? ($output, $run_error) : $output; } =item C @@ -192,7 +199,7 @@ sub cc_clean { ## no critic Subroutines::RequireFinalReturn unlink map "test_${$}$_", qw( .c .cco .ldo .out ), $conf->data->get(qw( o exe )), # MSVC - qw( .exe.manifest .ilk .pdb ); + ($^O eq 'MSWin32' ? qw( .exe.manifest .ilk .pdb ) : ()); } =item C diff --git a/src/packfile/pf_items.c b/src/packfile/pf_items.c index b8e588a9df..4eb4f15e5f 100644 --- a/src/packfile/pf_items.c +++ b/src/packfile/pf_items.c @@ -606,9 +606,15 @@ cvt_num16_num8(ARGOUT(unsigned char *dest), ARGIN(const unsigned char *src)) # ifdef __LCC__ int expo2; # endif - Parrot_x_force_error_exit(NULL, 1, "cvt_num16_num8: long double conversion unsupported"); - /* Have only 12-byte long double, or no long double at all. Need to disect it */ +#if !PARROT_BIGENDIAN + /* assume intel 10-byte padded to 16 byte, not a true __float128 */ + cvt_num12_num8(dest, src); + return; +#endif + /*Parrot_x_force_error_exit(NULL, 1, "cvt_num16_num8: long double conversion unsupported");*/ + + /* Have only 10/12-byte long double, or no long double at all. Need to disect it */ /* 16-byte double (128 bits): @@ -827,7 +833,7 @@ cvt_num12_num8_le(ARGOUT(unsigned char *dest), ARGIN(const unsigned char *src)) unsigned char b[12]; fetch_buf_le_12(b, src); /* TODO test endianize */ cvt_num12_num8(dest, b); - Parrot_x_force_error_exit(NULL, 1, "cvt_num12_num8_le: long double conversion unsupported"); + /*Parrot_x_force_error_exit(NULL, 1, "cvt_num12_num8_le: long double conversion unsupported");*/ } #endif @@ -853,7 +859,7 @@ cvt_num16_num8_le(ARGOUT(unsigned char *dest), ARGIN(const unsigned char *src)) unsigned char b[16]; fetch_buf_le_16(b, src); cvt_num16_num8(dest, b); - Parrot_x_force_error_exit(NULL, 1, "cvt_num16_num8_le: long double conversion unsupported"); + /*Parrot_x_force_error_exit(NULL, 1, "cvt_num16_num8_le: long double conversion unsupported");*/ } #endif