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.
pull/2935/merge
Ting-Wei Lan 7 years ago committed by Jussi Pakkanen
parent 93ba30751e
commit ec50073644
  1. 7
      mesonbuild/compilers/c.py
  2. 8
      mesonbuild/compilers/cpp.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)

@ -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)

Loading…
Cancel
Save