def __init__ (self, verbose=0, dry_run=0, force=0): UnixCCompiler.__init__ (self, verbose, dry_run, force) (status, details) = check_config_h() self.debug_print("Python's GCC status: %s (details: %s)" % (status, details)) if status is not CONFIG_H_OK: self.warn( "Python's pyconfig.h doesn't seem to support your compiler. " + ("Reason: %s." % details) + "Compiling may fail because of undefined preprocessor macros.") gcc_version, ld_version, dllwrap_version = get_compiler_versions() self.gcc_version, self.ld_version = gcc_version, ld_version self.debug_print(self.compiler_type + ": gcc %s, ld %s\n" % (self.gcc_version, self.ld_version) ) # Hard-code GCC because that's what this is all about. # XXX optimization, warnings etc. should be customizable. self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall', compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall', linker_exe='gcc -Zomf -Zmt -Zcrtdll', linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll') # want the gcc library statically linked (so that we don't have # to distribute a version dependent on the compiler we have) self.dll_libraries=["gcc"]
def __init__(self, verbose=0, dry_run=0, force=0): UnixCCompiler.__init__(self, verbose, dry_run, force) status, details = check_config_h() self.debug_print("Python's GCC status: %s (details: %s)" % (status, details)) if status is not CONFIG_H_OK: self.warn( "Python's pyconfig.h doesn't seem to support your compiler. " "Reason: %s. " "Compiling may fail because of undefined preprocessor macros." % details) self.gcc_version, self.ld_version, self.dllwrap_version = \ get_compiler_versions() self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" % (self.gcc_version, self.ld_version, self.dllwrap_version) ) # ld_version >= "2.10.90" and < "2.13" should also be able to use # gcc -mdll instead of dllwrap # Older dllwraps had own version numbers, newer ones use the # same as the rest of binutils ( also ld ) # dllwrap 2.10.90 is buggy if self.ld_version >= "2.10.90": self.linker_dll = "gcc" else: self.linker_dll = "dllwrap" # ld_version >= "2.13" support -shared so use it instead of # -mdll -static if self.ld_version >= "2.13": shared_option = "-shared" else: shared_option = "-mdll -static" # Hard-code GCC because that's what this is all about. # XXX optimization, warnings etc. should be customizable. self.set_executables(compiler='gcc -mcygwin -O -Wall', compiler_so='gcc -mcygwin -mdll -O -Wall', compiler_cxx='g++ -mcygwin -O -Wall', linker_exe='gcc -mcygwin', linker_so=('%s -mcygwin %s' % (self.linker_dll, shared_option))) # cygwin and mingw32 need different sets of libraries if self.gcc_version == "2.91.57": # cygwin shouldn't need msvcrt, but without the dlls will crash # (gcc version 2.91.57) -- perhaps something about initialization self.dll_libraries=["msvcrt"] self.warn( "Consider upgrading to a newer version of gcc") else: # Include the appropriate MSVC runtime library if Python was built # with MSVC 7.0 or later. self.dll_libraries = get_msvcr()
def get_versions(): """ Try to find out the versions of gcc, ld and dllwrap. If not possible it returns None for it. """ warn("'distutils.cygwinccompiler.get_versions' is deprecated " "use 'distutils.util.get_compiler_versions' instead", DeprecationWarning) return get_compiler_versions()
def get_versions(): """ Try to find out the versions of gcc and ld. If not possible it returns None for it. """ warn("'distutils.emxccompiler.get_versions' is deprecated " "use 'distutils.util.get_compiler_versions' instead", DeprecationWarning) # EMX ld has no way of reporting version number, and we use GCC # anyway - so we can link OMF DLLs gcc_version, ld_version, dllwrap_version = get_compiler_versions() return gcc_version, None
def __init__(self, dry_run=False, force=False): super(CygwinCCompiler, self).__init__(dry_run, force) status, details = check_config_h() logger.debug("Python's GCC status: %s (details: %s)", status, details) if status is not CONFIG_H_OK: self.warn( "Python's pyconfig.h doesn't seem to support your compiler. " "Reason: %s. " "Compiling may fail because of undefined preprocessor macros." % details) self.gcc_version, self.ld_version, self.dllwrap_version = \ get_compiler_versions() logger.debug(self.name + ": gcc %s, ld %s, dllwrap %s\n", self.gcc_version, self.ld_version, self.dllwrap_version) # ld_version >= "2.10.90" and < "2.13" should also be able to use # gcc -mdll instead of dllwrap # Older dllwraps had own version numbers, newer ones use the # same as the rest of binutils ( also ld ) # dllwrap 2.10.90 is buggy if self.ld_version >= "2.10.90": self.linker_dll = "gcc" else: self.linker_dll = "dllwrap" # ld_version >= "2.13" support -shared so use it instead of # -mdll -static if self.ld_version >= "2.13": shared_option = "-shared" else: shared_option = "-mdll -static" # Hard-code GCC because that's what this is all about. # XXX optimization, warnings etc. should be customizable. self.set_executables(compiler='gcc -mcygwin -O -Wall', compiler_so='gcc -mcygwin -mdll -O -Wall', compiler_cxx='g++ -mcygwin -O -Wall', linker_exe='gcc -mcygwin', linker_so=('%s -mcygwin %s' % (self.linker_dll, shared_option))) # cygwin and mingw32 need different sets of libraries if self.gcc_version == "2.91.57": # cygwin shouldn't need msvcrt, but without the dlls will crash # (gcc version 2.91.57) -- perhaps something about initialization self.dll_libraries = ["msvcrt"] self.warn("Consider upgrading to a newer version of gcc") else: # Include the appropriate MSVC runtime library if Python was built # with MSVC 7.0 or later. self.dll_libraries = get_msvcr()
def test_get_compiler_versions(self): self.mock_popen() # get_versions calls distutils.spawn.find_executable on # 'gcc', 'ld' and 'dllwrap' self.assertEqual(get_compiler_versions(), (None, None, None)) # Let's fake we have 'gcc' and it returns '3.4.5' self._exes['gcc'] = 'gcc (GCC) 3.4.5 (mingw special)\nFSF' res = get_compiler_versions() self.assertEqual(str(res[0]), '3.4.5') # and let's see what happens when the version # doesn't match the regular expression # (\d+\.\d+(\.\d+)*) self._exes['gcc'] = 'very strange output' res = get_compiler_versions() self.assertEqual(res[0], None) # same thing for ld if sys.platform != 'darwin': self._exes['ld'] = 'GNU ld version 2.17.50 20060824' res = get_compiler_versions() self.assertEqual(str(res[1]), '2.17.50') self._exes['ld'] = '@(#)PROGRAM:ld PROJECT:ld64-77' res = get_compiler_versions() self.assertEqual(res[1], None) else: self._exes['ld'] = 'GNU ld version 2.17.50 20060824' res = get_compiler_versions() self.assertEqual(res[1], None) self._exes['ld'] = '@(#)PROGRAM:ld PROJECT:ld64-77' res = get_compiler_versions() self.assertEqual(str(res[1]), '77') # and dllwrap self._exes['dllwrap'] = 'GNU dllwrap 2.17.50 20060824\nFSF' res = get_compiler_versions() self.assertEqual(str(res[2]), '2.17.50') self._exes['dllwrap'] = 'Cheese Wrap' res = get_compiler_versions() self.assertEqual(res[2], None)