aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-07-22 12:01:01 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-09-07 14:18:33 +0200
commit8596b3bcd12371ad16e5ffbd3e34953603cd1484 (patch)
tree8a4682d857ef92b827ad6806458a60e7c0b94257 /mesonbuild/compilers
parent90ee43463f4844b667d26230ef7773f63fcf60dd (diff)
downloadmeson-8596b3bcd12371ad16e5ffbd3e34953603cd1484.zip
meson-8596b3bcd12371ad16e5ffbd3e34953603cd1484.tar.gz
meson-8596b3bcd12371ad16e5ffbd3e34953603cd1484.tar.bz2
interpreter: detect and pass compiler to be used for linker tests
Allow using the links method to test that the C++ driver (e.g. g++) can be used to link C objects. One usecase is that the C compiler's libsanitizer might not be compatible with the one included by the C++ driver. This is theoretically backwards-incompatible, but it should be treated as a bugfix in my opinion. There is no way in Meson to compile a .c file with the C++ driver as part of a build target, therefore there would be no reason to do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')). Fixes: #7703
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/__init__.py2
-rw-r--r--mesonbuild/compilers/compilers.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py
index 3d39c9b..895f98d 100644
--- a/mesonbuild/compilers/__init__.py
+++ b/mesonbuild/compilers/__init__.py
@@ -34,6 +34,7 @@ __all__ = [
'is_known_suffix',
'lang_suffixes',
'sort_clink',
+ 'SUFFIX_TO_LANG',
'compiler_from_language',
'detect_compiler_for',
@@ -148,6 +149,7 @@ from .compilers import (
lang_suffixes,
LANGUAGES_USING_LDFLAGS,
sort_clink,
+ SUFFIX_TO_LANG,
)
from .detect import (
compiler_from_language,
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 3d3e57e..ea49833 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -84,6 +84,8 @@ for _l in clink_langs + ('vala',):
clink_suffixes += lang_suffixes[_l]
clink_suffixes += ('h', 'll', 's')
all_suffixes = set(itertools.chain(*lang_suffixes.values(), clink_suffixes)) # type: T.Set[str]
+SUFFIX_TO_LANG = dict(itertools.chain(*(
+ [(suffix, lang) for suffix in v] for lang, v in lang_suffixes.items()))) # type: T.Dict[str, str]
# Languages that should use LDFLAGS arguments when linking.
LANGUAGES_USING_LDFLAGS = {'objcpp', 'cpp', 'objc', 'c', 'fortran', 'd', 'cuda'} # type: T.Set[str]