aboutsummaryrefslogtreecommitdiff
path: root/test cases/frameworks
diff options
context:
space:
mode:
authorKonstantin <ria.freelander@gmail.com>2022-07-15 15:46:31 +0300
committerDaniel Mensinger <daniel@mensinger-ka.de>2023-01-28 20:16:06 +0100
commit89146e84c9eab649d3847af101d61047cac45765 (patch)
treebc93358ca46ce52bcadf7af4204d8ee78f6bc236 /test cases/frameworks
parent01275fb09ec083aa8328ba100ed665bb9034c914 (diff)
downloadmeson-89146e84c9eab649d3847af101d61047cac45765.zip
meson-89146e84c9eab649d3847af101d61047cac45765.tar.gz
meson-89146e84c9eab649d3847af101d61047cac45765.tar.bz2
cmake: allow dynamic linking with LLVM
llvm-config is unsuitable for standard cross-compile, because we need to build llvm especially for it, which is not done is almost any distros, so, for example, standard bootstrap chroot will be unsuitable. This patch is trying to acheive feature parity between config-tool searching of LLVM and CMake-based one, which is arch-agnostic. Signed-off-by: Konstantin <ria.freelander@gmail.com>
Diffstat (limited to 'test cases/frameworks')
-rw-r--r--test cases/frameworks/15 llvm/meson.build120
-rw-r--r--test cases/frameworks/15 llvm/meson_options.txt2
-rw-r--r--test cases/frameworks/15 llvm/test.json8
3 files changed, 85 insertions, 45 deletions
diff --git a/test cases/frameworks/15 llvm/meson.build b/test cases/frameworks/15 llvm/meson.build
index 3855fae..c8485fb 100644
--- a/test cases/frameworks/15 llvm/meson.build
+++ b/test cases/frameworks/15 llvm/meson.build
@@ -2,50 +2,92 @@ project('llvmtest', ['c', 'cpp'], default_options : ['c_std=c99'])
method = get_option('method')
static = get_option('link-static')
-d = dependency('llvm', required : false, method : method, static : static)
-if not d.found()
- error('MESON_SKIP_TEST llvm not found.')
-endif
-d = dependency('llvm', modules : 'not-found', required : false, static : static, method : method)
-assert(d.found() == false, 'not-found llvm module found')
+if(method == 'combination')
+ d = dependency('llvm', version : static ? '>0.1' : '>=7.0', required : false, static : static)
+ if not d.found()
+ error('MESON_SKIP_TEST llvm not found or llvm version is too low')
+ endif
+ llvm_ct_dep = dependency(
+ 'llvm',
+ modules : ['bitwriter', 'asmprinter', 'executionengine', 'target',
+ 'mcjit', 'nativecodegen', 'amdgpu', 'engine'],
+ required : false,
+ static : static,
+ method : 'config-tool',
+ )
+ llvm_cm_dep = dependency(
+ 'llvm',
+ modules : ['bitwriter', 'asmprinter', 'executionengine', 'target',
+ 'mcjit', 'nativecodegen', 'amdgpu', 'engine'],
+ required : false,
+ static : static,
+ method : 'cmake',
+ )
+ assert(llvm_ct_dep.found() == llvm_cm_dep.found(), 'config-tool and cmake results differ')
+ cm_version_major = llvm_cm_dep.version().split('.')[0].to_int()
+ cm_version_minor = llvm_cm_dep.version().split('.')[1].to_int()
+ ct_version_major = llvm_ct_dep.version().split('.')[0].to_int()
+ ct_version_minor = llvm_ct_dep.version().split('.')[1].to_int()
+ assert(cm_version_major == ct_version_major, 'config-tool and cmake returns different major versions')
+ assert(cm_version_minor == ct_version_minor, 'config-tool and cmake returns different minor versions')
+else
+ d = dependency('llvm', required : false, method : method, static : static)
+ if not d.found()
+ error('MESON_SKIP_TEST llvm not found.')
+ endif
-d = dependency('llvm', version : '<0.1', required : false, static : static, method : method)
-assert(d.found() == false, 'ancient llvm module found')
+ if(not static and method == 'cmake')
+ d = dependency('llvm', version : '>=7.0', required : false, static : static)
+ if not d.found()
+ error('MESON_SKIP_TEST llvm version is too low for cmake dynamic link.')
+ endif
+ endif
-d = dependency('llvm', optional_modules : 'not-found', required : false, static : static, method : method)
-assert(d.found() == true, 'optional module stopped llvm from being found.')
+ d = dependency('llvm', modules : 'not-found', required : false, static : static, method : method)
+ assert(d.found() == false, 'not-found llvm module found')
-# Check we can apply a version constraint
-d = dependency('llvm', version : ['< 500', '>=@0@'.format(d.version())], required: false, static : static, method : method)
-assert(d.found() == true, 'Cannot set version constraints')
+ d = dependency('llvm', version : '<0.1', required : false, static : static, method : method)
+ assert(d.found() == false, 'ancient llvm module found')
-dep_tinfo = dependency('tinfo', required : false)
-if not dep_tinfo.found()
- cpp = meson.get_compiler('cpp')
- dep_tinfo = cpp.find_library('tinfo', required: false)
-endif
+ d = dependency('llvm', optional_modules : 'not-found', required : false, static : static, method : method)
+ assert(d.found() == true, 'optional module stopped llvm from being found.')
-llvm_dep = dependency(
- 'llvm',
- modules : ['bitwriter', 'asmprinter', 'executionengine', 'target',
- 'mcjit', 'nativecodegen', 'amdgpu'],
- required : false,
- static : static,
- method : method,
-)
-
-if not llvm_dep.found()
- error('MESON_SKIP_TEST required llvm modules not found.')
-endif
+ # Check we can apply a version constraint
+ d = dependency('llvm', version : ['< 500', '>=@0@'.format(d.version())], required: false, static : static, method : method)
+ assert(d.found() == true, 'Cannot set version constraints')
-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),
- ]
+ # Check if we have to get pseudo components
+ d = dependency('llvm', modules: ['all-targets','native','engine'], required: false, static : static, method : method)
+ assert(d.found() == true, 'Cannot find pseudo components')
+
+ dep_tinfo = dependency('tinfo', required : false)
+ if not dep_tinfo.found()
+ cpp = meson.get_compiler('cpp')
+ dep_tinfo = cpp.find_library('tinfo', required: false)
+ endif
+
+ llvm_dep = dependency(
+ 'llvm',
+ modules : ['bitwriter', 'asmprinter', 'executionengine', 'target',
+ 'mcjit', 'nativecodegen', 'amdgpu'],
+ required : false,
+ static : static,
+ method : method,
)
+
+ if not llvm_dep.found()
+ error('MESON_SKIP_TEST required llvm modules not found.')
+ endif
+
+ 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
index de3d172..8730c48 100644
--- a/test cases/frameworks/15 llvm/meson_options.txt
+++ b/test cases/frameworks/15 llvm/meson_options.txt
@@ -1,7 +1,7 @@
option(
'method',
type : 'combo',
- choices : ['config-tool', 'cmake']
+ choices : ['config-tool', 'cmake', 'combination']
)
option(
'link-static',
diff --git a/test cases/frameworks/15 llvm/test.json b/test cases/frameworks/15 llvm/test.json
index e70edd5..b39844d 100644
--- a/test cases/frameworks/15 llvm/test.json
+++ b/test cases/frameworks/15 llvm/test.json
@@ -3,16 +3,14 @@
"options": {
"method": [
{ "val": "config-tool", "skip_on_jobname": ["msys2-gcc"]},
- { "val": "cmake", "skip_on_jobname": ["msys2-gcc"] }
+ { "val": "cmake", "skip_on_jobname": ["msys2-gcc"] },
+ { "val": "combination", "skip_on_jobname": ["msys2-gcc"]}
],
"link-static": [
{ "val": true, "skip_on_jobname": ["opensuse"] },
{ "val": false }
]
- },
- "exclude": [
- { "method": "cmake", "link-static": false }
- ]
+ }
},
"skip_on_jobname": ["azure", "cygwin"]
}