Skip to content

Commit 332de4b

Browse files
jhuber6sylvestre
andauthored
[Offload] Correctly reject building on unsupported architectures (#92276)
Summary: Previously we had this `LIBOMPTARGET_ENABLED` variable which controlled including `libomptarget`. This is now redundant since it's controlled by `LLVM_ENABLE_RUNTIMES`. However, this had the extra effect of not building it when given unsupported targets. THis was lost during the move to `offload`. This patch moves this logic back and makes the `offload` target just quit without doing anything if used on an unsupported architecture. #91881 #91819 --------- Co-authored-by: Sylvestre Ledru <[email protected]>
1 parent 3f954f5 commit 332de4b

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

offload/CMakeLists.txt

+10-20
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,16 @@ if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
1717
project(offload C CXX ASM)
1818
endif()
1919

20-
set(ENABLE_LIBOMPTARGET ON)
21-
# Currently libomptarget cannot be compiled on Windows or MacOS X.
22-
# Since the device plugins are only supported on Linux anyway,
23-
# there is no point in trying to compile libomptarget on other OSes.
24-
# 32-bit systems are not supported either.
25-
if (APPLE OR WIN32 OR NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
26-
set(ENABLE_LIBOMPTARGET OFF)
27-
endif()
28-
29-
option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
30-
${ENABLE_LIBOMPTARGET})
31-
if (OPENMP_ENABLE_LIBOMPTARGET)
32-
# Check that the library can actually be built.
33-
if (APPLE OR WIN32)
34-
message(FATAL_ERROR "libomptarget cannot be built on Windows and MacOS X!")
35-
elseif (NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
36-
message(FATAL_ERROR "Host compiler must support C++17 to build libomptarget!")
37-
elseif (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
38-
message(FATAL_ERROR "libomptarget on 32-bit systems are not supported!")
39-
endif()
20+
# Check that the library can actually be built.
21+
if(APPLE OR WIN32 OR WASM)
22+
message(WARNING "libomptarget cannot be built on Windows and MacOS X!")
23+
return()
24+
elseif(NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
25+
message(WARNING "Host compiler must support C++17 to build libomptarget!")
26+
return()
27+
elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
28+
message(WARNING "libomptarget on 32-bit systems is not supported!")
29+
return()
4030
endif()
4131

4232
if(OPENMP_STANDALONE_BUILD)

openmp/CMakeLists.txt

-12
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,6 @@ set(OPENMP_TEST_FLAGS "" CACHE STRING
9797
set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING
9898
"OpenMP compiler flag to use for testing OpenMP runtime libraries.")
9999

100-
set(ENABLE_LIBOMPTARGET ON)
101-
# Currently libomptarget cannot be compiled on Windows or MacOS X.
102-
# Since the device plugins are only supported on Linux anyway,
103-
# there is no point in trying to compile libomptarget on other OSes.
104-
# 32-bit systems are not supported either.
105-
if (APPLE OR WIN32 OR WASM OR NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES
106-
OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8 OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
107-
set(ENABLE_LIBOMPTARGET OFF)
108-
endif()
109-
110-
option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
111-
${ENABLE_LIBOMPTARGET})
112100
option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
113101

114102
# Header install location

0 commit comments

Comments
 (0)