Ticket #312: tt312-win32-linking.2.patch
File tt312-win32-linking.2.patch, 15.7 KB (added by rurban, 13 years ago) |
---|
-
config/gen/makefiles/dynpmc_pl.in
old new 86 86 $extraLibs =~ s/\Q$(A)\E/.lib/g; 87 87 $liblist .= ' ' . $extraLibs; 88 88 89 # Also note that we may need to look in the Parrot blib directory.90 if ($CC =~ /gcc/i) {91 $liblist .= qq{ -Wl,-L "@build_dir@/blib/lib"};92 }93 else {94 $liblist .= qq{ /LIBPATH:"@build_dir@/blib/lib"};95 }96 89 } 97 90 else { 98 91 $liblist = join( ' ', map { "-l$_" } keys %$libs ); -
config/gen/makefiles/root.in
old new 480 480 # Libraries 481 481 LIBPARROT_STATIC = @blib_dir@/@libparrot_static@ 482 482 #IF(darwin):export DYLD_LIBRARY_PATH := @blib_dir@:$(DYLD_LIBRARY_PATH) 483 #IF(win32):LIBPARROT_SHARED = @libparrot_shared@ 484 #ELSE:LIBPARROT_SHARED = @blib_dir@/@libparrot_shared@ 483 #IF(win32 or cygwin):LIBPARROT_SHARED = @libparrot_shared@ 484 #ELSE:LIBPARROT_SHARED = @blib_dir@/@libparrot_shared@ 485 IMPLIB_OUT = @implib_out@ 486 #IF(IMPORTLIB):IMPORTLIB = @blib_dir@/@importlib@ 487 #ELSE:IMPORTLIB = 485 488 486 489 # This line controls whether a static or shared library is built 487 490 LIBPARROT = @libparrot@ … … 845 848 846 849 PARROT_LIBS: \ 847 850 #IF(has_static_linking): $(LIBPARROT_STATIC) \ 848 #IF(has_dynamic_linking): $(LIBPARROT_SHARED)851 #IF(has_dynamic_linking): $(LIBPARROT_SHARED) 849 852 850 853 $(LIBPARROT_STATIC) : $(O_FILES) 851 854 $(MKPATH) @blib_dir@ … … 856 859 $(LIBPARROT_SHARED) : $(O_FILES) 857 860 $(MKPATH) @blib_dir@ 858 861 $(LD) $(LD_SHARE_FLAGS) $(LDFLAGS) @ld_out@$@ @libparrot_soname@ \ 859 #IF(cygwin): -Wl,--out-implib=libparrot.dll.a \ 860 #IF(win32 and cc==gcc): -Wl,--out-implib=libparrot.lib \ 862 #IF(importlib): $(IMPLIB_OUT)$(IMPORTLIB) \ 861 863 $(O_FILES) $(C_LIBS) $(ICU_SHARED) 862 864 #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2 863 865 #IF(libparrot_shared_alias): ( cd @blib_dir@ ; ln -sf @libparrot_shared@ @libparrot_shared_alias@ ) … … 1595 1597 $(PARROT) \ 1596 1598 $(MINIPARROT) \ 1597 1599 $(LIBPARROT) \ 1600 #IF(importlib): $(IMPORTLIB) \ 1598 1601 $(INSTALLABLEPARROT) \ 1599 1602 $(INSTALLABLEDIS) \ 1600 1603 $(INSTALLABLEPDUMP) \ 1601 1604 $(INSTALLABLEPINFO) \ 1602 1605 $(INSTALLABLEPBCMERGE) \ 1603 1606 $(INSTALLABLEPDB) \ 1607 $(INSTALLABLECONFIG) \ 1604 1608 pbc_to_exe.pbc pbc_to_exe.c pbc_to_exe$(O) pbc_to_exe$(EXE) \ 1609 parrot_config$(O) parrot_config.pbc parrot_config.c parrot_config$(EXE) \ 1605 1610 $(IMCC_DIR)/main$(O) \ 1606 1611 $(PDUMP) $(SRC_DIR)/pbc_dump$(O) $(SRC_DIR)/packdump$(O) \ 1607 1612 $(SRC_DIR)/pbc_info$(O) $(PINFO) \ … … 1672 1677 $(RM_F) \ 1673 1678 "$(DYNEXT_DIR)/*$(LOAD_EXT)" \ 1674 1679 "$(DYNEXT_DIR)/*$(SHARE_EXT)" \ 1675 "$(DYNEXT_DIR)/*.lib" \1676 "*.pdb" "$(DYNEXT_DIR)/*.pdb" \1677 "*.ilk" "$(DYNEXT_DIR)/*.ilk" \1678 "*.exp" "$(DYNEXT_DIR)/*.exp" \1679 "*.def" "$(DYNEXT_DIR)/*.def" \1680 "*.manifest" "$(DYNEXT_DIR)/*.manifest"1680 #IF(win32): "$(DYNEXT_DIR)/*.lib" \ 1681 #IF(win32): "*.pdb" "$(DYNEXT_DIR)/*.pdb" \ 1682 #IF(win32): "*.ilk" "$(DYNEXT_DIR)/*.ilk" \ 1683 #IF(win32): "*.exp" "$(DYNEXT_DIR)/*.exp" \ 1684 #IF(win32): "*.def" "$(DYNEXT_DIR)/*.def" \ 1685 #IF(win32): "*.manifest" "$(DYNEXT_DIR)/*.manifest" 1681 1686 1682 1687 # Remove files generated by the test suite 1683 1688 # XXX Is there a danger of too long command lines in the $(RM_F) commands, 1684 1689 # or is there an automatic xargs? 1685 1690 test-clean : 1686 1691 $(RM_F) \ 1687 "t/compilers/*/*.out" \ 1688 "t/compilers/*/*.pasm" \ 1689 "t/compilers/*/*.pbc" \ 1690 "t/compilers/*/*_pbcexe*" \ 1692 "t/compilers/*/*.out" "t/compilers/*/*.pasm" "t/compilers/*/*.pbc" "t/compilers/*/*_pbcexe*" \ 1691 1693 "t/compilers/*/*.pir" \ 1692 "t/compilers/*/*.stabs.s"1693 $(RM_F) \1694 "t/compilers/*/*/*.out" \1695 "t/compilers/*/*/*.pasm" \1696 "t/compilers/*/*/*.pbc" \1697 "t/compilers/*/*/*_pbcexe*" \1698 "t/compilers/*/*/*.pir" \1699 "t/compilers/*/*/*.stabs.s"1700 1694 $(RM_F) \ 1701 "t/*/*$(O)" \ 1702 "t/*/*.out" \ 1703 "t/*/*.pasm" \ 1704 "t/*/*_pbcexe*" \ 1705 "t/*/*.pir" \ 1706 "t/*/*.stabs.s" 1695 "t/compilers/*/*/*.out" "t/compilers/*/*/*.pasm" "t/compilers/*/*/*.pbc" "t/compilers/*/*/*_pbcexe*" \ 1696 "t/compilers/*/*/*.pir" 1707 1697 $(RM_F) \ 1708 "t/library/*.pbc" \ 1709 "t/dynoplibs/*.pbc" \ 1710 "t/op/*.pbc" \ 1711 "t/oo/*.pbc" \ 1712 "t/pmc/*.pbc" \ 1713 "t/stress/*.pbc" \ 1714 "t/tools/*.pbc" 1698 "t/*/*$(O)" "t/*/*.out" "t/*/*.pasm" "t/*/*_pbcexe*" "t/*/*.pir" 1699 #IF(!win32): $(RM_F) "t/compilers/*/*.stabs.s" "t/compilers/*/*/*.stabs.s" "t/*/*.stabs.s" 1715 1700 $(RM_F) \ 1716 "t/src/*.c" \ 1717 "t/src/*.pdb" \ 1718 "t/src/*.manifest" 1701 "t/library/*.pbc" "t/dynoplibs/*.pbc" "t/op/*.pbc" "t/oo/*.pbc" "t/pmc/*.pbc" "t/stress/*.pbc" "t/tools/*.pbc" "t/src/*.c" 1702 #IF(win32): $(RM_F) "t/src/*.pdb" "t/src/*.manifest" 1719 1703 $(RM_F) \ 1720 "t/tools/pmc2c.t_*" \ 1721 "t/tools/pmc2c.pmc_t_*" \ 1722 "t/tools/parrot_debugger.t.*" 1704 "t/tools/pmc2c.t_*" "t/tools/pmc2c.pmc_t_*" "t/tools/parrot_debugger.t.*" 1723 1705 $(RM_F) \ 1724 "test$(EXE)" \1725 "test.*" 1706 "test$(EXE)" "test.*" 1707 #IF(cygwin or mingw): $(RM_F) *.exe.stackdump 1726 1708 $(RM_F) \ 1727 1709 "parrot_test_run.tar.gz" 1728 1710 -
config/init/hints/mswin32.pm
old new 24 24 my $is_mingw = $cc =~ m/\bgcc(?:\.exe)?/; 25 25 my $is_bcc = $cc =~ m/\bbcc32(?:\.exe)?/; 26 26 27 # Notes: On win32 we need to put libparrot.dll into the build_dir not blib_dir to allow an 28 # already installed libparrot.dll. 29 # mingw gcc can link directly to the .dll, the others need an importlib which is in blib_dir. 30 # Because of naming conficts with non-gcc linkers we name the static lib libparrots.lib 31 # A static libparrot.lib is supported but not recommended when linking to the shared libparrot.dll 32 33 # The common options first 27 34 $conf->data->set( 28 win32 => 1,29 PQ => '"',30 make_c => '$(PERL) -e "chdir shift @ARGV; system \'$(MAKE)\', @ARGV; exit $$? >> 8;"',35 win32 => 1, 36 PQ => '"', 37 make_c => '$(PERL) -e "chdir shift @ARGV; system \'$(MAKE)\', @ARGV; exit $$? >> 8;"', 31 38 ncilib_link_extra => '-def:src/libnci_test.def', 39 slash => '\\', 40 blib_dir => 'blib\\lib', 41 share_ext => '.dll', 42 load_ext => '.dll', 43 a => '.lib', 44 o => '.obj', 45 has_dynamic_linking => 1 32 46 ); 33 47 34 48 my $build_dir = $conf->data->get('build_dir'); 35 36 if ( $build_dir =~ /\s/ ) { 49 if ( $build_dir =~ /\s/ ) { # so we don't need to quote the path 37 50 $conf->data->set( build_dir => Win32::GetShortPathName($build_dir) ); 38 51 } 39 52 53 # If we are building shared, we need to include dynamic libparrot.lib, otherwise 54 # the static libparrots.lib to avoid conflicts with dynpmc. See TT #276. 55 # To disable shared use --parrot_is_shared=0 56 my $opt_shared = $conf->options->get('parrot_is_shared'); 57 if (defined $opt_shared and $opt_shared eq '0') { 58 # disable shared and use a -lparrot compatible name 59 $conf->data->set( has_dynamic_linking => 0, 60 libparrot_static => 'libparrot' . $conf->data->get('a')); 61 } 62 else { 63 $conf->data->set(parrot_is_shared => 1, 64 libparrot_static => 'libparrots' . $conf->data->get('a')); 65 } 66 40 67 if ($is_msvc) { 41 68 my $msvcversion = $conf->data->get('msvcversion'); 42 69 … … 66 93 } 67 94 68 95 $conf->data->set( 69 share_ext => '.dll',70 load_ext => '.dll',71 a => '.lib',72 o => '.obj',73 96 cc_o_out => '-Fo', 74 97 cc_exe_out => '-out:', 75 98 cc_ldflags => '/link', 76 99 77 100 make_c => q{$(PERL) -e "chdir shift @ARGV;} 78 . q{system '$(MAKE)', '-nologo', @ARGV; exit $$? >> 8;"},101 . q{system '$(MAKE)', '-nologo', @ARGV; exit $$? >> 8;"}, 79 102 make => 'nmake', 103 msvc => 1, 80 104 81 105 # ZI messes with __LINE__ 82 106 cc_debug => '-Zi', … … 86 110 ld_out => '-out:', 87 111 ldflags => '-nologo -nodefaultlib', 88 112 libs => 'kernel32.lib ws2_32.lib msvcrt.lib oldnames.lib ', 89 libparrot_static => 'libparrot' . $conf->data->get('a'),90 113 libparrot_shared => 'libparrot$(SHARE_EXT)', 114 implib_out => '-implib:', 115 importlib => 'libparrot.lib', 91 116 ar_flags => '', 92 117 ar_out => '-out:', 93 slash => '\\',94 blib_dir => 'blib\\lib',95 118 ccflags => $ccflags, 96 119 ccwarn => $ccwarn, 97 has_dynamic_linking => 1,98 parrot_is_shared => 1,99 120 100 121 sym_export => '__declspec(dllexport)', 101 122 sym_import => '__declspec(dllimport)' 102 123 ); 103 124 104 # If we are building shared, need to include dynamic libparrot.lib, otherwise 105 # the static libparrot.lib. 106 $conf->data->set( libparrot_ldflags => "\"$build_dir\\libparrot.lib\"" ); 125 # linking with -libpath:blib_dir and libparrot.lib will not succeed for dynpmc linking. 126 # We better use the full path. 127 $conf->data->set( 128 libparrot_ldflags => "$build_dir\\" . $conf->data->get('blib_dir') . "\\libparrot.lib" 129 ); 107 130 108 131 # 'link' needs to be link.exe, not cl.exe. 109 132 # This makes 'link' and 'ld' the same. … … 118 141 } 119 142 elsif ($is_intel) { 120 143 $conf->data->set( 121 share_ext => '.dll',122 load_ext => '.dll',123 a => '.lib',124 o => '.obj',125 144 cc_o_out => '-Fo', 126 145 cc_exe_out => '-out:', 127 146 cc_ldflags => '/link', … … 138 157 ar => 'xilib', 139 158 ar_flags => '', 140 159 ar_out => '-out:', 141 slash => '\\',142 blib_dir => 'blib\\lib',143 160 ccflags => $ccflags, 144 161 ccwarn => '', 145 has_dynamic_linking => 1146 162 ); 147 163 148 164 # 'link' needs to be xilink.exe, not icl.exe. … … 158 174 } 159 175 elsif ($is_bcc) { 160 176 $conf->data->set( 161 o => '.obj',162 a => '.lib',163 share_ext => '.dll',164 load_ext => '.dll',165 177 cc => ${cc}, 166 178 ccflags => 167 179 '-O2 -w-8066 -DWIN32 -DNO_STRICT -DNDEBUG -D_CONSOLE -w-par -w-aus -w-ccc -w-rch', … … 185 197 ar_flags => '', 186 198 ar_out => '', 187 199 ar_extra => '', 188 slash => '\\',189 blib_dir => 'blib\\lib',190 200 make_and => "\n\t", 191 201 ); 192 202 } 193 203 elsif ($is_mingw) { 204 $conf->data->set( 205 a => '.a', 206 o => '.o', 207 mingw => 1, 208 ); 209 194 210 my $make = $conf->data->get(qw(make)); 195 211 if ( $make =~ /nmake/i ) { 196 212 197 213 # ActiveState Perl 198 214 $conf->data->set( 199 a => '.a',200 215 ar => 'ar', 201 216 ccflags => '-DWIN32 ', 202 217 ld => 'g++', 203 218 ldflags => '', 204 libs => 205 '-lmsvcrt -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion ', 219 libs => '-lmsvcrt -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32' 220 . ' -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr' 221 . ' -lwinmm -lversion ', 206 222 link => 'gcc', 207 223 linkflags => '', 208 o => '.o',209 224 ); 210 225 } 211 226 elsif ( $make =~ /dmake/i ) { … … 219 234 ); 220 235 } 221 236 elsif ( $make =~ /mingw32-make/i ) { 222 ; # Vanilla Perl 237 238 # Vanilla Perl 223 239 $conf->data->set( 224 240 make => 'mingw32-make', 225 241 make_c => 'mingw32-make -C', 226 242 ); 227 243 } 228 244 else { 229 warn "unknown configuration ";245 warn "unknown configuration make = '$make'"; 230 246 } 231 247 232 248 if ( $conf->data->get(qw(optimize)) eq "1" ) { … … 235 251 236 252 $conf->data->set( 237 253 cc => 'gcc', 238 parrot_is_shared => 1,239 has_dynamic_linking => 1,240 254 ld_load_flags => '-shared ', 241 255 ld_share_flags => '-shared ', 242 libparrot_ldflags => "\"$build_dir\\libparrot.dll\"",243 256 ncilib_link_extra => 'src/libnci_test.def', 244 257 sym_export => '__declspec(dllexport)', 245 258 sym_import => '__declspec(dllimport)', 246 slash => '\\', 247 blib_dir => 'blib\\lib', 259 libparrot_static => 'libparrot.a', 260 libparrot_ldflags => "$build_dir\\libparrot.dll", 261 importlib => 'libparrot.dll.a', 262 implib_out => '-Wl,--out-implib=', 248 263 ); 249 264 } 265 266 # sanity check 267 if ($conf->data->get('libparrot_static') eq $conf->data->get('importlib')) { 268 my $static = $conf->data->get('libparrot_static'); 269 if ($static) { 270 warn "invalid libparrot_static '$static' conflicts with importlib, renamed to '$static.lib'."; 271 $conf->data->set('libparrot_static') = "$static.lib"; 272 } 273 } 274 250 275 } 251 276 252 277 1; -
config/init/hints/cygwin.pm
old new 41 41 ld_share_flags => '-shared', 42 42 ld_load_flags => '-shared', 43 43 libs => $libs, 44 has_static_linking => 0,44 has_static_linking => 1, 45 45 has_dynamic_linking => 1, 46 46 parrot_is_shared => 1, 47 47 sym_export => '__declspec(dllexport)', 48 48 sym_import => '__declspec(dllimport)', 49 49 libparrot_shared => $libparrot_shared, 50 blib_dir => ' .',50 blib_dir => 'blib/lib', 51 51 libparrot_ldflags => '-L' . $build_dir . ' -lparrot', 52 implib_out => '-Wl,--out-implib=', 53 importlib => 'libparrot.dll.a', 52 54 ); 53 55 54 56 # inet_aton needs to be defined on Cygwin. -
config/init/defaults.pm
old new 212 212 make_set_make => $Config{make_set_make}, 213 213 make_and => '&&', 214 214 215 # for cygwin216 cygchkdll => '',217 218 215 # make_c: Command to emulate GNU make's C<-C directory> option: chdir 219 216 # to C<directory> before executing $(MAKE) 220 217 make_c => '$(PERL) -e \'chdir shift @ARGV; system q{$(MAKE)}, @ARGV; exit $$? >> 8;\'',