clc: add workaround for clang always defining __IMAGE_SUPPORT_ and __opencl_c_int64

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26764>
This commit is contained in:
Karol Herbst 2023-12-17 23:26:28 +01:00 committed by Marge Bot
parent 07ad6fd34a
commit f8afd41667
2 changed files with 6 additions and 3 deletions

View file

@ -893,6 +893,12 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
c->getPreprocessorOpts().addMacroUndef("__SPIR__");
c->getPreprocessorOpts().addMacroUndef("__SPIRV__");
// clang defines those unconditionally, we need to fix that.
if (!args->features.int64)
c->getPreprocessorOpts().addMacroUndef("__opencl_c_int64");
if (!args->features.images)
c->getPreprocessorOpts().addMacroUndef("__IMAGE_SUPPORT__");
#if LLVM_VERSION_MAJOR >= 14
c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("-all");
c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("+cl_khr_byte_addressable_store");

View file

@ -276,9 +276,6 @@ fn prepare_options(options: &str, dev: &Device) -> Vec<CString> {
options.push_str(" -cl-std=CL");
options.push_str(dev.clc_version.api_str());
}
if !dev.image_supported() {
options.push_str(" -U__IMAGE_SUPPORT__");
}
options.push_str(" -D__OPENCL_VERSION__=");
options.push_str(dev.cl_version.clc_str());