[CMake] Deduplicate libclc-enabled runtime check - #23066
Conversation
sycl/CMakeLists.txt and sycl-jit/jit-compiler/CMakeLists.txt each independently looped over LLVM_RUNTIME_TARGETS to determine whether the "libclc" runtime is enabled. Factor that into a shared is_llvm_runtime_enabled(runtime result) function in a new llvm/cmake/modules/CheckEnabledLLVMRuntime.cmake so future callers (e.g. downstream libdevice/offload consumers that need this before runtimes/CMakeLists.txt creates the libclc/libspirv-builtins targets) can reuse it instead of reimplementing the loop or relying on if(TARGET libclc), which evaluates false before those targets exist. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The change is a straightforward refactor into a reusable LLVM CMake module with no functional behavior change beyond deduplicating existing logic.
Pull request overview
This PR factors out the repeated CMake logic used by SYCL and SYCL-JIT to detect whether the libclc runtime is enabled for any configured LLVM_RUNTIME_TARGETS, by introducing a shared helper module in LLVM’s CMake module set.
Changes:
- Added
llvm/cmake/modules/CheckEnabledLLVMRuntime.cmakeprovidingis_llvm_runtime_enabled(runtime result). - Updated
sycl/CMakeLists.txtto use the shared helper instead of an inlined loop. - Updated
sycl-jit/jit-compiler/CMakeLists.txtto use the shared helper instead of an inlined loop.
File summaries
| File | Description |
|---|---|
sycl/CMakeLists.txt |
Replaces duplicated LLVM_RUNTIME_TARGETS scanning logic with is_llvm_runtime_enabled(libclc ...). |
sycl-jit/jit-compiler/CMakeLists.txt |
Replaces duplicated LLVM_RUNTIME_TARGETS scanning logic with is_llvm_runtime_enabled(libclc ...). |
llvm/cmake/modules/CheckEnabledLLVMRuntime.cmake |
Introduces a reusable CMake helper to query enabled LLVM runtimes before runtime targets exist. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
YuriPlyakhin
left a comment
There was a problem hiding this comment.
should we also take into account this duplication?
llvm/llvm/runtimes/CMakeLists.txt
Lines 593 to 603 in c2098bb
YuriPlyakhin
left a comment
There was a problem hiding this comment.
LGTM as is, but please, consider additional refactoring (see my previous comment).
sycl/CMakeLists.txt and sycl-jit/jit-compiler/CMakeLists.txt each independently looped over LLVM_RUNTIME_TARGETS to determine whether the "libclc" runtime is enabled. Factor that into a shared is_llvm_runtime_enabled(runtime result) function in a new llvm/cmake/modules/CheckEnabledLLVMRuntime.cmake so future callers (e.g. downstream libdevice/offload consumers that need this before runtimes/CMakeLists.txt creates the libclc/libspirv-builtins targets) can reuse it instead of reimplementing the loop or relying on if(TARGET libclc), which evaluates false before those targets exist.