Skip to content

Commit 300e5b9

Browse files
authored
[Offload] Fix enabling plugins on unsupported platforms (llvm#93186)
Summary: Certain plugins can only be built on specific platforms. Previously this didn't cause issues becaues each one was handled independently. However, now that we link these all directly they need to be in a CMake list. Furthermore we use this list to generate a config file. For this reason these checks are moved to where we normalize the support. Fixes: llvm#93183
1 parent 4feae05 commit 300e5b9

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

offload/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,25 @@ set(LIBOMPTARGET_PLUGINS_TO_BUILD "all" CACHE STRING
143143
if(LIBOMPTARGET_PLUGINS_TO_BUILD STREQUAL "all")
144144
set(LIBOMPTARGET_PLUGINS_TO_BUILD ${LIBOMPTARGET_ALL_PLUGIN_TARGETS})
145145
endif()
146+
147+
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux" AND
148+
"host" IN_LIST LIBOMPTARGET_PLUGINS_TO_BUILD)
149+
message(STATUS "Not building host plugin: only Linux systems are supported")
150+
list(REMOVE_ITEM LIBOMPTARGET_PLUGINS_TO_BUILD "host")
151+
endif()
152+
if(NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$"
153+
AND CMAKE_SYSTEM_NAME MATCHES "Linux"))
154+
if("amdgpu" IN_LIST LIBOMPTARGET_PLUGINS_TO_BUILD)
155+
message(STATUS "Not building AMDGPU plugin: only support AMDGPU in "
156+
"Linux x86_64, ppc64le, or aarch64 hosts")
157+
list(REMOVE_ITEM LIBOMPTARGET_PLUGINS_TO_BUILD "amdgpu")
158+
endif()
159+
if("nvptx" IN_LIST LIBOMPTARGET_PLUGINS_TO_BUILD)
160+
message(STATUS "Not building CUDA plugin: only support AMDGPU in "
161+
"Linux x86_64, ppc64le, or aarch64 hosts")
162+
list(REMOVE_ITEM LIBOMPTARGET_PLUGINS_TO_BUILD "cuda")
163+
endif()
164+
endif()
146165
message(STATUS "Building the offload library with support for "
147166
"the \"${LIBOMPTARGET_PLUGINS_TO_BUILD}\" plugins")
148167

offload/plugins-nextgen/amdgpu/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# As of rocm-3.7, hsa is installed with cmake packages and kmt is found via hsa
22
find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
33

4-
if(NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux"))
5-
message(STATUS "Not building AMDGPU NextGen plugin: only support AMDGPU in Linux x86_64, ppc64le, or aarch64 hosts")
6-
return()
7-
endif()
8-
94
# Create the library and add the default arguments.
105
add_target_library(omptarget.rtl.amdgpu AMDGPU)
116

offload/plugins-nextgen/cuda/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
if (NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux"))
2-
message(STATUS "Not building CUDA NextGen offloading plugin: only support CUDA in Linux x86_64, ppc64le, or aarch64 hosts.")
3-
return()
4-
endif()
5-
6-
message(STATUS "Building CUDA NextGen offloading plugin.")
7-
81
# Create the library and add the default arguments.
92
add_target_library(omptarget.rtl.cuda CUDA)
103

offload/plugins-nextgen/host/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
2-
return()
3-
endif()
4-
51
set(supported_targets x86_64 aarch64 ppc64 ppc64le s390x)
62
if(NOT ${CMAKE_SYSTEM_PROCESSOR} IN_LIST supported_targets)
73
message(STATUS "Not building ${machine} NextGen offloading plugin")

0 commit comments

Comments
 (0)