diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2022-01-10 19:01:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-10 19:01:11 +0200 |
commit | 251d6f0f5db26b82f4f0e78f0552cd606bd8d9dd (patch) | |
tree | 924b11960206319b8b37763a1fbf776d215a0c52 | |
parent | 3ab08265c0526509ea9d5a8e8aff0ff5012f8281 (diff) | |
parent | f30e83efd6968eacf07ebe3f1400e06a8a529778 (diff) | |
download | meson-251d6f0f5db26b82f4f0e78f0552cd606bd8d9dd.zip meson-251d6f0f5db26b82f4f0e78f0552cd606bd8d9dd.tar.gz meson-251d6f0f5db26b82f4f0e78f0552cd606bd8d9dd.tar.bz2 |
Merge pull request #9739 from mathstuf/armclang-support
Armclang support
-rw-r--r-- | docs/markdown/snippets/armclang-support.md | 6 | ||||
-rw-r--r-- | mesonbuild/build.py | 4 | ||||
-rw-r--r-- | mesonbuild/compilers/c.py | 11 | ||||
-rw-r--r-- | mesonbuild/compilers/cpp.py | 12 | ||||
-rw-r--r-- | mesonbuild/compilers/detect.py | 28 | ||||
-rw-r--r-- | mesonbuild/compilers/fortran.py | 6 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/arm.py | 3 |
7 files changed, 67 insertions, 3 deletions
diff --git a/docs/markdown/snippets/armclang-support.md b/docs/markdown/snippets/armclang-support.md new file mode 100644 index 0000000..80e7af2 --- /dev/null +++ b/docs/markdown/snippets/armclang-support.md @@ -0,0 +1,6 @@ +## Support for ARM Ltd. Clang toolchain + +Support for the `armltdclang` compiler has been added. This differs from the +existing `armclang` toolchain in that it is a fork of Clang by ARM Ltd. and +supports native compilation. The Keil `armclang` toolchain only supports +cross-compilation to embedded devices. diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 70f52f9..d8002bf 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1777,8 +1777,8 @@ class Executable(BuildTarget): self.suffix = 'exe' elif machine.system.startswith('wasm') or machine.system == 'emscripten': self.suffix = 'js' - elif ('c' in self.compilers and self.compilers['c'].get_id().startswith('arm') or - 'cpp' in self.compilers and self.compilers['cpp'].get_id().startswith('arm')): + elif ('c' in self.compilers and self.compilers['c'].get_id().startswith('armclang') or + 'cpp' in self.compilers and self.compilers['cpp'].get_id().startswith('armclang')): self.suffix = 'axf' elif ('c' in self.compilers and self.compilers['c'].get_id().startswith('ccrx') or 'cpp' in self.compilers and self.compilers['cpp'].get_id().startswith('ccrx')): diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 9d4a779..30768ad 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -183,6 +183,13 @@ class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler): return [] +class ArmLtdClangCCompiler(ClangCCompiler): + + def __init__(self, *args, **kwargs): + ClangCCompiler.__init__(self, *args, **kwargs) + self.id = 'armltdclang' + + class AppleClangCCompiler(ClangCCompiler): """Handle the differences between Apple Clang and Vanilla Clang. @@ -211,6 +218,10 @@ class EmscriptenCCompiler(EmscriptenMixin, ClangCCompiler): class ArmclangCCompiler(ArmclangCompiler, CCompiler): + ''' + Keil armclang + ''' + def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', exe_wrapper: T.Optional['ExternalProgram'] = None, linker: T.Optional['DynamicLinker'] = None, diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 8bc013f..20df359 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -155,7 +155,7 @@ class CPPCompiler(CLikeCompiler, Compiler): } # Currently, remapping is only supported for Clang, Elbrus and GCC - assert self.id in frozenset(['clang', 'lcc', 'gcc', 'emscripten']) + assert self.id in frozenset(['clang', 'lcc', 'gcc', 'emscripten', 'armltdclang']) if cpp_std not in CPP_FALLBACKS: # 'c++03' and 'c++98' don't have fallback types @@ -259,6 +259,12 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler): return search_dirs + ['-lstdc++'] +class ArmLtdClangCPPCompiler(ClangCPPCompiler): + def __init__(self, *args, **kwargs): + ClangCPPCompiler.__init__(self, *args, **kwargs) + self.id = 'armltdclang' + + class AppleClangCPPCompiler(ClangCPPCompiler): def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]: # We need to apply the search prefix here, as these link arguments may @@ -296,6 +302,10 @@ class EmscriptenCPPCompiler(EmscriptenMixin, ClangCPPCompiler): class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler): + ''' + Keil armclang + ''' + def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', exe_wrapper: T.Optional['ExternalProgram'] = None, linker: T.Optional['DynamicLinker'] = None, diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index 03c5226..572ec35 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -54,6 +54,7 @@ from .c import ( AppleClangCCompiler, ArmCCompiler, ArmclangCCompiler, + ArmLtdClangCCompiler, ClangCCompiler, ClangClCCompiler, GnuCCompiler, @@ -74,6 +75,7 @@ from .cpp import ( AppleClangCPPCompiler, ArmCPPCompiler, ArmclangCPPCompiler, + ArmLtdClangCPPCompiler, ClangCPPCompiler, ClangClCPPCompiler, GnuCPPCompiler, @@ -97,6 +99,7 @@ from .d import ( from .cuda import CudaCompiler from .fortran import ( FortranCompiler, + ArmLtdFlangFortranCompiler, G95FortranCompiler, GnuFortranCompiler, ElbrusFortranCompiler, @@ -462,6 +465,20 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin ccache + compiler, version, for_machine, is_cross, info, exe_wrap, linker=linker, full_version=full_version) + if 'Arm C/C++/Fortran Compiler' in out: + arm_ver_match = re.search('version (\d+)\.(\d+) \(build number (\d+)\)', out) + arm_ver_major = arm_ver_match.group(1) + arm_ver_minor = arm_ver_match.group(2) + arm_ver_build = arm_ver_match.group(3) + version = '.'.join([arm_ver_major, arm_ver_minor, arm_ver_build]) + if lang == 'c': + cls = ArmLtdClangCCompiler + elif lang == 'cpp': + cls = ArmLtdClangCPPCompiler + linker = guess_nix_linker(env, compiler, cls, for_machine) + return cls( + ccache + compiler, version, for_machine, is_cross, info, + exe_wrap, linker=linker) if 'armclang' in out: # The compiler version is not present in the first line of output, # instead it is present in second line, startswith 'Component:'. @@ -711,6 +728,17 @@ def detect_fortran_compiler(env: 'Environment', for_machine: MachineChoice) -> C compiler, version, for_machine, is_cross, info, exe_wrap, defines, full_version=full_version, linker=linker) + if 'Arm C/C++/Fortran Compiler' in out: + cls = ArmLtdFlangFortranCompiler + arm_ver_match = re.search('version (\d+)\.(\d+) \(build number (\d+)\)', out) + arm_ver_major = arm_ver_match.group(1) + arm_ver_minor = arm_ver_match.group(2) + arm_ver_build = arm_ver_match.group(3) + version = '.'.join([arm_ver_major, arm_ver_minor, arm_ver_build]) + linker = guess_nix_linker(env, compiler, cls, for_machine) + return cls( + ccache + compiler, version, for_machine, is_cross, info, + exe_wrap, linker=linker) if 'G95' in out: cls = G95FortranCompiler linker = guess_nix_linker(env, compiler, cls, for_machine) diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 6a4a343..e701ed8 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -494,6 +494,12 @@ class FlangFortranCompiler(ClangCompiler, FortranCompiler): search_dirs.append(f'-L{d}') return search_dirs + ['-lflang', '-lpgmath'] +class ArmLtdFlangFortranCompiler(FlangFortranCompiler): + + def __init__(self, *args, **kwargs): + FlangFortranCompiler.__init__(self, *args, **kwargs) + self.id = 'armltdflang' + class Open64FortranCompiler(FortranCompiler): def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, diff --git a/mesonbuild/compilers/mixins/arm.py b/mesonbuild/compilers/mixins/arm.py index 4e1898a..fc39851 100644 --- a/mesonbuild/compilers/mixins/arm.py +++ b/mesonbuild/compilers/mixins/arm.py @@ -136,6 +136,9 @@ class ArmCompiler(Compiler): class ArmclangCompiler(Compiler): + ''' + This is the Keil armclang. + ''' def __init__(self) -> None: if not self.is_cross: |