aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-10-22 07:21:14 -0700
committerGitHub <noreply@github.com>2020-10-22 17:21:14 +0300
commite8399c8c6e237f82c194e0a917767c0dc5e92062 (patch)
treef3b50b4dbe0ab5d016ad666b731594eab1183b19
parente7009d439c8e4e3d5497a6911b63fa6c47bde6b8 (diff)
downloadmeson-e8399c8c6e237f82c194e0a917767c0dc5e92062.zip
meson-e8399c8c6e237f82c194e0a917767c0dc5e92062.tar.gz
meson-e8399c8c6e237f82c194e0a917767c0dc5e92062.tar.bz2
depenencies/llvm: Handle llvm-config --shared-mode failing (#7379)
* depenencies/llvm: Handle llvm-config --shared-mode failing Fixes: #7371 Fixes: #7878 * test cases/llvm: Refactor to use test.json Instead of trying to cover everything internally
-rw-r--r--mesonbuild/dependencies/dev.py8
-rwxr-xr-xrun_project_tests.py6
-rw-r--r--test cases/frameworks/15 llvm/meson.build67
-rw-r--r--test cases/frameworks/15 llvm/meson_options.txt10
-rw-r--r--test cases/frameworks/15 llvm/test.json17
5 files changed, 68 insertions, 40 deletions
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index 99c5c07..c35022d 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -281,7 +281,13 @@ class LLVMDependencyConfigTool(ConfigToolDependency):
def _set_new_link_args(self, environment):
"""How to set linker args for LLVM versions >= 3.9"""
- mode = self.get_config_value(['--shared-mode'], 'link_args')[0]
+ try:
+ mode = self.get_config_value(['--shared-mode'], 'link_args')[0]
+ except IndexError:
+ mlog.debug('llvm-config --shared-mode returned an error')
+ self.is_found = False
+ return
+
if not self.static and mode == 'static':
# If llvm is configured with LLVM_BUILD_LLVM_DYLIB but not with
# LLVM_LINK_LLVM_DYLIB and not LLVM_BUILD_SHARED_LIBS (which
diff --git a/run_project_tests.py b/run_project_tests.py
index 037ba42..acd8590 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -865,6 +865,12 @@ def skippable(suite, test):
if any([x in test for x in ['16 sdl', '17 mpi']]):
return True
+ # We test cmake, and llvm-config. Some linux spins don't provide cmake or
+ # don't provide either the static or shared llvm libraries (fedora and
+ # opensuse only have the dynamic ones, for example).
+ if test.endswith('15 llvm'):
+ return True
+
# No frameworks test should be skipped on linux CI, as we expect all
# prerequisites to be installed
if mesonlib.is_linux():
diff --git a/test cases/frameworks/15 llvm/meson.build b/test cases/frameworks/15 llvm/meson.build
index 4b2c88c..bae83c5 100644
--- a/test cases/frameworks/15 llvm/meson.build
+++ b/test cases/frameworks/15 llvm/meson.build
@@ -1,28 +1,23 @@
project('llvmtest', ['c', 'cpp'], default_options : ['c_std=c99'])
-d = dependency('llvm', required : false, method : 'config-tool')
+method = get_option('method')
+static = get_option('link-static')
+d = dependency('llvm', required : false, method : method, static : static)
if not d.found()
- d = dependency('llvm', required : false, static : true)
- if not d.found()
- error('MESON_SKIP_TEST llvm not found.')
- else
- static = true
- endif
-else
- static = false
+ error('MESON_SKIP_TEST llvm not found.')
endif
-d = dependency('llvm', modules : 'not-found', required : false, static : static)
+d = dependency('llvm', modules : 'not-found', required : false, static : static, method : method)
assert(d.found() == false, 'not-found llvm module found')
-d = dependency('llvm', version : '<0.1', required : false, static : static)
+d = dependency('llvm', version : '<0.1', required : false, static : static, method : method)
assert(d.found() == false, 'ancient llvm module found')
-d = dependency('llvm', optional_modules : 'not-found', required : false, static : static)
+d = dependency('llvm', optional_modules : 'not-found', required : false, static : static, method : method)
assert(d.found() == true, 'optional module stopped llvm from being found.')
# Check we can apply a version constraint
-d = dependency('llvm', version : ['< 500', '>=@0@'.format(d.version())], required: false, static : static)
+d = dependency('llvm', version : ['< 500', '>=@0@'.format(d.version())], required: false, static : static, method : method)
assert(d.found() == true, 'Cannot set version constraints')
dep_tinfo = dependency('tinfo', required : false)
@@ -31,29 +26,23 @@ if not dep_tinfo.found()
dep_tinfo = cpp.find_library('tinfo', required: false)
endif
-foreach method : ['config-tool', 'cmake']
- foreach static : [true, false]
- message('Trying method @0@ for @1@ link'.format(method, static ? 'static' : 'dynamic'))
- llvm_dep = dependency(
- 'llvm',
- modules : ['bitwriter', 'asmprinter', 'executionengine', 'target',
- 'mcjit', 'nativecodegen', 'amdgpu'],
- required : false,
- static : static,
- method : method,
- )
- if llvm_dep.found()
- name = static ? 'static' : 'dynamic'
- executable(
- 'sum-@0@-@1@'.format(name, method),
- 'sum.c',
- dependencies : [
- llvm_dep, dep_tinfo,
- # zlib will be statically linked on windows
- dependency('zlib', required : host_machine.system() != 'windows'),
- meson.get_compiler('c').find_library('dl', required : false),
- ]
- )
- endif
- endforeach
-endforeach
+llvm_dep = dependency(
+ 'llvm',
+ modules : ['bitwriter', 'asmprinter', 'executionengine', 'target',
+ 'mcjit', 'nativecodegen', 'amdgpu'],
+ required : false,
+ static : static,
+ method : method,
+)
+if llvm_dep.found()
+ executable(
+ 'sum',
+ 'sum.c',
+ dependencies : [
+ llvm_dep, dep_tinfo,
+ # zlib will be statically linked on windows
+ dependency('zlib', required : host_machine.system() != 'windows'),
+ meson.get_compiler('c').find_library('dl', required : false),
+ ]
+ )
+endif
diff --git a/test cases/frameworks/15 llvm/meson_options.txt b/test cases/frameworks/15 llvm/meson_options.txt
new file mode 100644
index 0000000..de3d172
--- /dev/null
+++ b/test cases/frameworks/15 llvm/meson_options.txt
@@ -0,0 +1,10 @@
+option(
+ 'method',
+ type : 'combo',
+ choices : ['config-tool', 'cmake']
+)
+option(
+ 'link-static',
+ type : 'boolean',
+ value : false,
+)
diff --git a/test cases/frameworks/15 llvm/test.json b/test cases/frameworks/15 llvm/test.json
new file mode 100644
index 0000000..0cad05a
--- /dev/null
+++ b/test cases/frameworks/15 llvm/test.json
@@ -0,0 +1,17 @@
+{
+ "matrix": {
+ "options": {
+ "method": [
+ { "val": "config-tool" },
+ { "val": "cmake" }
+ ],
+ "link-static": [
+ { "val": true },
+ { "val": false }
+ ]
+ },
+ "exclude": [
+ { "method": "cmake", "link-static": false }
+ ]
+ }
+}