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.
pull/4085/head
Ole André Vadla Ravnås 6 years ago committed by Nirbheek Chauhan
parent a94099bc65
commit a7e6c1aaa4
  1. 7
      mesonbuild/compilers/compilers.py

@ -610,17 +610,18 @@ class CompilerArgs(list):
if get_compiler_uses_gnuld(self.compiler): if get_compiler_uses_gnuld(self.compiler):
global soregex global soregex
group_start = -1 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 \ if not each.startswith('-l') and not each.endswith('.a') and \
not soregex.match(each): not soregex.match(each):
continue continue
i = self.index(each) group_end = i
if group_start < 0: if group_start < 0:
# First occurrence of a library # First occurrence of a library
group_start = i group_start = i
if group_start >= 0: if group_start >= 0:
# Last occurrence of a library # 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') self.insert(group_start, '-Wl,--start-group')
return self.compiler.unix_args_to_native(self) return self.compiler.unix_args_to_native(self)

Loading…
Cancel
Save