aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Lenczewski <michael.lenczewski@gmail.com>2019-08-30 12:34:13 -0500
committerDylan Baker <dylan@pnwbakers.com>2019-10-09 14:24:37 -0700
commit763c1e32809c71e266d97e99f14b588c82284195 (patch)
treec5376b62f3e891bf6ce6c3dff962fc99890e74cc
parentb6af3f38102d57197fbd365d1b2fa57a56c5f457 (diff)
downloadmeson-763c1e32809c71e266d97e99f14b588c82284195.zip
meson-763c1e32809c71e266d97e99f14b588c82284195.tar.gz
meson-763c1e32809c71e266d97e99f14b588c82284195.tar.bz2
Fix for issue 5355
compiler.get_supported_arguments reports success for certain unsupported flags when using the gnu C/ObjC, C++/ObjC++ compilers. This fix reads the stderr on the has_arguments check to ensure the arguments really are supported and not valid for the language selection
-rw-r--r--mesonbuild/compilers/mixins/gnu.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index e4ca14f..a23a24e 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -334,3 +334,15 @@ class GnuCompiler(GnuLikeCompiler):
def openmp_flags(self) -> typing.List[str]:
return ['-fopenmp']
+
+ def has_arguments(self, args, env, code, mode):
+ # For some compiler command line arguments, the GNU compilers will
+ # emit a warning on stderr indicating that an option is valid for a
+ # another language, but still complete with exit_success
+ with self._build_wrapper(code, env, args, None, mode, disable_cache=False, want_output=True) as p:
+ result = p.returncode == 0
+ if self.language in {'cpp', 'objcpp'} and 'is valid for C/ObjC' in p.stde:
+ result = False
+ if self.language in {'c', 'objc'} and 'is valid for C++/ObjC++' in p.stde:
+ result = False
+ return result, p.cached