Ticket #312: tt312-win32-linking.patch

File tt312-win32-linking.patch, 15.7 KB (added by rurban, 13 years ago)

tested on freebsd, fixed some omissions

  • config/gen/makefiles/dynpmc_pl.in

    old new  
    8686        $extraLibs =~ s/\Q$(A)\E/.lib/g; 
    8787        $liblist .= ' ' . $extraLibs; 
    8888 
    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         } 
    9689    } 
    9790    else { 
    9891        $liblist = join( ' ', map { "-l$_" } keys %$libs ); 
  • config/gen/makefiles/root.in

    old new  
    480480# Libraries 
    481481LIBPARROT_STATIC    = @blib_dir@/@libparrot_static@ 
    482482#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@ 
     485IMPLIB_OUT          = @implib_out@ 
     486#IF(IMPORTLIB):IMPORTLIB           = @blib_dir@/@importlib@ 
     487#ELSE:IMPORTLIB           = 
    485488 
    486489# This line controls whether a static or shared library is built 
    487490LIBPARROT           = @libparrot@ 
     
    845848 
    846849PARROT_LIBS: \ 
    847850#IF(has_static_linking):  $(LIBPARROT_STATIC) \ 
    848 #IF(has_dynamic_linking): $(LIBPARROT_SHARED) 
     851#IF(has_dynamic_linking):  $(LIBPARROT_SHARED) 
    849852 
    850853$(LIBPARROT_STATIC) : $(O_FILES) 
    851854        $(MKPATH) @blib_dir@ 
     
    856859$(LIBPARROT_SHARED) : $(O_FILES) 
    857860        $(MKPATH) @blib_dir@ 
    858861        $(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) \ 
    861863                $(O_FILES) $(C_LIBS) $(ICU_SHARED) 
    862864#IF(win32):     if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2 
    863865#IF(libparrot_shared_alias):    ( cd @blib_dir@ ; ln -sf @libparrot_shared@ @libparrot_shared_alias@ ) 
     
    15951597    $(PARROT) \ 
    15961598    $(MINIPARROT) \ 
    15971599    $(LIBPARROT) \ 
     1600#IF(importlib):    $(IMPORTLIB) \ 
    15981601    $(INSTALLABLEPARROT) \ 
    15991602    $(INSTALLABLEDIS) \ 
    16001603    $(INSTALLABLEPDUMP) \ 
    16011604    $(INSTALLABLEPINFO) \ 
    16021605    $(INSTALLABLEPBCMERGE) \ 
    16031606    $(INSTALLABLEPDB) \ 
     1607    $(INSTALLABLECONFIG) \ 
    16041608    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) \ 
    16051610    $(IMCC_DIR)/main$(O) \ 
    16061611    $(PDUMP) $(SRC_DIR)/pbc_dump$(O) $(SRC_DIR)/packdump$(O) \ 
    16071612    $(SRC_DIR)/pbc_info$(O) $(PINFO) \ 
     
    16721677        $(RM_F) \ 
    16731678    "$(DYNEXT_DIR)/*$(LOAD_EXT)" \ 
    16741679    "$(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" 
    16811686 
    16821687# Remove files generated by the test suite 
    16831688# XXX Is there a danger of too long command lines in the $(RM_F) commands, 
    16841689# or is there an automatic xargs? 
    16851690test-clean : 
    16861691        $(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*" \ 
    16911693    "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" 
    17001694        $(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" 
    17071697        $(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" 
    17151700        $(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" 
    17191703        $(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.*" 
    17231705        $(RM_F) \ 
    1724      "test$(EXE)" \ 
    1725      "test.*" 
     1706     "test$(EXE)" "test.*" 
     1707#IF(cygwin or mingw):     $(RM_F) *.exe.stackdump 
    17261708        $(RM_F) \ 
    17271709     "parrot_test_run.tar.gz" 
    17281710 
  • config/init/hints/mswin32.pm

    old new  
    2424    my $is_mingw = $cc =~ m/\bgcc(?:\.exe)?/; 
    2525    my $is_bcc   = $cc =~ m/\bbcc32(?:\.exe)?/; 
    2626 
     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 
    2734    $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;"', 
    3138        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 
    3246    ); 
    3347 
    3448    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 
    3750        $conf->data->set( build_dir => Win32::GetShortPathName($build_dir) ); 
    3851    } 
    3952 
     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 
    4067    if ($is_msvc) { 
    4168        my $msvcversion = $conf->data->get('msvcversion'); 
    4269 
     
    6693        } 
    6794 
    6895        $conf->data->set( 
    69             share_ext  => '.dll', 
    70             load_ext   => '.dll', 
    71             a          => '.lib', 
    72             o          => '.obj', 
    7396            cc_o_out   => '-Fo', 
    7497            cc_exe_out => '-out:', 
    7598            cc_ldflags => '/link', 
    7699 
    77100            make_c => q{$(PERL) -e "chdir shift @ARGV;} 
    78                 . q{system '$(MAKE)', '-nologo', @ARGV; exit $$? >> 8;"}, 
     101                    . q{system '$(MAKE)', '-nologo', @ARGV; exit $$? >> 8;"}, 
    79102            make => 'nmake', 
     103            msvc => 1, 
    80104 
    81105            # ZI messes with __LINE__ 
    82106            cc_debug            => '-Zi', 
     
    86110            ld_out              => '-out:', 
    87111            ldflags             => '-nologo -nodefaultlib', 
    88112            libs                => 'kernel32.lib ws2_32.lib msvcrt.lib oldnames.lib ', 
    89             libparrot_static    => 'libparrot' . $conf->data->get('a'), 
    90113            libparrot_shared    => 'libparrot$(SHARE_EXT)', 
     114            implib_out          => '-implib:', 
     115            importlib           => 'libparrot.lib', 
    91116            ar_flags            => '', 
    92117            ar_out              => '-out:', 
    93             slash               => '\\', 
    94             blib_dir            => 'blib\\lib', 
    95118            ccflags             => $ccflags, 
    96119            ccwarn              => $ccwarn, 
    97             has_dynamic_linking => 1, 
    98             parrot_is_shared    => 1, 
    99120 
    100121            sym_export => '__declspec(dllexport)', 
    101122            sym_import => '__declspec(dllimport)' 
    102123        ); 
    103124 
    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        ); 
    107130 
    108131        # 'link' needs to be link.exe, not cl.exe. 
    109132        # This makes 'link' and 'ld' the same. 
     
    118141    } 
    119142    elsif ($is_intel) { 
    120143        $conf->data->set( 
    121             share_ext  => '.dll', 
    122             load_ext   => '.dll', 
    123             a          => '.lib', 
    124             o          => '.obj', 
    125144            cc_o_out   => '-Fo', 
    126145            cc_exe_out => '-out:', 
    127146            cc_ldflags => '/link', 
     
    138157            ar                  => 'xilib', 
    139158            ar_flags            => '', 
    140159            ar_out              => '-out:', 
    141             slash               => '\\', 
    142             blib_dir            => 'blib\\lib', 
    143160            ccflags             => $ccflags, 
    144161            ccwarn              => '', 
    145             has_dynamic_linking => 1 
    146162        ); 
    147163 
    148164        # 'link' needs to be xilink.exe, not icl.exe. 
     
    158174    } 
    159175    elsif ($is_bcc) { 
    160176        $conf->data->set( 
    161             o         => '.obj', 
    162             a         => '.lib', 
    163             share_ext => '.dll', 
    164             load_ext  => '.dll', 
    165177            cc        => ${cc}, 
    166178            ccflags => 
    167179                '-O2 -w-8066 -DWIN32 -DNO_STRICT -DNDEBUG -D_CONSOLE -w-par -w-aus -w-ccc -w-rch', 
     
    185197            ar_flags => '', 
    186198            ar_out   => '', 
    187199            ar_extra => '', 
    188             slash    => '\\', 
    189             blib_dir => 'blib\\lib', 
    190200            make_and => "\n\t", 
    191201        ); 
    192202    } 
    193203    elsif ($is_mingw) { 
     204        $conf->data->set( 
     205            a          => '.a', 
     206            o          => '.o', 
     207            mingw      => 1, 
     208        ); 
     209 
    194210        my $make = $conf->data->get(qw(make)); 
    195211        if ( $make =~ /nmake/i ) { 
    196212 
    197213            # ActiveState Perl 
    198214            $conf->data->set( 
    199                 a       => '.a', 
    200215                ar      => 'ar', 
    201216                ccflags => '-DWIN32 ', 
    202217                ld      => 'g++', 
    203218                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 ', 
    206222                link      => 'gcc', 
    207223                linkflags => '', 
    208                 o         => '.o', 
    209224            ); 
    210225        } 
    211226        elsif ( $make =~ /dmake/i ) { 
     
    219234            ); 
    220235        } 
    221236        elsif ( $make =~ /mingw32-make/i ) { 
    222             ; # Vanilla Perl 
     237 
     238            # Vanilla Perl 
    223239            $conf->data->set( 
    224240                make      => 'mingw32-make', 
    225241                make_c    => 'mingw32-make -C', 
    226242            ); 
    227243        } 
    228244        else { 
    229             warn "unknown configuration"; 
     245            warn "unknown configuration make = '$make'"; 
    230246        } 
    231247 
    232248        if ( $conf->data->get(qw(optimize)) eq "1" ) { 
     
    235251 
    236252        $conf->data->set( 
    237253            cc                  => 'gcc', 
    238             parrot_is_shared    => 1, 
    239             has_dynamic_linking => 1, 
    240254            ld_load_flags       => '-shared ', 
    241255            ld_share_flags      => '-shared ', 
    242             libparrot_ldflags   => "\"$build_dir\\libparrot.dll\"", 
    243256            ncilib_link_extra   => 'src/libnci_test.def', 
    244257            sym_export          => '__declspec(dllexport)', 
    245258            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=', 
    248263        ); 
    249264    } 
     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 
    250275} 
    251276 
    2522771; 
  • config/init/hints/cygwin.pm

    old new  
    4141        ld_share_flags      => '-shared', 
    4242        ld_load_flags       => '-shared', 
    4343        libs                => $libs, 
    44         has_static_linking  => 0, 
     44        has_static_linking  => 1, 
    4545        has_dynamic_linking => 1, 
    4646        parrot_is_shared    => 1, 
    4747        sym_export          => '__declspec(dllexport)', 
    4848        sym_import          => '__declspec(dllimport)', 
    4949        libparrot_shared    => $libparrot_shared, 
    50         blib_dir            => '.', 
     50        blib_dir            => 'blib/lib', 
    5151        libparrot_ldflags   => '-L' . $build_dir . ' -lparrot', 
     52        implib_out          => '-Wl,--out-implib=', 
     53        importlib           => 'libparrot.dll.a', 
    5254    ); 
    5355 
    5456    # inet_aton needs to be defined on Cygwin. 
  • config/init/defaults.pm

    old new  
    212212        make_set_make => $Config{make_set_make}, 
    213213        make_and      => '&&', 
    214214 
    215         # for cygwin 
    216         cygchkdll => '', 
    217  
    218215        # make_c: Command to emulate GNU make's C<-C directory> option:  chdir 
    219216        # to C<directory> before executing $(MAKE) 
    220217        make_c => '$(PERL) -e \'chdir shift @ARGV; system q{$(MAKE)}, @ARGV; exit $$? >> 8;\'',