aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchitranjali <chitranjali189@gmail.com>2018-03-21 14:19:36 +0530
committerchitranjali <chitranjali189@gmail.com>2018-03-29 13:26:32 +0530
commit83766313a71e79fd81bc6d89cabdb21f90fc3251 (patch)
tree2a4ec073bbd1a1d64c20f5367ce3190b90abf759
parentb4aee4675afd9f9f4a36aea628bab4249d7addbc (diff)
downloadmeson-83766313a71e79fd81bc6d89cabdb21f90fc3251.zip
meson-83766313a71e79fd81bc6d89cabdb21f90fc3251.tar.gz
meson-83766313a71e79fd81bc6d89cabdb21f90fc3251.tar.bz2
fix2865
-rw-r--r--mesonbuild/build.py8
-rwxr-xr-xrun_unittests.py11
-rw-r--r--test cases/unit/25 shared_mod linking/installed_files.txt1
-rw-r--r--test cases/unit/25 shared_mod linking/libfile.c14
-rw-r--r--test cases/unit/25 shared_mod linking/main.c11
-rw-r--r--test cases/unit/25 shared_mod linking/meson.build6
6 files changed, 51 insertions, 0 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 3ff68ed..fac0c42 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -380,6 +380,7 @@ class BuildTarget(Target):
self.process_compilers_late()
self.validate_sources()
self.validate_cross_install(environment)
+ self.check_module_linking()
def __lt__(self, other):
return self.get_id() < other.get_id()
@@ -1027,6 +1028,13 @@ You probably should put it in link_with instead.''')
def is_linkable_target(self):
return False
+ def check_module_linking(self):
+ '''
+ Warn if shared modules are linked with target: (link_with) #2865
+ '''
+ for link_target in self.link_targets:
+ if isinstance(link_target, SharedModule):
+ mlog.warning('''Linking shared modules to targets is not recommended''')
class Generator:
def __init__(self, args, kwargs):
diff --git a/run_unittests.py b/run_unittests.py
index 6ab549c..65ededf 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1897,6 +1897,17 @@ int main(int argc, char **argv) {
exception_raised = True
self.assertTrue(exception_raised, 'Double locking did not raise exception.')
+ def test_check_module_linking(self):
+ '''
+ Test that shared modules are not linked with targets(link_with:) #2865
+ '''
+ tdir = os.path.join(self.unit_test_dir, '25 shared_mod linking')
+ out = self.init(tdir)
+ for expected in [
+ r'WARNING: Linking shared modules to targets is not recommended'
+ ]:
+ self.assertRegex(out, re.escape(expected))
+
def test_ndebug_if_release_disabled(self):
testdir = os.path.join(self.unit_test_dir, '25 ndebug if-release')
self.init(testdir, extra_args=['--buildtype=release', '-Db_ndebug=if-release'])
diff --git a/test cases/unit/25 shared_mod linking/installed_files.txt b/test cases/unit/25 shared_mod linking/installed_files.txt
new file mode 100644
index 0000000..c7dab9f
--- /dev/null
+++ b/test cases/unit/25 shared_mod linking/installed_files.txt
@@ -0,0 +1 @@
+usr/bin/prog?exe
diff --git a/test cases/unit/25 shared_mod linking/libfile.c b/test cases/unit/25 shared_mod linking/libfile.c
new file mode 100644
index 0000000..44f7667
--- /dev/null
+++ b/test cases/unit/25 shared_mod linking/libfile.c
@@ -0,0 +1,14 @@
+#if defined _WIN32 || defined __CYGWIN__
+ #define DLL_PUBLIC __declspec(dllexport)
+#else
+ #if defined __GNUC__
+ #define DLL_PUBLIC __attribute__ ((visibility("default")))
+ #else
+ #pragma message ("Compiler does not support symbol visibility.")
+ #define DLL_PUBLIC
+ #endif
+#endif
+
+int DLL_PUBLIC func() {
+ return 0;
+}
diff --git a/test cases/unit/25 shared_mod linking/main.c b/test cases/unit/25 shared_mod linking/main.c
new file mode 100644
index 0000000..12f9c98
--- /dev/null
+++ b/test cases/unit/25 shared_mod linking/main.c
@@ -0,0 +1,11 @@
+#if defined _WIN32 || defined __CYGWIN__
+ #define DLL_IMPORT __declspec(dllimport)
+#else
+ #define DLL_IMPORT
+#endif
+
+int DLL_IMPORT func();
+
+int main(int argc, char **arg) {
+ return func();
+}
diff --git a/test cases/unit/25 shared_mod linking/meson.build b/test cases/unit/25 shared_mod linking/meson.build
new file mode 100644
index 0000000..d8934e9
--- /dev/null
+++ b/test cases/unit/25 shared_mod linking/meson.build
@@ -0,0 +1,6 @@
+project('shared library linking test', 'c', 'cpp')
+
+lib = shared_module('mylib',
+ 'libfile.c' # Split to different lines before and after the comma to test parser.
+ , install : false) # Don't install libraries in common tests; the path is platform-specific
+exe = executable('prog', 'main.c', link_with : lib, install : true) \ No newline at end of file