3333# * cygwin gcc 2.95.2/ld 2.10.90/dllwrap 2.10.90 works now
3434# - its dllwrap doesn't work, there is a bug in binutils 2.10.90
3535# see also http://sources.redhat.com/ml/cygwin/2000-06/msg01274.html
36+ # - using gcc -mdll instead dllwrap doesn't work without -static because
37+ # it tries to link against dlls instead their import libraries. (If
38+ # it finds the dll first.)
39+ # By specifying -static we force ld to link against the import libraries,
40+ # this is windows standard and there are normally not the necessary symbols
41+ # in the dlls.
3642# *** only the version of June 2000 shows these problems
43+ # * cygwin gcc 3.2/ld 2.13.90 works
44+ # (ld supports -shared)
45+ # * mingw gcc 3.2/ld 2.13 works
46+ # (ld supports -shared)
3747
3848# This module should be kept compatible with Python 1.5.2.
3949
@@ -77,7 +87,7 @@ def __init__ (self, verbose=0, dry_run=0, force=0):
7787 self .ld_version ,
7888 self .dllwrap_version ) )
7989
80- # ld_version >= "2.10.90" should also be able to use
90+ # ld_version >= "2.10.90" and < "2.13" should also be able to use
8191 # gcc -mdll instead of dllwrap
8292 # Older dllwraps had own version numbers, newer ones use the
8393 # same as the rest of binutils ( also ld )
@@ -87,13 +97,20 @@ def __init__ (self, verbose=0, dry_run=0, force=0):
8797 else :
8898 self .linker_dll = "dllwrap"
8999
100+ # ld_version >= "2.13" support -shared so use it instead of
101+ # -mdll -static
102+ if self .ld_version >= "2.13" :
103+ shared_option = "-shared"
104+ else :
105+ shared_option = "-mdll -static"
106+
90107 # Hard-code GCC because that's what this is all about.
91108 # XXX optimization, warnings etc. should be customizable.
92109 self .set_executables (compiler = 'gcc -mcygwin -O -Wall' ,
93110 compiler_so = 'gcc -mcygwin -mdll -O -Wall' ,
94111 linker_exe = 'gcc -mcygwin' ,
95- linker_so = ('%s -mcygwin -mdll ' %
96- self .linker_dll ))
112+ linker_so = ('%s -mcygwin %s ' %
113+ ( self .linker_dll , shared_option ) ))
97114
98115 # cygwin and mingw32 need different sets of libraries
99116 if self .gcc_version == "2.91.57" :
@@ -262,6 +279,13 @@ def __init__ (self,
262279
263280 CygwinCCompiler .__init__ (self , verbose , dry_run , force )
264281
282+ # ld_version >= "2.13" support -shared so use it instead of
283+ # -mdll -static
284+ if self .ld_version >= "2.13" :
285+ shared_option = "-shared"
286+ else :
287+ shared_option = "-mdll -static"
288+
265289 # A real mingw32 doesn't need to specify a different entry point,
266290 # but cygwin 2.91.57 in no-cygwin-mode needs it.
267291 if self .gcc_version <= "2.91.57" :
@@ -272,8 +296,9 @@ def __init__ (self,
272296 self .set_executables (compiler = 'gcc -mno-cygwin -O -Wall' ,
273297 compiler_so = 'gcc -mno-cygwin -mdll -O -Wall' ,
274298 linker_exe = 'gcc -mno-cygwin' ,
275- linker_so = '%s -mno-cygwin -mdll %s'
276- % (self .linker_dll , entry_point ))
299+ linker_so = '%s -mno-cygwin %s %s'
300+ % (self .linker_dll , shared_option ,
301+ entry_point ))
277302 # Maybe we should also append -mthreads, but then the finished
278303 # dlls need another dll (mingwm10.dll see Mingw32 docs)
279304 # (-mthreads: Support thread-safe exception handling on `Mingw32')
0 commit comments