aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-07-21 06:07:51 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2017-07-23 02:07:04 +0300
commitb3d048e93a55feaedadb1efae72de0b8871eefab (patch)
tree71fad319fa4d9516c5737f0b15e1f5ee2f823bcc /mesonbuild/compilers/compilers.py
parent5f6add79e0759692dba272e60913c6401f2318ce (diff)
downloadmeson-b3d048e93a55feaedadb1efae72de0b8871eefab.zip
meson-b3d048e93a55feaedadb1efae72de0b8871eefab.tar.gz
meson-b3d048e93a55feaedadb1efae72de0b8871eefab.tar.bz2
CompilerArgs: Put start/end-group around shared libs too
Closes https://github.com/mesonbuild/meson/issues/2096
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 72e1ed3..77b3cb9 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -54,6 +54,9 @@ for _l in clike_langs:
clike_suffixes += lang_suffixes[_l]
clike_suffixes += ('h', 'll', 's')
+# XXX: Use this in is_library()?
+soregex = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$')
+
# All these are only for C-like languages; see `clike_langs` above.
def sort_clike(lang):
@@ -495,20 +498,24 @@ class CompilerArgs(list):
def to_native(self):
# Check if we need to add --start/end-group for circular dependencies
- # between static libraries.
+ # between static libraries, and for recursively searching for symbols
+ # needed by static libraries that are provided by object files or
+ # shared libraries.
if get_compiler_uses_gnuld(self.compiler):
- group_started = False
+ global soregex
+ group_start = -1
for each in self:
- if not each.startswith('-l') and not each.endswith('.a'):
+ if not each.startswith('-l') and not each.endswith('.a') and \
+ not soregex.match(each):
continue
i = self.index(each)
- if not group_started:
+ if group_start < 0:
# First occurance of a library
- self.insert(i, '-Wl,--start-group')
- group_started = True
- # Last occurance of a library
- if group_started:
+ group_start = i
+ if group_start >= 0:
+ # Last occurance of a library
self.insert(i + 1, '-Wl,--end-group')
+ self.insert(group_start, '-Wl,--start-group')
return self.compiler.unix_args_to_native(self)
def append_direct(self, arg):