mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 13:40:16 +01:00
clc: speed up compilation by not relying on opencl-c.h
This depends on LLVM change: https://reviews.llvm.org/D125401 Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16479>
This commit is contained in:
parent
e5a052f75f
commit
bcc2df4890
2 changed files with 21 additions and 6 deletions
|
|
@ -55,7 +55,9 @@
|
||||||
#include "spirv.h"
|
#include "spirv.h"
|
||||||
|
|
||||||
#ifdef USE_STATIC_OPENCL_C_H
|
#ifdef USE_STATIC_OPENCL_C_H
|
||||||
|
#if LLVM_VERSION_MAJOR < 15
|
||||||
#include "opencl-c.h.h"
|
#include "opencl-c.h.h"
|
||||||
|
#endif
|
||||||
#include "opencl-c-base.h.h"
|
#include "opencl-c-base.h.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -767,7 +769,11 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
|
||||||
"-triple", "spir64-unknown-unknown",
|
"-triple", "spir64-unknown-unknown",
|
||||||
// By default, clang prefers to use modules to pull in the default headers,
|
// By default, clang prefers to use modules to pull in the default headers,
|
||||||
// which doesn't work with our technique of embedding the headers in our binary
|
// which doesn't work with our technique of embedding the headers in our binary
|
||||||
|
#if LLVM_VERSION_MAJOR >= 15
|
||||||
|
"-fdeclare-opencl-builtins",
|
||||||
|
#else
|
||||||
"-finclude-default-header",
|
"-finclude-default-header",
|
||||||
|
#endif
|
||||||
// Add a default CL compiler version. Clang will pick the last one specified
|
// Add a default CL compiler version. Clang will pick the last one specified
|
||||||
// on the command line, so the app can override this one.
|
// on the command line, so the app can override this one.
|
||||||
"-cl-std=cl1.2",
|
"-cl-std=cl1.2",
|
||||||
|
|
@ -827,9 +833,11 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
|
||||||
clang::frontend::Angled,
|
clang::frontend::Angled,
|
||||||
false, false);
|
false, false);
|
||||||
|
|
||||||
|
#if LLVM_VERSION_MAJOR < 15
|
||||||
::llvm::sys::path::append(system_header_path, "opencl-c.h");
|
::llvm::sys::path::append(system_header_path, "opencl-c.h");
|
||||||
c->getPreprocessorOpts().addRemappedFile(system_header_path.str(),
|
c->getPreprocessorOpts().addRemappedFile(system_header_path.str(),
|
||||||
::llvm::MemoryBuffer::getMemBuffer(llvm::StringRef(opencl_c_source, ARRAY_SIZE(opencl_c_source) - 1)).release());
|
::llvm::MemoryBuffer::getMemBuffer(llvm::StringRef(opencl_c_source, ARRAY_SIZE(opencl_c_source) - 1)).release());
|
||||||
|
#endif
|
||||||
|
|
||||||
::llvm::sys::path::remove_filename(system_header_path);
|
::llvm::sys::path::remove_filename(system_header_path);
|
||||||
::llvm::sys::path::append(system_header_path, "opencl-c-base.h");
|
::llvm::sys::path::append(system_header_path, "opencl-c-base.h");
|
||||||
|
|
@ -846,7 +854,11 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
|
||||||
clang::frontend::Angled,
|
clang::frontend::Angled,
|
||||||
false, false);
|
false, false);
|
||||||
// Add opencl include
|
// Add opencl include
|
||||||
|
#if LLVM_VERSION_MAJOR >= 15
|
||||||
|
c->getPreprocessorOpts().Includes.push_back("opencl-c-base.h");
|
||||||
|
#else
|
||||||
c->getPreprocessorOpts().Includes.push_back("opencl-c.h");
|
c->getPreprocessorOpts().Includes.push_back("opencl-c.h");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (args->num_headers) {
|
if (args->num_headers) {
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,15 @@
|
||||||
|
|
||||||
clang_resource_dir = join_paths(llvm_libdir, 'clang', dep_llvm.version(), 'include')
|
clang_resource_dir = join_paths(llvm_libdir, 'clang', dep_llvm.version(), 'include')
|
||||||
|
|
||||||
opencl_c_h = custom_target(
|
if dep_llvm.version().version_compare('< 15.0')
|
||||||
'opencl-c.h',
|
opencl_c_h = custom_target(
|
||||||
input : [files_xxd, join_paths(clang_resource_dir, 'opencl-c.h')],
|
'opencl-c.h',
|
||||||
output : 'opencl-c.h.h',
|
input : [files_xxd, join_paths(clang_resource_dir, 'opencl-c.h')],
|
||||||
command : [prog_python, '@INPUT@', '@OUTPUT@', '-n', 'opencl_c_source'],
|
output : 'opencl-c.h.h',
|
||||||
)
|
command : [prog_python, '@INPUT@', '@OUTPUT@', '-n', 'opencl_c_source'],
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
opencl_c_base_h = custom_target(
|
opencl_c_base_h = custom_target(
|
||||||
'opencl-c-base.h',
|
'opencl-c-base.h',
|
||||||
input : [files_xxd, join_paths(clang_resource_dir, 'opencl-c-base.h')],
|
input : [files_xxd, join_paths(clang_resource_dir, 'opencl-c-base.h')],
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue