diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-02-21 05:09:05 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-02-21 05:45:34 +0530 |
commit | 36b4dec26270e8908307e80fcc174004bc69a181 (patch) | |
tree | ec76ce18bdad8cc8149a14b436a56a2506ae3a84 /mesonbuild/compilers/compilers.py | |
parent | 090eaac91881b3cff50369fa0b1d53dcd5167fe6 (diff) | |
download | meson-36b4dec26270e8908307e80fcc174004bc69a181.zip meson-36b4dec26270e8908307e80fcc174004bc69a181.tar.gz meson-36b4dec26270e8908307e80fcc174004bc69a181.tar.bz2 |
macOS: Remove more unused linkerlike args
`-L` and `-headerpad_max_install_names` are both linker arguments that
are commonly passed in CFLAGS too.
Closes https://github.com/mesonbuild/meson/issues/6294
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r-- | mesonbuild/compilers/compilers.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index e8e72cf..03b1a33 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1059,7 +1059,25 @@ class Compiler: return self.linker.get_undefined_link_args() def remove_linkerlike_args(self, args): - return [x for x in args if not x.startswith('-Wl')] + rm_exact = ('-headerpad_max_install_names',) + rm_prefixes = ('-Wl,', '-L',) + rm_next = ('-L',) + ret = [] + iargs = iter(args) + for arg in iargs: + # Remove this argument + if arg in rm_exact: + continue + # If the argument starts with this, but is not *exactly* this + # f.ex., '-L' should match ['-Lfoo'] but not ['-L', 'foo'] + if arg.startswith(rm_prefixes) and arg not in rm_prefixes: + continue + # Ignore this argument and the one after it + if arg in rm_next: + next(iargs) + continue + ret.append(arg) + return ret def get_lto_compile_args(self) -> T.List[str]: return [] |