Skip to content

Commit

Permalink
Merge branch 'smoke-me/win64-msvc-gh1190'
Browse files Browse the repository at this point in the history
Passed all tests
  • Loading branch information
Reini Urban committed Jan 27, 2015
2 parents 08c8222 + b02d825 commit 8e5a8c3
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 55 deletions.
7 changes: 5 additions & 2 deletions config/auto/cpu/amd64/auto.pm
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions config/auto/msvc.pm
@@ -1,4 +1,4 @@
# Copyright (C) 2005-2007, Parrot Foundation.
# Copyright (C) 2005-2015, Parrot Foundation.

=head1 NAME
Expand Down Expand Up @@ -38,9 +38,7 @@ sub runstep {
return 1;
}
my $msvcref = _probe_for_msvc($conf);

$self->_evaluate_msvc($conf, $msvcref);

return 1;
}

Expand Down Expand Up @@ -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.
#
Expand Down
82 changes: 57 additions & 25 deletions 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;

Expand Down Expand Up @@ -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 => ' ' );
Expand All @@ -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) {
Expand All @@ -78,28 +71,71 @@ 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',
a => '.lib',
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',
Expand All @@ -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 );
Expand All @@ -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',
Expand Down
26 changes: 15 additions & 11 deletions config/inter/progs.pm
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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} <<END_C;
#include <stdio.h>
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;
}

Expand Down
23 changes: 15 additions & 8 deletions lib/Parrot/Configure/Compiler.pm
@@ -1,4 +1,4 @@
# Copyright (C) 2001-2014, Parrot Foundation.
# Copyright (C) 2001-2015, Parrot Foundation.

=head1 NAME
Expand Down Expand Up @@ -86,6 +86,8 @@ These items are used from current config settings:
Calls the compiler and linker on F<test_$$.c>.
Returns the last error code.
=cut

sub cc_build {
Expand Down Expand Up @@ -117,6 +119,7 @@ sub cc_build {
if ($link_result) {
return $link_result;
}
return undef;
}

=item C<cc_run()>
Expand All @@ -126,6 +129,8 @@ sub cc_build {
Calls the F<test> (or F<test.exe>) executable. Any output is directed to
F<test.out>.
Returns the captured stdout, and in array context with the additional exit code.
=cut

sub cc_run {
Expand All @@ -146,8 +151,7 @@ sub cc_run {
}

my $output = _slurp("./$test.out");

return $output;
return wantarray ? ($output, $run_error) : $output;
}

=item C<cc_run_capture()>
Expand All @@ -157,6 +161,9 @@ sub cc_run {
Same as C<cc_run()> except that warnings and errors are also directed to
F<test.out>.
Returns the captured stdout combined with stderr, and in array context
with the additional exit code.
=cut

sub cc_run_capture {
Expand All @@ -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<cc_clean()>
Expand All @@ -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<shebang_mod()>
Expand Down
14 changes: 10 additions & 4 deletions src/packfile/pf_items.c
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 8e5a8c3

Please sign in to comment.