aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-08-21 13:21:49 -0700
committerDylan Baker <dylan@pnwbakers.com>2019-10-07 10:44:56 -0700
commitff4a17dbef08a1d8afd075f57dbab0f5c76951ab (patch)
tree5c0e08f3150679fd0e220ca1006b7ddee3a08e40
parent1ea3182f827db7c038ac20089437a6202eec02c0 (diff)
downloadmeson-ff4a17dbef08a1d8afd075f57dbab0f5c76951ab.zip
meson-ff4a17dbef08a1d8afd075f57dbab0f5c76951ab.tar.gz
meson-ff4a17dbef08a1d8afd075f57dbab0f5c76951ab.tar.bz2
compilers: Add a specific type for AppleClangC
This allows us to detect use classes rather than methods to determine what C standards are available.
-rw-r--r--mesonbuild/compilers/__init__.py4
-rw-r--r--mesonbuild/compilers/c.py22
-rw-r--r--mesonbuild/compilers/cpp.py5
-rw-r--r--mesonbuild/environment.py23
4 files changed, 42 insertions, 12 deletions
diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py
index c81fe75..c0ad9f6 100644
--- a/mesonbuild/compilers/__init__.py
+++ b/mesonbuild/compilers/__init__.py
@@ -34,6 +34,8 @@ __all__ = [
'lang_suffixes',
'sort_clink',
+ 'AppleClangCCompiler',
+ 'AppleClangCPPCompiler',
'ArmCCompiler',
'ArmCPPCompiler',
'ArmclangCCompiler',
@@ -119,6 +121,7 @@ from .compilers import (
)
from .c import (
CCompiler,
+ AppleClangCCompiler,
ArmCCompiler,
ArmclangCCompiler,
ClangCCompiler,
@@ -134,6 +137,7 @@ from .c import (
)
from .cpp import (
CPPCompiler,
+ AppleClangCPPCompiler,
ArmCPPCompiler,
ArmclangCPPCompiler,
ClangCPPCompiler,
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 1ec9146..7b5d3cc 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -75,6 +75,10 @@ class CCompiler(CLikeCompiler, Compiler):
class ClangCCompiler(ClangCompiler, CCompiler):
+
+ _C17_VERSION = '>=10.0.0'
+ _C18_VERSION = '>=11.0.0'
+
def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs):
CCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs)
ClangCompiler.__init__(self, compiler_type)
@@ -90,12 +94,10 @@ class ClangCCompiler(ClangCompiler, CCompiler):
g_stds = ['gnu89', 'gnu99', 'gnu11']
# https://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html
# https://en.wikipedia.org/wiki/Xcode#Latest_versions
- v = '>=10.0.0' if self.compiler_type is CompilerType.CLANG_OSX else '>=6.0.0'
- if version_compare(self.version, v):
+ if version_compare(self.version, self._C17_VERSION):
c_stds += ['c17']
g_stds += ['gnu17']
- v = '>=11.0.0' if self.compiler_type is CompilerType.CLANG_OSX else '>=8.0.0'
- if version_compare(self.version, v):
+ if version_compare(self.version, self._C18_VERSION):
c_stds += ['c18']
g_stds += ['gnu18']
opts.update({'c_std': coredata.UserComboOption('C language standard to use',
@@ -114,6 +116,18 @@ class ClangCCompiler(ClangCompiler, CCompiler):
return []
+class AppleClangCCompiler(ClangCCompiler):
+
+ """Handle the differences between Apple Clang and Vanilla Clang.
+
+ Right now this just handles the differences between the versions that new
+ C standards were added.
+ """
+
+ _C17_VERSION = '>=6.0.0'
+ _C18_VERSION = '>=8.0.0'
+
+
class EmscriptenCCompiler(LinkerEnvVarsMixin, BasicLinkerIsCompilerMixin, ClangCCompiler):
def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs):
if not is_cross:
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index f93db3e..922a780 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -184,6 +184,11 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
return ['-lstdc++']
+class AppleClangCPPCompiler(ClangCPPCompiler):
+
+ pass
+
+
class EmscriptenCPPCompiler(LinkerEnvVarsMixin, BasicLinkerIsCompilerMixin, ClangCPPCompiler):
def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs):
if not is_cross:
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 03c6568..d488f77 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -65,6 +65,8 @@ from .compilers import (
ArmCPPCompiler,
ArmclangCCompiler,
ArmclangCPPCompiler,
+ AppleClangCCompiler,
+ AppleClangCPPCompiler,
ClangCCompiler,
ClangCPPCompiler,
ClangObjCCompiler,
@@ -947,20 +949,25 @@ class Environment:
return cls(compiler, version, for_machine, is_cross, exe_wrap, target, linker=linker)
if 'clang' in out:
linker = None
- cls = ClangCCompiler if lang == 'c' else ClangCPPCompiler
- if 'Apple' in out or self.machines[for_machine].is_darwin():
- compiler_type = CompilerType.CLANG_OSX
- elif 'windows' in out or self.machines[for_machine].is_windows():
- compiler_type = CompilerType.CLANG_MINGW
- # If we're in a MINGW context this actually will use a gnu style ld
+
+ # Even if the for_machine is darwin, we could be using vanilla
+ # clang.
+ if 'Apple' in out:
+ cls = AppleClangCCompiler if lang == 'c' else AppleClangCPPCompiler
+ else:
+ cls = ClangCCompiler if lang == 'c' else ClangCPPCompiler
+
+ if 'windows' in out or self.machines[for_machine].is_windows():
+ # If we're in a MINGW context this actually will use a gnu
+ # style ld, but for clang on "real" windows we'll use
+ # either link.exe or lld-link.exe
try:
linker = self._guess_win_linker(compiler, for_machine, cls.LINKER_PREFIX)
except MesonException:
pass
- else:
- compiler_type = CompilerType.CLANG_STANDARD
if linker is None:
linker = self._guess_nix_linker(compiler, for_machine, cls.LINKER_PREFIX)
+
return cls(ccache + compiler, version, compiler_type, for_machine, is_cross, exe_wrap, full_version=full_version, linker=linker)
if 'Intel(R) C++ Intel(R)' in err:
version = search_version(err)