diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2021-11-24 17:29:06 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2021-11-24 23:18:53 +0530 |
commit | af5993fffd37944a15326cb9510775b269352ce0 (patch) | |
tree | 7783fbd8d21a98a70497a9b3e35bffcc85b43b07 /mesonbuild | |
parent | bd9d9818711eaba18b774e17c9ce405c5020c6f9 (diff) | |
download | meson-af5993fffd37944a15326cb9510775b269352ce0.zip meson-af5993fffd37944a15326cb9510775b269352ce0.tar.gz meson-af5993fffd37944a15326cb9510775b269352ce0.tar.bz2 |
shared_module: Add soname when used as a link target
Emit a detailed deprecation warning that explains what to do instead.
Also add a unittest.
```
DEPRECATION: target prog links against shared module mymod, which is incorrect.
This will be an error in the future, so please use shared_library() for mymod instead.
If shared_module() was used for mymod because it has references to undefined symbols,
use shared_libary() with `override_options: ['b_lundef=false']` instead.
```
Fixes https://github.com/mesonbuild/meson/issues/9492
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 2 | ||||
-rw-r--r-- | mesonbuild/build.py | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index a1d3e50..b6621c9 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2785,7 +2785,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): + if not isinstance(target, build.SharedModule) or target.backwards_compat_want_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 6036735..ad18a7f 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1591,11 +1591,16 @@ You probably should put it in link_with instead.''') if isinstance(link_target, SharedModule): if self.environment.machines[self.for_machine].is_darwin(): raise MesonException( - 'target links against shared modules. This is not permitted on OSX') + f'target {self.name} links against shared module {link_target.name}. This is not permitted on OSX') else: - mlog.warning('target links against shared modules. This ' - 'is not recommended as it is not supported on some ' - 'platforms') + mlog.deprecation(f'target {self.name} links against shared module {link_target.name}, which is incorrect.' + '\n ' + f'This will be an error in the future, so please use shared_library() for {link_target.name} instead.' + '\n ' + 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 return class Generator(HoldableObject): @@ -2259,6 +2264,9 @@ class SharedModule(SharedLibrary): raise MesonException('Shared modules must not specify the soversion kwarg.') super().__init__(name, subdir, subproject, for_machine, sources, objects, environment, kwargs) 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 def get_default_install_dir(self, environment) -> T.Tuple[str, str]: return environment.get_shared_module_dir(), '{moduledir_shared}' |