Do not use -install_name or -shared when building modules on OSX,

but do use -bundle. Closes #1112.
pull/1126/head
Jussi Pakkanen 8 years ago
parent 6d84b9b646
commit 04a2e6ded3
  1. 8
      mesonbuild/backend/ninjabackend.py
  2. 39
      mesonbuild/compilers.py

@ -1937,13 +1937,17 @@ rule FORTRAN_DEP_HACK
if isinstance(target, build.Executable): if isinstance(target, build.Executable):
commands += linker.get_std_exe_link_args() commands += linker.get_std_exe_link_args()
elif isinstance(target, build.SharedLibrary): elif isinstance(target, build.SharedLibrary):
commands += linker.get_std_shared_lib_link_args() if isinstance(target, build.SharedModule):
commands += linker.get_std_shared_module_link_args()
else:
commands += linker.get_std_shared_lib_link_args()
commands += linker.get_pic_args() commands += linker.get_pic_args()
if hasattr(target, 'soversion'): if hasattr(target, 'soversion'):
soversion = target.soversion soversion = target.soversion
else: else:
soversion = None soversion = None
commands += linker.get_soname_args(target.prefix, target.name, target.suffix, abspath, soversion) commands += linker.get_soname_args(target.prefix, target.name, target.suffix,
abspath, soversion, isinstance(target, build.SharedModule))
# This is only visited when using the Visual Studio toolchain # This is only visited when using the Visual Studio toolchain
if target.vs_module_defs and hasattr(linker, 'gen_vs_module_defs_args'): 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)) commands += linker.gen_vs_module_defs_args(target.vs_module_defs.rel_to_builddir(self.build_to_src))

@ -486,6 +486,12 @@ class Compiler():
def get_link_debugfile_args(self, rel_obj): def get_link_debugfile_args(self, rel_obj):
return [] return []
def get_std_shared_lib_link_args(self):
return []
def get_std_shared_module_link_args(self):
return self.get_std_shared_lib_link_args()
class CCompiler(Compiler): class CCompiler(Compiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None): def __init__(self, exelist, version, is_cross, exe_wrapper=None):
# If a child ObjC or CPP class has already set it, don't set it ourselves # If a child ObjC or CPP class has already set it, don't set it ourselves
@ -1178,9 +1184,6 @@ class MonoCompiler(Compiler):
def get_include_args(self, path): def get_include_args(self, path):
return [] return []
def get_std_shared_lib_link_args(self):
return []
def get_pic_args(self): def get_pic_args(self):
return [] return []
@ -1267,9 +1270,6 @@ class JavaCompiler(Compiler):
def get_include_args(self, path): def get_include_args(self, path):
return [] return []
def get_std_shared_lib_link_args(self):
return []
def get_pic_args(self): def get_pic_args(self):
return [] return []
@ -1962,7 +1962,7 @@ CLANG_OSX = 1
CLANG_WIN = 2 CLANG_WIN = 2
# Possibly clang-cl? # Possibly clang-cl?
def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion): def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion, is_shared_module):
if soversion is None: if soversion is None:
sostr = '' sostr = ''
else: else:
@ -1972,6 +1972,8 @@ def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion):
return ['-Wl,-soname,%s%s.%s%s' % (prefix, shlib_name, suffix, sostr)] return ['-Wl,-soname,%s%s.%s%s' % (prefix, shlib_name, suffix, sostr)]
return ['-Wl,-soname,%s%s' % (shlib_name, sostr)] return ['-Wl,-soname,%s%s' % (shlib_name, sostr)]
elif gcc_type == GCC_OSX: elif gcc_type == GCC_OSX:
if is_shared_module:
return []
return ['-install_name', os.path.join(path, 'lib' + shlib_name + '.dylib')] return ['-install_name', os.path.join(path, 'lib' + shlib_name + '.dylib')]
else: else:
raise RuntimeError('Not implemented yet.') raise RuntimeError('Not implemented yet.')
@ -2007,7 +2009,7 @@ class GnuCompiler:
def get_define(self, define): def get_define(self, define):
if define in self.defines: if define in self.defines:
return defines[define] return self.defines[define]
def get_pic_args(self): def get_pic_args(self):
if self.gcc_type in (GCC_MINGW, GCC_OSX): if self.gcc_type in (GCC_MINGW, GCC_OSX):
@ -2029,8 +2031,13 @@ class GnuCompiler:
def split_shlib_to_parts(self, fname): def split_shlib_to_parts(self, fname):
return (os.path.split(fname)[0], fname) return (os.path.split(fname)[0], fname)
def get_soname_args(self, prefix, shlib_name, suffix, path, soversion): def get_soname_args(self, prefix, shlib_name, suffix, path, soversion, is_shared_module):
return get_gcc_soname_args(self.gcc_type, prefix, shlib_name, suffix, path, soversion) return get_gcc_soname_args(self.gcc_type, prefix, shlib_name, suffix, path, soversion, is_shared_module)
def get_std_shared_lib_link_args(self):
if self.gcc_type == GCC_OSX:
return ['-bundle']
return ['-shared']
class GnuCCompiler(GnuCompiler, CCompiler): class GnuCCompiler(GnuCompiler, CCompiler):
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None): def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None):
@ -2066,6 +2073,9 @@ class GnuCCompiler(GnuCompiler, CCompiler):
return options['c_winlibs'].value[:] return options['c_winlibs'].value[:]
return [] return []
def get_std_shared_lib_link_args(self):
return ['-shared']
class GnuCPPCompiler(GnuCompiler, CPPCompiler): class GnuCPPCompiler(GnuCompiler, CPPCompiler):
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrap, defines): def __init__(self, exelist, version, gcc_type, is_cross, exe_wrap, defines):
@ -2193,6 +2203,11 @@ class ClangCompiler():
extra_args.append('-Wl,-no_weak_imports') extra_args.append('-Wl,-no_weak_imports')
return super().has_function(funcname, prefix, env, extra_args, dependencies) return super().has_function(funcname, prefix, env, extra_args, dependencies)
def get_std_shared_module_link_args(self):
if self.clang_type == CLANG_OSX:
return ['-bundle']
return ['-shared']
class ClangCCompiler(ClangCompiler, CCompiler): class ClangCCompiler(ClangCompiler, CCompiler):
def __init__(self, exelist, version, clang_type, is_cross, exe_wrapper=None): def __init__(self, exelist, version, clang_type, is_cross, exe_wrapper=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
@ -2317,8 +2332,8 @@ end program prog
def split_shlib_to_parts(self, fname): def split_shlib_to_parts(self, fname):
return (os.path.split(fname)[0], fname) return (os.path.split(fname)[0], fname)
def get_soname_args(self, prefix, shlib_name, suffix, path, soversion): def get_soname_args(self, prefix, shlib_name, suffix, path, soversion, is_shared_module):
return get_gcc_soname_args(self.gcc_type, prefix, shlib_name, suffix, path, soversion) return get_gcc_soname_args(self.gcc_type, prefix, shlib_name, suffix, path, soversion, is_shared_module)
def get_dependency_gen_args(self, outtarget, outfile): def get_dependency_gen_args(self, outtarget, outfile):
# Disabled until this is fixed: # Disabled until this is fixed:

Loading…
Cancel
Save