aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-04-15 18:16:35 +0300
committerGitHub <noreply@github.com>2017-04-15 18:16:35 +0300
commit4e1249c920a6f64e2ca953334e9ec700f30693da (patch)
tree4ff1e03ac95c0827c6519b0fe684f41602bb47c3 /mesonbuild/compilers.py
parentdcc95d7f705c5fbc036d7d6511f6df50beaac44a (diff)
parent62b86824f03d6b401f7bc8da6ce68b334726df44 (diff)
downloadmeson-4e1249c920a6f64e2ca953334e9ec700f30693da.zip
meson-4e1249c920a6f64e2ca953334e9ec700f30693da.tar.gz
meson-4e1249c920a6f64e2ca953334e9ec700f30693da.tar.bz2
Merge pull request #1549 from mesonbuild/linkwhole
Add option to link the entire contents of a static library to a target.
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r--mesonbuild/compilers.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index e6be8b1..c8ce487 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -707,6 +707,11 @@ class Compiler:
def get_std_shared_module_link_args(self):
return self.get_std_shared_lib_link_args()
+ def get_link_whole_for(self, args):
+ if isinstance(args, list) and len(args) == 0:
+ return []
+ raise EnvironmentException('Language %s does not support linking whole archives.' % self.language)
+
class CCompiler(Compiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None):
# If a child ObjC or CPP class has already set it, don't set it ourselves
@@ -2274,6 +2279,13 @@ class VisualStudioCCompiler(CCompiler):
pdbarr += ['pdb']
return ['/DEBUG', '/PDB:' + '.'.join(pdbarr)]
+ def get_link_whole_for(self, args):
+ # Only since VS2015
+ if not isinstance(args, list):
+ args = [args]
+ return ['/WHOLEARCHIVE:' + x for x in args]
+
+
class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
def __init__(self, exelist, version, is_cross, exe_wrap):
self.language = 'cpp'
@@ -2425,6 +2437,10 @@ class GnuCompiler:
return ['-bundle']
return ['-shared']
+ def get_link_whole_for(self, args):
+ return ['-Wl,--whole-archive'] + args + ['-Wl,--no-whole-archive']
+
+
class GnuCCompiler(GnuCompiler, CCompiler):
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
@@ -2460,6 +2476,7 @@ class GnuCCompiler(GnuCompiler, CCompiler):
def get_std_shared_lib_link_args(self):
return ['-shared']
+
class GnuCPPCompiler(GnuCompiler, CPPCompiler):
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrap, defines):
@@ -2589,6 +2606,15 @@ class ClangCompiler:
return ['-bundle', '-Wl,-undefined,dynamic_lookup']
return ['-shared']
+ def get_link_whole_for(self, args):
+ if self.clang_type == CLANG_OSX:
+ result = []
+ for a in args:
+ result += ['-Wl,-force_load', a]
+ return result
+ return ['-Wl,--whole-archive'] + args + ['-Wl,--no-whole-archive']
+
+
class ClangCCompiler(ClangCompiler, CCompiler):
def __init__(self, exelist, version, clang_type, is_cross, exe_wrapper=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)