Module: Mesa Branch: main Commit: 299f9497758ca5d7278e5aafd210aa91d20dfb4d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=299f9497758ca5d7278e5aafd210aa91d20dfb4d
Author: Karol Herbst <g...@karolherbst.de> Date: Sat Jun 24 10:59:45 2023 +0200 rusticl/meson: generate bindings for LLVM Signed-off-by: Karol Herbst <kher...@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24386> --- src/gallium/frontends/rusticl/meson.build | 37 ++++++++++++++++++++++ .../frontends/rusticl/rusticl_llvm_bindings.hpp | 4 +-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/rusticl/meson.build b/src/gallium/frontends/rusticl/meson.build index 4c83ce6ddda..eb87dad2659 100644 --- a/src/gallium/frontends/rusticl/meson.build +++ b/src/gallium/frontends/rusticl/meson.build @@ -108,6 +108,7 @@ endif rusticl_gen_args = [ # can't do anything about it anyway '-Aclippy::all', + '-Aimproper_ctypes', # Some bindgen versions assume `unsafe_op_in_unsafe_fn` '-Aunused_unsafe', '-Anon_camel_case_types', @@ -211,6 +212,41 @@ rusticl_opencl_gen = static_library( ], ) +rusticl_llvm_bindings_rs = rust.bindgen( + input : 'rusticl_llvm_bindings.hpp', + output : 'rusticl_llvm_bindings.rs', + c_args : [ + rusticl_bindgen_c_args, + pre_args, + ], + dependencies : [ + dep_clang, + dep_llvm, + dep_llvmspirvlib, + ], + args : [ + # we want to limit what to generate bindings for + '--generate', 'constructors,functions,types', + # and all types will be opaque + '--opaque-type', '.*', + # LLVM/Clang/Translator stuff, only used for build-id + # also only use functions from very basic header files, otherwise bindgen might crash :') + '--allowlist-function', 'clang::getClangFullVersion', + '--allowlist-function', 'llvm::LLVMContext::LLVMContext', + '--allowlist-function', 'llvm::writeSpirv', + ], +) + +rusticl_llvm_gen = static_library( + 'rusticl_llvm_gen', + rusticl_llvm_bindings_rs, + gnu_symbol_visibility : 'hidden', + rust_crate_type : 'rlib', + rust_args : [ + rusticl_gen_args, + ], +) + rusticl_system_bindings_wrapper = static_library( 'system_bindings', [ @@ -432,6 +468,7 @@ librusticl = static_library( libmesa_rust, libmesa_rust_gen, libmesa_rust_util, + rusticl_llvm_gen, rusticl_opencl_gen, rusticl_proc_macros, ], diff --git a/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp b/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp index d9fb575a4ab..5aed13b34bb 100644 --- a/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp +++ b/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp @@ -1,4 +1,4 @@ -//#include <clang/Basic/Version.h> -//#include <llvm/IR/LLVMContext.h> +#include <clang/Basic/Version.h> +#include <llvm/IR/LLVMContext.h> #include <LLVMSPIRVLib/LLVMSPIRVLib.h> #include <spirv-tools/linker.hpp>