aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw@src.gnome.org>2018-01-24 22:18:12 +0800
committerJussi Pakkanen <jpakkane@gmail.com>2018-01-30 06:34:34 +1100
commitec5007364487da64545f383b5725ed5074109050 (patch)
tree99912199b7f4c93ecb9d48225918f2422131212e
parent93ba30751e47487268e8f42f763fff362612ff91 (diff)
downloadmeson-ec5007364487da64545f383b5725ed5074109050.zip
meson-ec5007364487da64545f383b5725ed5074109050.tar.gz
meson-ec5007364487da64545f383b5725ed5074109050.tar.bz2
Print warning when linker arguments are passed to has_argument
has_argument and other similar methods of compiler objects only support checking compiler flags. If they are used to check linker flags, the results are very likely to be wrong and developers should be warned.
-rw-r--r--mesonbuild/compilers/c.py7
-rw-r--r--mesonbuild/compilers/cpp.py8
2 files changed, 15 insertions, 0 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 4c6e3a2..5b376e9 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -804,6 +804,13 @@ class CCompiler(Compiler):
return ['-pthread']
def has_multi_arguments(self, args, env):
+ for arg in args:
+ if arg.startswith('-Wl,'):
+ mlog.warning('''{} looks like a linker argument, but has_argument
+and other similar methods only support checking compiler arguments.
+Using them to check linker arguments are never supported, and results
+are likely to be wrong regardless of the compiler you are using.
+'''.format(arg))
return self.compiles('int i;\n', env, extra_args=args)
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 5e32ace..3a7e753 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -14,6 +14,7 @@
import os.path
+from .. import mlog
from .. import coredata
from ..mesonlib import version_compare
@@ -174,6 +175,13 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler):
return []
def has_multi_arguments(self, args, env):
+ for arg in args:
+ if arg.startswith('-Wl,'):
+ mlog.warning('''{} looks like a linker argument, but has_argument
+and other similar methods only support checking compiler arguments.
+Using them to check linker arguments are never supported, and results
+are likely to be wrong regardless of the compiler you are using.
+'''.format(arg))
return super().has_multi_arguments(args + ['-diag-error', '10006'], env)