aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Reference-manual.md4
-rw-r--r--mesonbuild/build.py8
-rwxr-xr-xrun_unittests.py7
-rw-r--r--test cases/failing/78 link with shared module on osx/meson.build8
-rw-r--r--test cases/failing/78 link with shared module on osx/module.c3
-rw-r--r--test cases/failing/78 link with shared module on osx/prog.c4
6 files changed, 30 insertions, 4 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index a5733a2..cc49e88 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -1161,6 +1161,10 @@ variables defined in the [`executable`](#executable) it is loaded by,
you will need to set the `export_dynamic` argument of the executable to
`true`.
+**Note:** Linking to a shared module is not supported on some platforms, notably
+OSX. Consider using a [`shared_library`](#shared_library) instead, if you need
+to both `dlopen()` and link with a library.
+
*Added 0.37.0*
### static_library()
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 4b42365..36e2e3c 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1086,8 +1086,12 @@ You probably should put it in link_with instead.''')
'''
for link_target in self.link_targets:
if isinstance(link_target, SharedModule):
- mlog.warning('''target links against shared modules. This is not
-recommended as it can lead to undefined behaviour on some platforms''')
+ if for_darwin(self.is_cross, self.environment):
+ raise MesonException('''target links against shared modules.
+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''')
return
class Generator:
diff --git a/run_unittests.py b/run_unittests.py
index f17b69b..61c0816 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1943,14 +1943,17 @@ int main(int argc, char **argv) {
exception_raised = True
self.assertTrue(exception_raised, 'Double locking did not raise exception.')
+ @unittest.skipIf(is_osx(), 'Test not applicable to OSX')
def test_check_module_linking(self):
"""
- Test that shared modules are not linked with targets(link_with:) #2865
+ Test that link_with: a shared module issues a warning
+ https://github.com/mesonbuild/meson/issues/2865
+ (That an error is raised on OSX is exercised by test failing/78)
"""
tdir = os.path.join(self.unit_test_dir, '26 shared_mod linking')
out = self.init(tdir)
msg = ('''WARNING: target links against shared modules. This is not
-recommended as it can lead to undefined behaviour on some platforms''')
+recommended as it is not supported on some platforms''')
self.assertIn(msg, out)
def test_ndebug_if_release_disabled(self):
diff --git a/test cases/failing/78 link with shared module on osx/meson.build b/test cases/failing/78 link with shared module on osx/meson.build
new file mode 100644
index 0000000..2c714f9
--- /dev/null
+++ b/test cases/failing/78 link with shared module on osx/meson.build
@@ -0,0 +1,8 @@
+project('link with shared module', 'c')
+
+if host_machine.system() != 'darwin'
+ error('Test only fails on OSX')
+endif
+
+m = shared_module('mymodule', 'module.c')
+e = executable('prog', 'prog.c', link_with : m)
diff --git a/test cases/failing/78 link with shared module on osx/module.c b/test cases/failing/78 link with shared module on osx/module.c
new file mode 100644
index 0000000..81b0d5a
--- /dev/null
+++ b/test cases/failing/78 link with shared module on osx/module.c
@@ -0,0 +1,3 @@
+int func(void) {
+ return 1496;
+}
diff --git a/test cases/failing/78 link with shared module on osx/prog.c b/test cases/failing/78 link with shared module on osx/prog.c
new file mode 100644
index 0000000..8164d8d
--- /dev/null
+++ b/test cases/failing/78 link with shared module on osx/prog.c
@@ -0,0 +1,4 @@
+
+int main(int argc, char **argv) {
+ return func();
+}