Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/targets/opencl/meson.build
4565 views
1
# Copyright © 2017 Intel Corporation
2
3
# Permission is hereby granted, free of charge, to any person obtaining a copy
4
# of this software and associated documentation files (the "Software"), to deal
5
# in the Software without restriction, including without limitation the rights
6
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
# copies of the Software, and to permit persons to whom the Software is
8
# furnished to do so, subject to the following conditions:
9
10
# The above copyright notice and this permission notice shall be included in
11
# all copies or substantial portions of the Software.
12
13
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
# SOFTWARE.
20
21
opencl_link_args = []
22
opencl_link_deps = []
23
opencl_version = '1'
24
25
if with_ld_version_script
26
opencl_link_args += [
27
'-Wl,--version-script', join_paths(meson.current_source_dir(), 'opencl.sym')
28
]
29
opencl_link_deps += files('opencl.sym')
30
endif
31
32
llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir')
33
opencl_libname = with_opencl_icd ? 'MesaOpenCL' : 'OpenCL'
34
35
polly_dep = null_dep
36
polly_isl_dep = null_dep
37
if dep_llvm.version().version_compare('>=10.0.0')
38
polly_dep = cpp.find_library('Polly', dirs : llvm_libdir, required : false)
39
polly_isl_dep = cpp.find_library('PollyISL', dirs : llvm_libdir, required : false)
40
endif
41
42
dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)
43
44
# meson will return clang-cpp from system dirs if it's not found in llvm_libdir
45
linker_rpath_arg = '-Wl,--rpath=@0@'.format(llvm_libdir)
46
clang_test_code = '''
47
#include <clang/Basic/Version.h>
48
int main (void) {
49
size_t found_pos = clang::getClangFullVersion().find(CLANG_VERSION_STRING);
50
return found_pos == ::std::string::npos ? 1 : 0;
51
}
52
'''
53
can_check_clang = (not meson.is_cross_build() or meson.has_exe_wrapper()) and cpp.has_link_argument(linker_rpath_arg)
54
if can_check_clang
55
test_run = cpp.run(clang_test_code, name : 'dep-clang-usable',
56
dependencies : [dep_llvm, dep_clang], args : linker_rpath_arg)
57
dep_clang_usable = test_run.compiled() and test_run.returncode() == 0
58
else
59
dep_clang_usable = true
60
endif
61
if not (dep_clang.found() and dep_clang_usable)
62
dep_clang = [
63
cpp.find_library('clangCodeGen', dirs : llvm_libdir),
64
cpp.find_library('clangFrontendTool', dirs : llvm_libdir),
65
cpp.find_library('clangFrontend', dirs : llvm_libdir),
66
cpp.find_library('clangDriver', dirs : llvm_libdir),
67
cpp.find_library('clangSerialization', dirs : llvm_libdir),
68
cpp.find_library('clangParse', dirs : llvm_libdir),
69
cpp.find_library('clangSema', dirs : llvm_libdir),
70
cpp.find_library('clangAnalysis', dirs : llvm_libdir),
71
cpp.find_library('clangAST', dirs : llvm_libdir),
72
cpp.find_library('clangASTMatchers', dirs : llvm_libdir),
73
cpp.find_library('clangEdit', dirs : llvm_libdir),
74
cpp.find_library('clangLex', dirs : llvm_libdir),
75
cpp.find_library('clangBasic', dirs : llvm_libdir),
76
polly_dep, polly_isl_dep,
77
]
78
# check clang once more
79
if can_check_clang
80
test_run = cpp.run(clang_test_code, name : 'dep-clang-usable',
81
dependencies : [dep_llvm, dep_clang], args : linker_rpath_arg)
82
if not test_run.compiled() or test_run.returncode() != 0
83
error('No usable clang found!')
84
endif
85
endif
86
endif
87
88
# Be explicit about only using this lib on Windows, to avoid picking
89
# up random libs with the generic name 'libversion'
90
if host_machine.system() == 'windows'
91
dep_version = cpp.find_library('version')
92
else
93
dep_version = null_dep
94
endif
95
96
ocldef = files(opencl_libname + '.def')[0]
97
98
libopencl = shared_library(
99
opencl_libname,
100
[],
101
vs_module_defs : ocldef,
102
link_args : [ld_args_gc_sections, opencl_link_args],
103
link_depends : opencl_link_deps,
104
link_whole : libclover,
105
link_with : [libpipe_loader_dynamic, libgallium],
106
dependencies : [
107
idep_mesautil,
108
dep_clock, dep_dl, dep_unwind, dep_elf, dep_clang, dep_version
109
],
110
version : '@[email protected]'.format(opencl_version),
111
install : true,
112
)
113
114
if with_opencl_icd
115
_config = configuration_data()
116
_config.set('OPENCL_LIBNAME', 'MesaOpenCL')
117
_config.set('OPENCL_VERSION', opencl_version)
118
configure_file(
119
configuration : _config,
120
input : 'mesa.icd.in',
121
output : 'mesa.icd',
122
install : true,
123
install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
124
)
125
endif
126
127