llvm: Add support for linking statically

This adds support for the static kwarg to the llvm dependency.
pull/2444/head
Dylan Baker 7 years ago
parent 6cbbbd546e
commit 5584409346
  1. 4
      mesonbuild/dependencies/dev.py
  2. 27
      test cases/frameworks/15 llvm/meson.build

@ -139,6 +139,7 @@ class LLVMDependency(ExternalDependency):
self.provided_modules = []
self.required_modules = set()
self.llvmconfig = None
self.static = kwargs.get('static', False)
self.__best_found = None
# FIXME: Support multiple version requirements ala PkgConfigDependency
req_version = kwargs.get('version', None)
@ -180,8 +181,9 @@ class LLVMDependency(ExternalDependency):
opt_modules = stringlistify(extract_as_list(kwargs, 'optional_modules'))
self.check_components(opt_modules, required=False)
link_args = ['--link-static', '--system-libs'] if self.static else ['--link-shared']
p, out = Popen_safe(
[self.llvmconfig, '--libs', '--ldflags'] + list(self.required_modules))[:2]
[self.llvmconfig, '--libs', '--ldflags'] + link_args + list(self.required_modules))[:2]
if p.returncode != 0:
raise DependencyException('Could not generate libs for LLVM.')
self.link_args = strip_system_libdirs(environment, shlex.split(out))

@ -1,12 +1,5 @@
project('llvmtest', ['c', 'cpp'], default_options : ['c_std=c99'])
llvm_dep = dependency(
'llvm',
modules : ['bitwriter', 'asmprinter', 'executionengine', 'target',
'mcjit', 'nativecodegen'],
required : true,
)
d = dependency('llvm', modules : 'not-found', required : false)
assert(d.found() == false, 'not-found llvm module found')
@ -16,9 +9,23 @@ assert(d.found() == false, 'ancient llvm module found')
d = dependency('llvm', optional_modules : 'not-found', required : false)
assert(d.found() == true, 'optional module stopped llvm from being found.')
executable('sum', 'sum.c', dependencies : [
foreach static : [true, false]
llvm_dep = dependency(
'llvm',
modules : ['bitwriter', 'asmprinter', 'executionengine', 'target',
'mcjit', 'nativecodegen'],
required : true,
static : static,
)
name = static ? 'static' : 'dynamic'
executable(
'sum-@0@'.format(name),
'sum.c',
dependencies : [
llvm_dep,
dependency('zlib'),
meson.get_compiler('c').find_library('dl', required : false),
dependency('glib-2.0'),
])
meson.get_compiler('c').find_library('dl', required : false),
]
)
endforeach

Loading…
Cancel
Save