aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorOle André Vadla RavnÄs <oleavr@gmail.com>2018-08-22 18:20:13 +0000
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-08-23 19:16:02 -0700
commita7e6c1aaa46749b0e20c91e98869208e5e664500 (patch)
tree49afa9f5649d76e6a0f32453cbc04eae1f725395 /mesonbuild/compilers/compilers.py
parenta94099bc6554cac747475994ba5b6658f7c98bc8 (diff)
downloadmeson-a7e6c1aaa46749b0e20c91e98869208e5e664500.zip
meson-a7e6c1aaa46749b0e20c91e98869208e5e664500.tar.gz
meson-a7e6c1aaa46749b0e20c91e98869208e5e664500.tar.bz2
compilers: Handle dupes in the --start/end-group logic
The index calculated through `self.index()` may find the same flag earlier in the list and end up putting `--end-group` in the wrong spot.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index d08671e..5af4b5d 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -610,17 +610,18 @@ class CompilerArgs(list):
if get_compiler_uses_gnuld(self.compiler):
global soregex
group_start = -1
- for each in self:
+ group_end = -1
+ for i, each in enumerate(self):
if not each.startswith('-l') and not each.endswith('.a') and \
not soregex.match(each):
continue
- i = self.index(each)
+ group_end = i
if group_start < 0:
# First occurrence of a library
group_start = i
if group_start >= 0:
# Last occurrence of a library
- self.insert(i + 1, '-Wl,--end-group')
+ self.insert(group_end + 1, '-Wl,--end-group')
self.insert(group_start, '-Wl,--start-group')
return self.compiler.unix_args_to_native(self)