aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2022-02-14 22:02:35 +0530
committerEli Schwartz <eschwartz93@gmail.com>2022-02-14 23:30:24 -0500
commit2d56ff135e6e0f3cdf455797a6561796a8c1b7b4 (patch)
tree26078410b16d584f0e02b72181d4f98b7b34bb6c /mesonbuild
parent39f61795ca1ae7de3c4c1fc08f88b3d864502cec (diff)
downloadmeson-2d56ff135e6e0f3cdf455797a6561796a8c1b7b4.zip
meson-2d56ff135e6e0f3cdf455797a6561796a8c1b7b4.tar.gz
meson-2d56ff135e6e0f3cdf455797a6561796a8c1b7b4.tar.bz2
shared module: Allow linking on Android
Android requires shared modules that use symbols from other shared modules to be linked before they can be dlopen()ed in the correct order. Not doing so leads to a missing symbol error: https://github.com/android/ndk/issues/201 We need to always allow linking for this. Also add a soname, although it's not confirmed that it's needed, and it doesn't really hurt if it isn't needed.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/ninjabackend.py2
-rw-r--r--mesonbuild/build.py11
2 files changed, 9 insertions, 4 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index f4df789..560fe53 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2792,7 +2792,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
commands += linker.get_std_shared_lib_link_args()
# All shared libraries are PIC
commands += linker.get_pic_args()
- if not isinstance(target, build.SharedModule) or target.backwards_compat_want_soname:
+ if not isinstance(target, build.SharedModule) or target.force_soname:
# Add -Wl,-soname arguments on Linux, -install_name on OS X
commands += linker.get_soname_args(
self.environment, target.prefix, target.name, target.suffix,
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 27e6d36..cdd761f 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1589,10 +1589,15 @@ You probably should put it in link_with instead.''')
Warn if shared modules are linked with target: (link_with) #2865
'''
for link_target in self.link_targets:
- if isinstance(link_target, SharedModule) and not link_target.backwards_compat_want_soname:
+ if isinstance(link_target, SharedModule) and not link_target.force_soname:
if self.environment.machines[self.for_machine].is_darwin():
raise MesonException(
f'target {self.name} links against shared module {link_target.name}. This is not permitted on OSX')
+ elif self.environment.machines[self.for_machine].is_android() and isinstance(self, SharedModule):
+ # Android requires shared modules that use symbols from other shared modules to
+ # be linked before they can be dlopen()ed in the correct order. Not doing so
+ # leads to a missing symbol error: https://github.com/android/ndk/issues/201
+ link_target.force_soname = True
else:
mlog.deprecation(f'target {self.name} links against shared module {link_target.name}, which is incorrect.'
'\n '
@@ -1601,7 +1606,7 @@ You probably should put it in link_with instead.''')
f'If shared_module() was used for {link_target.name} because it has references to undefined symbols,'
'\n '
'use shared_libary() with `override_options: [\'b_lundef=false\']` instead.')
- link_target.backwards_compat_want_soname = True
+ link_target.force_soname = True
class Generator(HoldableObject):
def __init__(self, exe: T.Union['Executable', programs.ExternalProgram],
@@ -2270,7 +2275,7 @@ class SharedModule(SharedLibrary):
self.typename = 'shared module'
# We need to set the soname in cases where build files link the module
# to build targets, see: https://github.com/mesonbuild/meson/issues/9492
- self.backwards_compat_want_soname = False
+ self.force_soname = False
def get_default_install_dir(self, environment) -> T.Tuple[str, str]:
return environment.get_shared_module_dir(), '{moduledir_shared}'