summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/detect.py
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2024-09-30 16:29:40 +0300
committerDylan Baker <dylan@pnwbakers.com>2024-09-30 09:21:01 -0700
commit5399d3de02cb0f92e334f3f5f61cf0aa8521ac63 (patch)
treeecf86329a3b8a78c55f930d244245bb82414b4b4 /mesonbuild/compilers/detect.py
parentddc03e5ab3449efcded44ac35e3d6934bdc85c1e (diff)
downloadmeson-5399d3de02cb0f92e334f3f5f61cf0aa8521ac63.tar.gz
compilers/detect: remove unsupported -cpp flag for Clang preprocessor detection
Clang's resource files, e.g. /usr/share/clang/clang++.cfg, can be used to bump the default standard level across the system. However due to llvm/llvm-project#61641 `clang++ -std=c++17 -E -dM -` doesn't work. The workaround is to pass the language explicitly. 4ad792e158b6059eb847dd0562aff9bd7029981f fixed the issue by passing the language explicitly, but started passing the `-cpp` flag, which Clang doesn't support. Basically Clang would always fallback to the second detection attempt as a result. Remove the unsupported flag and the above scenarios works now too. 🙂 See-also: https://github.com/llvm/llvm-project/issues/61641 Fixes: 4ad792e158b6059eb847dd0562aff9bd7029981f
Diffstat (limited to 'mesonbuild/compilers/detect.py')
-rw-r--r--mesonbuild/compilers/detect.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index 41ecf2528..7542fb628 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -1436,13 +1436,12 @@ def _get_clang_compiler_defines(compiler: T.List[str], lang: str) -> T.Dict[str,
# based on the driver.
lang = clang_lang_map[lang]
- # The compiler may not infer the target language based on the driver name
- # so first, try with '-cpp -x lang', then fallback without given it's less
- # portable. We try with '-cpp' as GCC needs it for Fortran at least, and
- # it seems to do no harm.
- output = _try_obtain_compiler_defines(['-cpp', '-x', lang] + baseline_test_args)
+ # The compiler may not infer the target language based on the driver name.
+ # Try first with '-x lang' to supported systemwide language level overrides,
+ # then fallback to without since it's a more recent option.
+ output = _try_obtain_compiler_defines(['-x', lang] + baseline_test_args)
except (EnvironmentException, KeyError):
- mlog.debug(f'pre-processor extraction using -cpp -x {lang} failed, falling back w/o lang')
+ mlog.debug(f'pre-processor extraction using -x {lang} failed, falling back w/o lang')
output = _try_obtain_compiler_defines(baseline_test_args)
defines: T.Dict[str, str] = {}