clc: use CLANG_RESOURCE_DIR for clang's resource path
authorKarol Herbst <git@karolherbst.de>
Tue, 4 Jul 2023 00:15:03 +0000 (02:15 +0200)
committerMarge Bot <emma+marge@anholt.net>
Mon, 14 Aug 2023 10:50:25 +0000 (10:50 +0000)
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 <git@karolherbst.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23981>

docs/rusticl.rst
src/compiler/clc/clc_helpers.cpp

index 7da6376..703bf9b 100644 (file)
@@ -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
index 412a0db..0daf06f 100644 (file)
@@ -39,6 +39,7 @@
 #include <llvm-c/Target.h>
 #include <LLVMSPIRVLib/LLVMSPIRVLib.h>
 
+#include <clang/Config/config.h>
 #include <clang/Driver/Driver.h>
 #include <clang/CodeGen/CodeGenAction.h>
 #include <clang/Lex/PreprocessorOptions.h>
@@ -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;