Check that soname matches the filename. Closes #785.

pull/795/head
Jussi Pakkanen 9 years ago
parent 9fdec2d23f
commit 4dc798dc7e
  1. 3
      mesonbuild/backend/ninjabackend.py
  2. 2
      mesonbuild/compilers.py
  3. 31
      munit.py

@ -1827,7 +1827,8 @@ rule FORTRAN_DEP_HACK
soversion = target.soversion
else:
soversion = None
commands += linker.get_soname_args(target.name, abspath, soversion)
soname = target.prefix + target.name + '.' + target.suffix
commands += linker.get_soname_args(soname, abspath, soversion)
# This is only visited when using the Visual Studio toolchain
if target.vs_module_defs and hasattr(linker, 'gen_vs_module_defs_args'):
commands += linker.gen_vs_module_defs_args(target.vs_module_defs.rel_to_builddir(self.build_to_src))

@ -1894,7 +1894,7 @@ def get_gcc_soname_args(gcc_type, shlib_name, path, soversion):
sostr = '.' + soversion
if gcc_type == GCC_STANDARD or gcc_type == GCC_MINGW:
# Might not be correct for mingw but seems to work.
return ['-Wl,-soname,lib%s.so%s' % (shlib_name, sostr)]
return ['-Wl,-soname,%s%s' % (shlib_name, sostr)]
elif gcc_type == GCC_OSX:
return ['-install_name', os.path.join(path, 'lib' + shlib_name + '.dylib')]
else:

@ -15,26 +15,47 @@
import unittest, os, shutil
import subprocess
import re
def get_soname(fname):
# HACK, fix to not use shell.
raw_out = subprocess.check_output(['readelf', '-a', fname])
pattern = re.compile(b'soname: \[(.*?)\]')
for line in raw_out.split(b'\n'):
m = pattern.search(line)
if m is not None:
return m.group(1)
class LinuxlikeTests(unittest.TestCase):
def setUp(self):
super().setUp()
src_root = os.path.split(__file__)[0]
self.builddir = 'unittestdir' # fixme to be unique
self.meson_command = [os.path.join(src_root, 'meson.py')]
self.ninja_command = ['ninja']
self.ninja_command = ['ninja', '-C', self.builddir]
self.common_test_dir = os.path.join(src_root, 'test cases/common')
self.builddir = 'unittestdir' # fixme to be unique
os.mkdir(self.builddir)
def tearDown(self):
shutil.rmtree(self.builddir)
super().tearDown()
def test_simple(self):
testdir = os.path.join(self.common_test_dir, '1 trivial')
def test_basic_soname(self):
testdir = os.path.join(self.common_test_dir, '4 shared')
subprocess.check_call(self.meson_command + [testdir, self.builddir])
subprocess.check_call(self.ninja_command)
lib1 = os.path.join(self.builddir, 'libmylib.so')
soname = get_soname(lib1)
self.assertEqual(soname, b'libmylib.so')
def test_custom_soname(self):
testdir = os.path.join(self.common_test_dir, '27 library versions')
subprocess.check_call(self.meson_command + [testdir, self.builddir])
subprocess.check_call(self.ninja_command, cwd=self.builddir)
subprocess.check_call(self.ninja_command)
lib1 = os.path.join(self.builddir, 'prefixsomelib.suffix')
soname = get_soname(lib1)
self.assertEqual(soname, b'prefixsomelib.suffix')
if __name__ == '__main__':
unittest.main()

Loading…
Cancel
Save