diff options
-rw-r--r-- | mesonbuild/compilers/c.py | 8 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 88ad7b6..b009645 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -427,7 +427,13 @@ class CCompiler(Compiler): args += env.coredata.get_external_preprocess_args(self.language) elif mode == 'compile': # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env - args += env.coredata.get_external_args(self.language) + sys_args = env.coredata.get_external_args(self.language) + # Apparently it is a thing to inject linker flags both + # via CFLAGS _and_ LDFLAGS, even though the former are + # also used during linking. These flags can break + # argument checks. Thanks, Autotools. + cleaned_sys_args = self.remove_linkerlike_args(sys_args) + args += cleaned_sys_args elif mode == 'link': # Add LDFLAGS from the env args += env.coredata.get_external_link_args(self.language) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index f464ec8..3761433 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1271,6 +1271,9 @@ class Compiler: ''' return [] + def remove_linkerlike_args(self, args): + return [x for x in args if not x.startswith('-Wl')] + @enum.unique class CompilerType(enum.Enum): |