From f0fee2e54260a4d227d282da3435f129c6b54687 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 8 Oct 2016 14:34:24 +0200 Subject: [PATCH] Fix soname to work on OSX. --- mesonbuild/backend/ninjabackend.py | 3 +-- mesonbuild/compilers.py | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index f2600cfe6..a29af6094 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1827,8 +1827,7 @@ rule FORTRAN_DEP_HACK soversion = target.soversion else: soversion = None - soname = target.prefix + target.name + '.' + target.suffix - commands += linker.get_soname_args(soname, abspath, soversion) + commands += linker.get_soname_args(target.prefix, target.name, target.suffix, 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)) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index d92d5097c..3cf761abb 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -469,7 +469,7 @@ class CCompiler(Compiler): def get_warn_args(self, level): return self.warn_args[level] - def get_soname_args(self, shlib_name, path, soversion): + def get_soname_args(self, prefix, shlib_name, suffix, path, soversion): return [] def split_shlib_to_parts(self, fname): @@ -1104,7 +1104,7 @@ class MonoCompiler(Compiler): def get_link_args(self, fname): return ['-r:' + fname] - def get_soname_args(self, shlib_name, path, soversion): + def get_soname_args(self, prefix, shlib_name, suffix, path, soversion): return [] def get_werror_args(self): @@ -1191,7 +1191,7 @@ class JavaCompiler(Compiler): self.id = 'unknown' self.javarunner = 'java' - def get_soname_args(self, shlib_name, path, soversion): + def get_soname_args(self, prefix, shlib_name, suffix, path, soversion): return [] def get_werror_args(self): @@ -1466,7 +1466,7 @@ class DCompiler(Compiler): def get_std_shared_lib_link_args(self): return ['-shared'] - def get_soname_args(self, shlib_name, path, soversion): + def get_soname_args(self, prefix, shlib_name, suffix, path, soversion): return [] def get_unittest_args(self): @@ -1887,13 +1887,14 @@ CLANG_OSX = 1 CLANG_WIN = 2 # Possibly clang-cl? -def get_gcc_soname_args(gcc_type, shlib_name, path, soversion): +def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion): if soversion is None: sostr = '' else: 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,%s%s.%s%s' % (prefix, shlib_name, suffix, 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')] @@ -1953,8 +1954,8 @@ class GnuCompiler: def split_shlib_to_parts(self, fname): return (os.path.split(fname)[0], fname) - def get_soname_args(self, shlib_name, path, soversion): - return get_gcc_soname_args(self.gcc_type, shlib_name, path, soversion) + def get_soname_args(self, prefix, shlib_name, suffix, path, soversion): + return get_gcc_soname_args(self.gcc_type, prefix, shlib_name, suffix, path, soversion) class GnuCCompiler(GnuCompiler, CCompiler): def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None): @@ -2079,7 +2080,7 @@ class ClangCompiler(): # so it might change semantics at any time. return ['-include-pch', os.path.join (pch_dir, self.get_pch_name (header))] - def get_soname_args(self, shlib_name, path, soversion): + def get_soname_args(self, prefix, shlib_name, suffix, path, soversion): if self.clang_type == CLANG_STANDARD: gcc_type = GCC_STANDARD elif self.clang_type == CLANG_OSX: @@ -2088,7 +2089,7 @@ class ClangCompiler(): gcc_type = GCC_MINGW else: raise MesonException('Unreachable code when converting clang type to gcc type.') - return get_gcc_soname_args(gcc_type, shlib_name, path, soversion) + return get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion) class ClangCCompiler(ClangCompiler, CCompiler): def __init__(self, exelist, version, clang_type, is_cross, exe_wrapper=None): @@ -2226,8 +2227,8 @@ end program prog def split_shlib_to_parts(self, fname): return (os.path.split(fname)[0], fname) - def get_soname_args(self, shlib_name, path, soversion): - return get_gcc_soname_args(self.gcc_type, shlib_name, path, soversion) + def get_soname_args(self, prefix, shlib_name, suffix, path, soversion): + return get_gcc_soname_args(self.gcc_type, prefix, shlib_name, suffix, path, soversion) def get_dependency_gen_args(self, outtarget, outfile): # Disabled until this is fixed: