Mesa (staging/19.1): meson: Add support for using cmake for finding LLVM
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 28 08:18:43 UTC 2019
Module: Mesa
Branch: staging/19.1
Commit: 421aa4d1625c763c35b05a7103a409a2b190e0f5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=421aa4d1625c763c35b05a7103a409a2b190e0f5
Author: Dylan Baker <dylan at pnwbakers.com>
Date: Wed May 22 11:01:17 2019 -0700
meson: Add support for using cmake for finding LLVM
Meson has support for using cmake as a finder for some dependencies,
including LLVM. Using cmake has a lot of advantages: it needs less meson
maintenance to keep working (even for llvm updates); it works more
sanely for cross compiles (as llvm-config is a compiled binary not a
shell script). Meson 0.51.0 also has a new generic variable getter that
can be used to get information from either cmake, pkg-config, or
config-tools dependencies, which is needed for cmake. We continue to
support using llvm-config if you don't have cmake installed, or if cmake
cannot find a suitable version.
Fixes: 0d59459432cf077d768164091318af8fb1612500
("meson: Force the use of config-tool for llvm")
Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>
(cherry picked from commit 5157a4276500c77e2210e853b262be1d1b30aedf)
---
meson.build | 13 +++++++++++--
src/gallium/drivers/swr/rasterizer/jitter/meson.build | 13 ++++++++-----
src/gallium/state_trackers/clover/meson.build | 13 ++++++++-----
src/gallium/targets/opencl/meson.build | 6 +++++-
4 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/meson.build b/meson.build
index 595260ddec2..b4f359b90be 100644
--- a/meson.build
+++ b/meson.build
@@ -1258,7 +1258,6 @@ if _llvm != 'false'
with_gallium_opencl or _llvm == 'true'
),
static : not _shared_llvm,
- method : 'config-tool',
)
with_llvm = dep_llvm.found()
endif
@@ -1272,7 +1271,17 @@ if with_llvm
# LLVM can be built without rtti, turning off rtti changes the ABI of C++
# programs, so we need to build all C++ code in mesa without rtti as well to
# ensure that linking works.
- if dep_llvm.get_configtool_variable('has-rtti') == 'NO'
+ #
+ # In meson 0.51.0 we can use cmake to find LLVM in addittion to meson's
+ # builtin llvm-config based finder. A new generic variable getter method
+ # has also been added, so we'll use that if we can, to cover the cmake case.
+ if meson.version().version_compare('>=0.51')
+ # The CMake finder will return 'ON', the llvm-config will return 'YES'
+ _rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti'))
+ else
+ _rtti = dep_llvm.get_configtool_variable('has-rtti') == 'YES'
+ endif
+ if not _rtti
if with_gallium_nouveau
error('The Nouveau driver requires rtti. You either need to turn off nouveau or use an LLVM built with LLVM_ENABLE_RTTI.')
elif with_gallium_opencl
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/meson.build b/src/gallium/drivers/swr/rasterizer/jitter/meson.build
index aced4a1b735..6885c344939 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/meson.build
+++ b/src/gallium/drivers/swr/rasterizer/jitter/meson.build
@@ -1,4 +1,4 @@
-# Copyright © 2017-2018 Intel Corporation
+# Copyright © 2017-2019 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -19,14 +19,17 @@
# SOFTWARE.
+if meson.version().version_compare('>=0.51')
+ _llvm_includedir = dep_llvm.get_variable(configtool : 'includedir', cmake : 'LLVM_INCLUDE_DIR')
+else
+ _llvm_includedir = dep_llvm.get_configtool_variable('includedir')
+endif
+
gen_builder_hpp = custom_target(
'gen_builder.hpp',
input : [
swr_gen_llvm_ir_macros_py,
- join_paths(
- dep_llvm.get_configtool_variable('includedir'), 'llvm', 'IR',
- 'IRBuilder.h'
- )
+ join_paths(_llvm_includedir, 'llvm', 'IR', 'IRBuilder.h')
],
output : 'gen_builder.hpp',
command : [
diff --git a/src/gallium/state_trackers/clover/meson.build b/src/gallium/state_trackers/clover/meson.build
index 2ff060bf35b..8f751cbb414 100644
--- a/src/gallium/state_trackers/clover/meson.build
+++ b/src/gallium/state_trackers/clover/meson.build
@@ -1,4 +1,4 @@
-# Copyright © 2017-2018 Intel Corporation
+# Copyright © 2017-2019 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,12 @@ if with_opencl_icd
clover_cpp_args += '-DHAVE_CLOVER_ICD'
endif
+if meson.version().version_compare('>=0.51')
+ _clang_resources = join_paths(dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool : 'libdir'), 'clang', dep_llvm.version(), 'include')
+else
+ _clang_resources = join_paths(dep_llvm.get_configtool_variable('libdir'), 'clang', dep_llvm.version(), 'include')
+endif
+
libclllvm = static_library(
'clllvm',
files(
@@ -43,10 +49,7 @@ libclllvm = static_library(
cpp_vis_args,
'-DLIBCLC_INCLUDEDIR="@0@/"'.format(dep_clc.get_pkgconfig_variable('includedir')),
'-DLIBCLC_LIBEXECDIR="@0@/"'.format(dep_clc.get_pkgconfig_variable('libexecdir')),
- '-DCLANG_RESOURCE_DIR="@0@"'.format(join_paths(
- dep_llvm.get_configtool_variable('libdir'), 'clang',
- dep_llvm.version(), 'include',
- )),
+ '-DCLANG_RESOURCE_DIR="@0@"'.format(_clang_resources),
],
dependencies : [dep_llvm, dep_elf],
override_options : clover_cpp_std,
diff --git a/src/gallium/targets/opencl/meson.build b/src/gallium/targets/opencl/meson.build
index 317ad8dab4a..676e0e13174 100644
--- a/src/gallium/targets/opencl/meson.build
+++ b/src/gallium/targets/opencl/meson.build
@@ -29,7 +29,11 @@ if with_ld_version_script
opencl_link_deps += files('opencl.sym')
endif
-llvm_libdir = dep_llvm.get_configtool_variable('libdir')
+if meson.version().version_compare('>=0.51')
+ llvm_libdir = dep_llvm.get_variable(configtool : 'libdir', cmake : 'LLVM_LIBRARY_DIR')
+else
+ llvm_libdir = dep_llvm.get_configtool_variable('libdir')
+endif
opencl_libname = with_opencl_icd ? 'MesaOpenCL' : 'OpenCL'
More information about the mesa-commit
mailing list