aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/compilers/c.py14
-rw-r--r--test cases/common/191 has link arg/meson.build2
2 files changed, 16 insertions, 0 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 88571a3..e811096 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -59,6 +59,9 @@ class CCompiler(Compiler):
else:
self.exe_wrapper = exe_wrapper
+ # Set to None until we actually need to check this
+ self.has_fatal_warnings_link_arg = None
+
def needs_static_linker(self):
return True # When compiling static libraries, so yes.
@@ -871,6 +874,17 @@ class CCompiler(Compiler):
return self.has_arguments(args, env, code, mode='compile')
def has_multi_link_arguments(self, args, env):
+ # First time we check for link flags we need to first check if we have
+ # --fatal-warnings, otherwise some linker checks could give some
+ # false positive.
+ fatal_warnings_args = ['-Wl,--fatal-warnings']
+ if self.has_fatal_warnings_link_arg is None:
+ self.has_fatal_warnings_link_arg = False
+ self.has_fatal_warnings_link_arg = self.has_multi_link_arguments(fatal_warnings_args, env)
+
+ if self.has_fatal_warnings_link_arg:
+ args = fatal_warnings_args + args
+
args = self.linker_to_compiler_args(args)
code = 'int main(int argc, char **argv) { return 0; }'
return self.has_arguments(args, env, code, mode='link')
diff --git a/test cases/common/191 has link arg/meson.build b/test cases/common/191 has link arg/meson.build
index 255ff45..e166101 100644
--- a/test cases/common/191 has link arg/meson.build
+++ b/test cases/common/191 has link arg/meson.build
@@ -40,3 +40,5 @@ assert(l2.length() == 0, 'First supported did not return empty array.')
assert(not cc.has_multi_link_arguments([isnt_arg, is_arg]), 'Arg that should be broken is not.')
assert(cc.has_multi_link_arguments(is_arg), 'Arg that should have worked does not work.')
assert(cc.has_multi_link_arguments([useless, is_arg]), 'Arg that should have worked does not work.')
+
+assert(not cc.has_link_argument('-Wl,-z,nodelete42'), 'Did not detect wrong -z linker argument')