aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorDavid Seifert <soap@gentoo.org>2018-03-19 08:16:25 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2018-03-19 23:37:14 +0200
commit7eb187c5f2cf55c6d441db08a87bac02cb58a9dc (patch)
tree57d824083ff7a54fc08752b4574b23bcb8853ed3 /mesonbuild/compilers/compilers.py
parent50c66f1f5c099cb1286dab8a646bed55f39d1e3e (diff)
downloadmeson-7eb187c5f2cf55c6d441db08a87bac02cb58a9dc.zip
meson-7eb187c5f2cf55c6d441db08a87bac02cb58a9dc.tar.gz
meson-7eb187c5f2cf55c6d441db08a87bac02cb58a9dc.tar.bz2
Add -Wl,-dead_strip_dylibs support
* `-Wl,-dead_strip_dylibs` is the analogue of `-Wl,--as-needed` on macOS.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 034fef4..f8dfc96 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -348,7 +348,7 @@ def get_base_link_args(options, linker, is_shared_module):
pass
try:
if 'b_asneeded' in linker.base_options and options['b_asneeded'].value:
- args.append('-Wl,--as-needed')
+ args.append(linker.get_asneeded_args())
except KeyError:
pass
try:
@@ -900,6 +900,13 @@ ICC_STANDARD = 0
ICC_OSX = 1
ICC_WIN = 2
+# GNU ld cannot be installed on macOS
+# https://github.com/Homebrew/homebrew-core/issues/17794#issuecomment-328174395
+# Hence, we don't need to differentiate between OS and ld
+# for the sake of adding as-needed support
+GNU_LD_AS_NEEDED = '-Wl,--as-needed'
+APPLE_LD_AS_NEEDED = '-Wl,-dead_strip_dylibs'
+
def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion, is_shared_module):
if soversion is None:
sostr = ''
@@ -1002,10 +1009,18 @@ class GnuCompiler:
'b_colorout', 'b_ndebug', 'b_staticpic']
if self.gcc_type != GCC_OSX:
self.base_options.append('b_lundef')
- self.base_options.append('b_asneeded')
+ self.base_options.append('b_asneeded')
# All GCC backends can do assembly
self.can_compile_suffixes.add('s')
+ # TODO: centralise this policy more globally, instead
+ # of fragmenting it into GnuCompiler and ClangCompiler
+ def get_asneeded_args(self):
+ if self.gcc_type == GCC_OSX:
+ return APPLE_LD_AS_NEEDED
+ else:
+ return GNU_LD_AS_NEEDED
+
def get_colorout_args(self, colortype):
if mesonlib.version_compare(self.version, '>=4.9.0'):
return gnu_color_args[colortype][:]
@@ -1084,10 +1099,18 @@ class ClangCompiler:
'b_ndebug', 'b_staticpic', 'b_colorout']
if self.clang_type != CLANG_OSX:
self.base_options.append('b_lundef')
- self.base_options.append('b_asneeded')
+ self.base_options.append('b_asneeded')
# All Clang backends can do assembly and LLVM IR
self.can_compile_suffixes.update(['ll', 's'])
+ # TODO: centralise this policy more globally, instead
+ # of fragmenting it into GnuCompiler and ClangCompiler
+ def get_asneeded_args(self):
+ if self.clang_type == CLANG_OSX:
+ return APPLE_LD_AS_NEEDED
+ else:
+ return GNU_LD_AS_NEEDED
+
def get_pic_args(self):
if self.clang_type in (CLANG_WIN, CLANG_OSX):
return [] # On Window and OS X, pic is always on.