pull/3277/head
chitranjali 7 years ago
parent b4aee4675a
commit 83766313a7
  1. 8
      mesonbuild/build.py
  2. 11
      run_unittests.py
  3. 1
      test cases/unit/25 shared_mod linking/installed_files.txt
  4. 14
      test cases/unit/25 shared_mod linking/libfile.c
  5. 11
      test cases/unit/25 shared_mod linking/main.c
  6. 6
      test cases/unit/25 shared_mod linking/meson.build

@ -380,6 +380,7 @@ class BuildTarget(Target):
self.process_compilers_late() self.process_compilers_late()
self.validate_sources() self.validate_sources()
self.validate_cross_install(environment) self.validate_cross_install(environment)
self.check_module_linking()
def __lt__(self, other): def __lt__(self, other):
return self.get_id() < other.get_id() 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): def is_linkable_target(self):
return False 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: class Generator:
def __init__(self, args, kwargs): def __init__(self, args, kwargs):

@ -1897,6 +1897,17 @@ int main(int argc, char **argv) {
exception_raised = True exception_raised = True
self.assertTrue(exception_raised, 'Double locking did not raise exception.') 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): def test_ndebug_if_release_disabled(self):
testdir = os.path.join(self.unit_test_dir, '25 ndebug if-release') testdir = os.path.join(self.unit_test_dir, '25 ndebug if-release')
self.init(testdir, extra_args=['--buildtype=release', '-Db_ndebug=if-release']) self.init(testdir, extra_args=['--buildtype=release', '-Db_ndebug=if-release'])

@ -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;
}

@ -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();
}

@ -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)
Loading…
Cancel
Save