From e1c278ae825958186418cc8201a6f49f74b75181 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 4 Jul 2023 02:15:03 +0200 Subject: [PATCH] clc: use CLANG_RESOURCE_DIR for clang's resource path With certain build configuration that value can be a non empty string and needs to be used. This will also require distributions to rebuild mesa if and only if CLANG_RESOURCE_DIR changes between clang rebuilds or updates. Signed-off-by: Karol Herbst Part-of: --- docs/rusticl.rst | 3 +++ src/compiler/clc/clc_helpers.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/rusticl.rst b/docs/rusticl.rst index 7da6376e5cf..703bf9b94e5 100644 --- a/docs/rusticl.rst +++ b/docs/rusticl.rst @@ -33,6 +33,9 @@ The minimum versions to build Rusticl are: - Meson: 1.2.0 - Bindgen: 0.62.0 - LLVM: 11.0.0 (recommended: 15.0.0) +- Clang: 11.0.0 (recommended: 15.0.0) + Updating clang requires a rebuilt of mesa and rusticl if and only if the value of + ``CLANG_RESOURCE_DIR`` changes. It is defined through ``clang/Config/config.h``. - SPIRV-Tools: any version (recommended: v2022.3) Afterwards you only need to add ``-Dgallium-rusticl=true -Dllvm=enabled diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp index 412a0dbf93d..0daf06f1e7c 100644 --- a/src/compiler/clc/clc_helpers.cpp +++ b/src/compiler/clc/clc_helpers.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -76,6 +77,7 @@ using ::llvm::Function; using ::llvm::LLVMContext; using ::llvm::Module; using ::llvm::raw_string_ostream; +using ::clang::driver::Driver; static void llvm_log_handler(const ::llvm::DiagnosticInfo &di, void *data) { @@ -877,7 +879,7 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx, // because we might have linked clang statically. auto libclang_path = fs::path(LLVM_LIB_DIR) / "libclang.so"; auto clang_res_path = - fs::path(clang::driver::Driver::GetResourcesPath(libclang_path.string())) / "include"; + fs::path(Driver::GetResourcesPath(libclang_path.string(), CLANG_RESOURCE_DIR)) / "include"; c->getHeaderSearchOpts().UseBuiltinIncludes = true; c->getHeaderSearchOpts().UseStandardSystemIncludes = true;