Index: parrot-svn/config/gen/makefiles/dynpmc_pl.in =================================================================== --- parrot-svn.orig/config/gen/makefiles/dynpmc_pl.in 2009-02-12 17:03:46.828125000 +0000 +++ parrot-svn/config/gen/makefiles/dynpmc_pl.in 2009-02-12 17:05:24.937500000 +0000 @@ -86,13 +86,6 @@ $extraLibs =~ s/\Q$(A)\E/.lib/g; $liblist .= ' ' . $extraLibs; - # Also note that we may need to look in the Parrot blib directory. - if ($CC =~ /gcc/i) { - $liblist .= qq{ -Wl,-L "@build_dir@/blib/lib"}; - } - else { - $liblist .= qq{ /LIBPATH:"@build_dir@/blib/lib"}; - } } else { $liblist = join( ' ', map { "-l$_" } keys %$libs ); Index: parrot-svn/config/gen/makefiles/root.in =================================================================== --- parrot-svn.orig/config/gen/makefiles/root.in 2009-02-12 17:03:46.829125000 +0000 +++ parrot-svn/config/gen/makefiles/root.in 2009-02-12 17:24:58.296875000 +0000 @@ -480,8 +480,11 @@ # Libraries LIBPARROT_STATIC = @blib_dir@/@libparrot_static@ #IF(darwin):export DYLD_LIBRARY_PATH := @blib_dir@:$(DYLD_LIBRARY_PATH) -#IF(win32):LIBPARROT_SHARED = @libparrot_shared@ -#ELSE:LIBPARROT_SHARED = @blib_dir@/@libparrot_shared@ +#IF(win32 or cygwin):LIBPARROT_SHARED = @libparrot_shared@ +#ELSE:LIBPARROT_SHARED = @blib_dir@/@libparrot_shared@ +#IF(importlib):IMPLIB_OUT = @implib_out@ +#IF(importlib):IMPORTLIB = @blib_dir@/@importlib@ +#ELSE:IMPORTLIB = # This line controls whether a static or shared library is built LIBPARROT = @libparrot@ @@ -845,7 +848,7 @@ PARROT_LIBS: \ #IF(has_static_linking): $(LIBPARROT_STATIC) \ -#IF(has_dynamic_linking): $(LIBPARROT_SHARED) +#IF(has_dynamic_linking): $(LIBPARROT_SHARED) $(LIBPARROT_STATIC) : $(O_FILES) $(MKPATH) @blib_dir@ @@ -856,8 +859,7 @@ $(LIBPARROT_SHARED) : $(O_FILES) $(MKPATH) @blib_dir@ $(LD) $(LD_SHARE_FLAGS) $(LDFLAGS) @ld_out@$@ @libparrot_soname@ \ -#IF(cygwin): -Wl,--out-implib=libparrot.dll.a \ -#IF(win32 and cc==gcc): -Wl,--out-implib=libparrot.lib \ +#IF(importlib): $(IMPLIB_OUT)$(IMPORTLIB) \ $(O_FILES) $(C_LIBS) $(ICU_SHARED) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2 #IF(libparrot_shared_alias): ( cd @blib_dir@ ; ln -sf @libparrot_shared@ @libparrot_shared_alias@ ) @@ -1595,13 +1597,16 @@ $(PARROT) \ $(MINIPARROT) \ $(LIBPARROT) \ +#IF(importlib): $(IMPORTLIB) \ $(INSTALLABLEPARROT) \ $(INSTALLABLEDIS) \ $(INSTALLABLEPDUMP) \ $(INSTALLABLEPINFO) \ $(INSTALLABLEPBCMERGE) \ $(INSTALLABLEPDB) \ + $(INSTALLABLECONFIG) \ pbc_to_exe.pbc pbc_to_exe.c pbc_to_exe$(O) pbc_to_exe$(EXE) \ + parrot_config$(O) parrot_config.pbc parrot_config.c parrot_config$(EXE) \ $(IMCC_DIR)/main$(O) \ $(PDUMP) $(SRC_DIR)/pbc_dump$(O) $(SRC_DIR)/packdump$(O) \ $(SRC_DIR)/pbc_info$(O) $(PINFO) \ @@ -1672,57 +1677,34 @@ $(RM_F) \ "$(DYNEXT_DIR)/*$(LOAD_EXT)" \ "$(DYNEXT_DIR)/*$(SHARE_EXT)" \ - "$(DYNEXT_DIR)/*.lib" \ - "*.pdb" "$(DYNEXT_DIR)/*.pdb" \ - "*.ilk" "$(DYNEXT_DIR)/*.ilk" \ - "*.exp" "$(DYNEXT_DIR)/*.exp" \ - "*.def" "$(DYNEXT_DIR)/*.def" \ - "*.manifest" "$(DYNEXT_DIR)/*.manifest" +#IF(win32): "$(DYNEXT_DIR)/*.lib" \ +#IF(win32): "*.pdb" "$(DYNEXT_DIR)/*.pdb" \ +#IF(win32): "*.ilk" "$(DYNEXT_DIR)/*.ilk" \ +#IF(win32): "*.exp" "$(DYNEXT_DIR)/*.exp" \ +#IF(win32): "*.def" "$(DYNEXT_DIR)/*.def" \ +#IF(win32): "*.manifest" "$(DYNEXT_DIR)/*.manifest" # Remove files generated by the test suite # XXX Is there a danger of too long command lines in the $(RM_F) commands, # or is there an automatic xargs? test-clean : $(RM_F) \ - "t/compilers/*/*.out" \ - "t/compilers/*/*.pasm" \ - "t/compilers/*/*.pbc" \ - "t/compilers/*/*_pbcexe*" \ + "t/compilers/*/*.out" "t/compilers/*/*.pasm" "t/compilers/*/*.pbc" "t/compilers/*/*_pbcexe*" \ "t/compilers/*/*.pir" \ - "t/compilers/*/*.stabs.s" - $(RM_F) \ - "t/compilers/*/*/*.out" \ - "t/compilers/*/*/*.pasm" \ - "t/compilers/*/*/*.pbc" \ - "t/compilers/*/*/*_pbcexe*" \ - "t/compilers/*/*/*.pir" \ - "t/compilers/*/*/*.stabs.s" $(RM_F) \ - "t/*/*$(O)" \ - "t/*/*.out" \ - "t/*/*.pasm" \ - "t/*/*_pbcexe*" \ - "t/*/*.pir" \ - "t/*/*.stabs.s" + "t/compilers/*/*/*.out" "t/compilers/*/*/*.pasm" "t/compilers/*/*/*.pbc" "t/compilers/*/*/*_pbcexe*" \ + "t/compilers/*/*/*.pir" $(RM_F) \ - "t/library/*.pbc" \ - "t/dynoplibs/*.pbc" \ - "t/op/*.pbc" \ - "t/oo/*.pbc" \ - "t/pmc/*.pbc" \ - "t/stress/*.pbc" \ - "t/tools/*.pbc" + "t/*/*$(O)" "t/*/*.out" "t/*/*.pasm" "t/*/*_pbcexe*" "t/*/*.pir" +#IF(!win32): $(RM_F) "t/compilers/*/*.stabs.s" "t/compilers/*/*/*.stabs.s" "t/*/*.stabs.s" $(RM_F) \ - "t/src/*.c" \ - "t/src/*.pdb" \ - "t/src/*.manifest" + "t/library/*.pbc" "t/dynoplibs/*.pbc" "t/op/*.pbc" "t/oo/*.pbc" "t/pmc/*.pbc" "t/stress/*.pbc" "t/tools/*.pbc" "t/src/*.c" +#IF(win32): $(RM_F) "t/src/*.pdb" "t/src/*.manifest" $(RM_F) \ - "t/tools/pmc2c.t_*" \ - "t/tools/pmc2c.pmc_t_*" \ - "t/tools/parrot_debugger.t.*" + "t/tools/pmc2c.t_*" "t/tools/pmc2c.pmc_t_*" "t/tools/parrot_debugger.t.*" $(RM_F) \ - "test$(EXE)" \ - "test.*" + "test$(EXE)" "test.*" +#IF(cygwin or mingw): $(RM_F) *.exe.stackdump $(RM_F) \ "parrot_test_run.tar.gz" Index: parrot-svn/config/init/hints/mswin32.pm =================================================================== --- parrot-svn.orig/config/init/hints/mswin32.pm 2009-02-12 17:03:46.833125000 +0000 +++ parrot-svn/config/init/hints/mswin32.pm 2009-02-12 17:05:24.953125000 +0000 @@ -24,19 +24,46 @@ my $is_mingw = $cc =~ m/\bgcc(?:\.exe)?/; my $is_bcc = $cc =~ m/\bbcc32(?:\.exe)?/; + # Notes: On win32 we need to put libparrot.dll into the build_dir not blib_dir to allow an + # already installed libparrot.dll. + # mingw gcc can link directly to the .dll, the others need an importlib which is in blib_dir. + # Because of naming conficts with non-gcc linkers we name the static lib libparrots.lib + # A static libparrot.lib is supported but not recommended when linking to the shared libparrot.dll + + # The common options first $conf->data->set( - win32 => 1, - PQ => '"', - make_c => '$(PERL) -e "chdir shift @ARGV; system \'$(MAKE)\', @ARGV; exit $$? >> 8;"', + win32 => 1, + PQ => '"', + make_c => '$(PERL) -e "chdir shift @ARGV; system \'$(MAKE)\', @ARGV; exit $$? >> 8;"', ncilib_link_extra => '-def:src/libnci_test.def', + slash => '\\', + blib_dir => 'blib\\lib', + share_ext => '.dll', + load_ext => '.dll', + a => '.lib', + o => '.obj', + has_dynamic_linking => 1 ); my $build_dir = $conf->data->get('build_dir'); - - if ( $build_dir =~ /\s/ ) { + if ( $build_dir =~ /\s/ ) { # so we don't need to quote the path $conf->data->set( build_dir => Win32::GetShortPathName($build_dir) ); } + # If we are building shared, we need to include dynamic libparrot.lib, otherwise + # the static libparrots.lib to avoid conflicts with dynpmc. See TT #276. + # To disable shared use --parrot_is_shared=0 + my $opt_shared = $conf->options->get('parrot_is_shared'); + if (defined $opt_shared and $opt_shared eq '0') { + # disable shared and use a -lparrot compatible name + $conf->data->set( has_dynamic_linking => 0, + libparrot_static => 'libparrot' . $conf->data->get('a')); + } + else { + $conf->data->set(parrot_is_shared => 1, + libparrot_static => 'libparrots' . $conf->data->get('a')); + } + if ($is_msvc) { my $msvcversion = $conf->data->get('msvcversion'); @@ -66,17 +93,14 @@ } $conf->data->set( - share_ext => '.dll', - load_ext => '.dll', - a => '.lib', - o => '.obj', cc_o_out => '-Fo', cc_exe_out => '-out:', cc_ldflags => '/link', make_c => q{$(PERL) -e "chdir shift @ARGV;} - . q{system '$(MAKE)', '-nologo', @ARGV; exit $$? >> 8;"}, + . q{system '$(MAKE)', '-nologo', @ARGV; exit $$? >> 8;"}, make => 'nmake', + msvc => 1, # ZI messes with __LINE__ cc_debug => '-Zi', @@ -86,24 +110,23 @@ ld_out => '-out:', ldflags => '-nologo -nodefaultlib', libs => 'kernel32.lib ws2_32.lib msvcrt.lib oldnames.lib ', - libparrot_static => 'libparrot' . $conf->data->get('a'), libparrot_shared => 'libparrot$(SHARE_EXT)', + implib_out => '-implib:', + importlib => 'libparrot.lib', ar_flags => '', ar_out => '-out:', - slash => '\\', - blib_dir => 'blib\\lib', ccflags => $ccflags, ccwarn => $ccwarn, - has_dynamic_linking => 1, - parrot_is_shared => 1, sym_export => '__declspec(dllexport)', sym_import => '__declspec(dllimport)' ); - # If we are building shared, need to include dynamic libparrot.lib, otherwise - # the static libparrot.lib. - $conf->data->set( libparrot_ldflags => "\"$build_dir\\libparrot.lib\"" ); + # linking with -libpath:blib_dir and libparrot.lib will not succeed for dynpmc linking. + # We better use the full path. + $conf->data->set( + libparrot_ldflags => "$build_dir\\" . $conf->data->get('blib_dir') . "\\libparrot.lib" + ); # 'link' needs to be link.exe, not cl.exe. # This makes 'link' and 'ld' the same. @@ -118,10 +141,6 @@ } elsif ($is_intel) { $conf->data->set( - share_ext => '.dll', - load_ext => '.dll', - a => '.lib', - o => '.obj', cc_o_out => '-Fo', cc_exe_out => '-out:', cc_ldflags => '/link', @@ -138,11 +157,8 @@ ar => 'xilib', ar_flags => '', ar_out => '-out:', - slash => '\\', - blib_dir => 'blib\\lib', ccflags => $ccflags, ccwarn => '', - has_dynamic_linking => 1 ); # 'link' needs to be xilink.exe, not icl.exe. @@ -158,10 +174,6 @@ } elsif ($is_bcc) { $conf->data->set( - o => '.obj', - a => '.lib', - share_ext => '.dll', - load_ext => '.dll', cc => ${cc}, ccflags => '-O2 -w-8066 -DWIN32 -DNO_STRICT -DNDEBUG -D_CONSOLE -w-par -w-aus -w-ccc -w-rch', @@ -185,27 +197,30 @@ ar_flags => '', ar_out => '', ar_extra => '', - slash => '\\', - blib_dir => 'blib\\lib', make_and => "\n\t", ); } elsif ($is_mingw) { + $conf->data->set( + a => '.a', + o => '.o', + mingw => 1, + ); + my $make = $conf->data->get(qw(make)); if ( $make =~ /nmake/i ) { # ActiveState Perl $conf->data->set( - a => '.a', ar => 'ar', ccflags => '-DWIN32 ', ld => 'g++', ldflags => '', - libs => -'-lmsvcrt -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion ', + libs => '-lmsvcrt -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32' + . ' -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr' + . ' -lwinmm -lversion ', link => 'gcc', linkflags => '', - o => '.o', ); } elsif ( $make =~ /dmake/i ) { @@ -219,14 +234,15 @@ ); } elsif ( $make =~ /mingw32-make/i ) { - ; # Vanilla Perl + + # Vanilla Perl $conf->data->set( make => 'mingw32-make', make_c => 'mingw32-make -C', ); } else { - warn "unknown configuration"; + warn "unknown configuration make = '$make'"; } if ( $conf->data->get(qw(optimize)) eq "1" ) { @@ -235,18 +251,27 @@ $conf->data->set( cc => 'gcc', - parrot_is_shared => 1, - has_dynamic_linking => 1, ld_load_flags => '-shared ', ld_share_flags => '-shared ', - libparrot_ldflags => "\"$build_dir\\libparrot.dll\"", ncilib_link_extra => 'src/libnci_test.def', sym_export => '__declspec(dllexport)', sym_import => '__declspec(dllimport)', - slash => '\\', - blib_dir => 'blib\\lib', + libparrot_static => 'libparrot.a', + libparrot_ldflags => "$build_dir\\libparrot.dll", + importlib => 'libparrot.dll.a', + implib_out => '-Wl,--out-implib=', ); } + + # sanity check + if ($conf->data->get('libparrot_static') eq $conf->data->get('importlib')) { + my $static = $conf->data->get('libparrot_static'); + if ($static) { + warn "invalid libparrot_static '$static' conflicts with importlib, renamed to '$static.lib'."; + $conf->data->set('libparrot_static') = "$static.lib"; + } + } + } 1; Index: parrot-svn/config/init/hints/cygwin.pm =================================================================== --- parrot-svn.orig/config/init/hints/cygwin.pm 2009-02-12 17:03:46.832125000 +0000 +++ parrot-svn/config/init/hints/cygwin.pm 2009-02-12 17:05:24.953125000 +0000 @@ -41,14 +41,16 @@ ld_share_flags => '-shared', ld_load_flags => '-shared', libs => $libs, - has_static_linking => 0, + has_static_linking => 1, has_dynamic_linking => 1, parrot_is_shared => 1, sym_export => '__declspec(dllexport)', sym_import => '__declspec(dllimport)', libparrot_shared => $libparrot_shared, - blib_dir => '.', + blib_dir => 'blib/lib', libparrot_ldflags => '-L' . $build_dir . ' -lparrot', + implib_out => '-Wl,--out-implib=', + importlib => 'libparrot.dll.a', ); # inet_aton needs to be defined on Cygwin. Index: parrot-svn/config/init/defaults.pm =================================================================== --- parrot-svn.orig/config/init/defaults.pm 2009-02-12 17:05:04.390625000 +0000 +++ parrot-svn/config/init/defaults.pm 2009-02-12 17:05:24.953125000 +0000 @@ -212,9 +212,6 @@ make_set_make => $Config{make_set_make}, make_and => '&&', - # for cygwin - cygchkdll => '', - # make_c: Command to emulate GNU make's C<-C directory> option: chdir # to C before executing $(MAKE) make_c => '$(PERL) -e \'chdir shift @ARGV; system q{$(MAKE)}, @ARGV; exit $$? >> 8;\'',