[llvm] [Offload] Allow building liboffload without libomptarget (PR #159775)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 19 06:14:02 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Ross Brunton (RossBrunton)
<details>
<summary>Changes</summary>
This patch makes `LLVM_ENABLE_RUNTIMES="offload"` build. The
target `libomptarget` will not be available, but `LLVMOffload` will
still be built.
The check target `check-offload` is not available (it has a mix of
both liboffload and libomptarget), but `check-offload-unit` is and
passes.
---
Full diff: https://github.com/llvm/llvm-project/pull/159775.diff
4 Files Affected:
- (modified) llvm/runtimes/CMakeLists.txt (+1-1)
- (modified) offload/CMakeLists.txt (+11)
- (modified) offload/test/CMakeLists.txt (+2)
- (modified) offload/tools/CMakeLists.txt (+3)
``````````diff
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index c98d12ce7992d..90f93c569fdd2 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -209,7 +209,7 @@ foreach(entry ${runtimes})
string(REPLACE "-" "_" canon_name ${name})
string(TOUPPER ${canon_name} canon_name)
list(APPEND prefixes ${canon_name})
- if (${canon_name} STREQUAL "OPENMP")
+ if (${canon_name} STREQUAL "OPENMP" OR ${canon_name} STREQUAL "OFFLOAD")
list(APPEND prefixes "LIBOMP" "LIBOMPTARGET")
endif()
# Many compiler-rt options start with SANITIZER_ and DARWIN_ rather than
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index b277380783500..2385e6245fc84 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -24,6 +24,15 @@ elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
return()
endif()
+set(OPENMP_ENABLED OFF)
+if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
+ set(OPENMP_ENABLED ON)
+endif()
+set(LIBOFFLOAD_ENABLED OFF)
+if("offload" IN_LIST LLVM_ENABLE_RUNTIMES)
+ set(OFFLOAD_ENABLED ON)
+endif()
+
set(OFFLOAD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if(OPENMP_STANDALONE_BUILD)
@@ -376,7 +385,9 @@ add_subdirectory(tools)
add_subdirectory(docs)
# Build target agnostic offloading library.
+if(OPENMP_ENABLED)
add_subdirectory(libomptarget)
+endif()
add_subdirectory(liboffload)
diff --git a/offload/test/CMakeLists.txt b/offload/test/CMakeLists.txt
index 711621de9075d..667014ef5d746 100644
--- a/offload/test/CMakeLists.txt
+++ b/offload/test/CMakeLists.txt
@@ -33,6 +33,7 @@ if(TARGET omp)
set(OMP_DEPEND omp)
endif()
+if(OPENMP_ENABLED)
string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}")
foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET)
@@ -63,6 +64,7 @@ add_offload_testsuite(check-offload
EXCLUDE_FROM_CHECK_ALL
DEPENDS llvm-offload-device-info omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})
+endif()
# Add liboffload unit tests - the test binary will run on all available devices
configure_lit_site_cfg(
diff --git a/offload/tools/CMakeLists.txt b/offload/tools/CMakeLists.txt
index 13772a4a675e5..a877922081710 100644
--- a/offload/tools/CMakeLists.txt
+++ b/offload/tools/CMakeLists.txt
@@ -13,4 +13,7 @@ macro(add_openmp_tool_symlink name)
endmacro()
add_subdirectory(deviceinfo)
+
+if(OPENMP_ENABLED)
add_subdirectory(kernelreplay)
+endif()
``````````
</details>
https://github.com/llvm/llvm-project/pull/159775
More information about the llvm-commits
mailing list