diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-11-23 21:35:52 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-12-11 14:54:30 +0530 |
commit | 04c1909a4dcc4f92c845eabab5515419f0881dc5 (patch) | |
tree | 8c2bdf0a54e644a1982bf1354895e51e67493e7f /mesonbuild/compilers.py | |
parent | 38f6fee86defebc6ccbc68c21ff857f6111ed874 (diff) | |
download | meson-04c1909a4dcc4f92c845eabab5515419f0881dc5.zip meson-04c1909a4dcc4f92c845eabab5515419f0881dc5.tar.gz meson-04c1909a4dcc4f92c845eabab5515419f0881dc5.tar.bz2 |
compilers: Implement support for LLVM IR compilation
Also C++ compilers can build .S assembly files. This wasn't noticed
earlier because most people were also using C compilers in their C++
projects and we would fall back to using the C compiler for building the
assembly files. Now we have a test for this.
This was trivial to add; except that we needed a new LLVM IR rule
because the compiler emits warnings if you pass any special arguments to
it such as include arguments or dependency arguments.
Closes #1089
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r-- | mesonbuild/compilers.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 2ee4aac..08ebbfb 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -59,6 +59,11 @@ def is_source(fname): suffix = fname.split('.')[-1] return suffix in clike_suffixes +def is_llvm_ir(fname): + if hasattr(fname, 'fname'): + fname = fname.fname + return fname.split('.')[-1] == 'll' + def is_object(fname): if hasattr(fname, 'fname'): fname = fname.fname @@ -2018,6 +2023,8 @@ class GnuCompiler: if self.gcc_type != GCC_OSX: self.base_options.append('b_lundef') self.base_options.append('b_asneeded') + # All GCC backends can do assembly + self.can_compile_suffixes.add('s') def get_colorout_args(self, colortype): if mesonlib.version_compare(self.version, '>=4.9.0'): @@ -2071,8 +2078,6 @@ class GnuCCompiler(GnuCompiler, CCompiler): def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) GnuCompiler.__init__(self, gcc_type, defines) - # Gcc can do asm, too. - self.can_compile_suffixes.add('s') self.warn_args = {'1': ['-Wall', '-Winvalid-pch'], '2': ['-Wall', '-Wextra', '-Winvalid-pch'], '3' : ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']} @@ -2185,6 +2190,8 @@ class ClangCompiler(): if self.clang_type != CLANG_OSX: self.base_options.append('b_lundef') self.base_options.append('b_asneeded') + # All Clang backends can do assembly and LLVM IR + self.can_compile_suffixes.update(['ll', 's']) def get_pic_args(self): if self.clang_type in (CLANG_WIN, CLANG_OSX): @@ -2240,8 +2247,6 @@ class ClangCCompiler(ClangCompiler, CCompiler): def __init__(self, exelist, version, clang_type, is_cross, exe_wrapper=None): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) ClangCompiler.__init__(self, clang_type) - # Clang can do asm, too. - self.can_compile_suffixes.add('s') self.warn_args = {'1': ['-Wall', '-Winvalid-pch'], '2': ['-Wall', '-Wextra', '-Winvalid-pch'], '3' : ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']} |