Skip to content

[CMake] Deduplicate libclc-enabled runtime check - #23066

Open
wenju-he wants to merge 1 commit into
syclfrom
check-libclc-target
Open

[CMake] Deduplicate libclc-enabled runtime check#23066
wenju-he wants to merge 1 commit into
syclfrom
check-libclc-target

Conversation

@wenju-he

@wenju-he wenju-he commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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.

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>
@wenju-he
wenju-he requested review from a team and cperkinsintel September 1, 2026 06:49
@cperkinsintel
cperkinsintel requested a lite review from Copilot September 1, 2026 20:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.cmake providing is_llvm_runtime_enabled(runtime result).
  • Updated sycl/CMakeLists.txt to use the shared helper instead of an inlined loop.
  • Updated sycl-jit/jit-compiler/CMakeLists.txt to 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 YuriPlyakhin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also take into account this duplication?

set(libclc_enabled FALSE)
if("libclc" IN_LIST LLVM_ENABLE_RUNTIMES)
set(libclc_enabled TRUE)
else()
foreach(target ${LLVM_RUNTIME_TARGETS})
if("libclc" IN_LIST RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES)
set(libclc_enabled TRUE)
break()
endif()
endforeach()
endif()

@YuriPlyakhin YuriPlyakhin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as is, but please, consider additional refactoring (see my previous comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants