Don't use -fPIC on Cygwin, either

Identify Cygwin-targetted gcc as sui generis (don't use -fPIC, but don't
link with standard Windows libraries, either)

Update tests appropriately
pull/1567/head
Jon Turney 8 years ago
parent c80ca384b2
commit cbc5064a67
  1. 7
      mesonbuild/compilers.py
  2. 3
      mesonbuild/environment.py
  3. 4
      mesonbuild/mesonlib.py
  4. 4
      run_unittests.py

@ -2309,6 +2309,7 @@ class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
GCC_STANDARD = 0
GCC_OSX = 1
GCC_MINGW = 2
GCC_CYGWIN = 3
CLANG_STANDARD = 0
CLANG_OSX = 1
@ -2324,7 +2325,7 @@ def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion, i
sostr = ''
else:
sostr = '.' + soversion
if gcc_type == GCC_STANDARD or gcc_type == GCC_MINGW:
if gcc_type in (GCC_STANDARD, GCC_MINGW, GCC_CYGWIN):
# Might not be correct for mingw but seems to work.
return ['-Wl,-soname,%s%s.%s%s' % (prefix, shlib_name, suffix, sostr)]
elif gcc_type == GCC_OSX:
@ -2398,7 +2399,7 @@ class GnuCompiler:
return self.defines[define]
def get_pic_args(self):
if self.gcc_type in (GCC_MINGW, GCC_OSX):
if self.gcc_type in (GCC_CYGWIN, GCC_MINGW, GCC_OSX):
return [] # On Window and OS X, pic is always on.
return ['-fPIC']
@ -2796,7 +2797,7 @@ class FortranCompiler(Compiler):
return ' '.join(self.exelist)
def get_pic_args(self):
if self.gcc_type in (GCC_MINGW, GCC_OSX):
if self.gcc_type in (GCC_CYGWIN, GCC_MINGW, GCC_OSX):
return [] # On Window and OS X, pic is always on.
return ['-fPIC']

@ -368,7 +368,8 @@ class Environment:
return GCC_OSX
elif '__MINGW32__' in defines or '__MINGW64__' in defines:
return GCC_MINGW
# We ignore Cygwin for now, and treat it as a standard GCC
elif '__CYGWIN__' in defines:
return GCC_CYGWIN
return GCC_STANDARD
def _get_compilers(self, lang, evar, want_cross):

@ -212,6 +212,10 @@ def is_windows():
platname = platform.system().lower()
return platname == 'windows' or 'mingw' in platname
def is_cygwin():
platname = platform.system().lower()
return platname.startswith('cygwin')
def is_debianlike():
return os.path.isfile('/etc/debian_version')

@ -24,7 +24,7 @@ from pathlib import PurePath
import mesonbuild.compilers
import mesonbuild.environment
import mesonbuild.mesonlib
from mesonbuild.mesonlib import is_windows, is_osx
from mesonbuild.mesonlib import is_windows, is_osx, is_cygwin
from mesonbuild.environment import detect_ninja, Environment
from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram
@ -833,6 +833,8 @@ class AllPlatformTests(BasePlatformTests):
self.assertEqual(cc.gcc_type, mesonbuild.compilers.GCC_OSX)
elif is_windows():
self.assertEqual(cc.gcc_type, mesonbuild.compilers.GCC_MINGW)
elif is_cygwin():
self.assertEqual(cc.gcc_type, mesonbuild.compilers.GCC_CYGWIN)
else:
self.assertEqual(cc.gcc_type, mesonbuild.compilers.GCC_STANDARD)
if isinstance(cc, clang):

Loading…
Cancel
Save