[llvm] [openmp] [Offload] Correctly reject building on unsupported architectures (PR #92276)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 09:07:47 PDT 2024
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/92276
>From e3de5b40959c39223910470b40f6c3d46a8bb90e Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 15 May 2024 10:00:14 -0500
Subject: [PATCH 1/2] [Offload] Correctly reject building on unsupported
architectures
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.
https://github.com/llvm/llvm-project/issues/91881
https://github.com/llvm/llvm-project/issues/91819
---
offload/CMakeLists.txt | 30 ++++++++++--------------------
openmp/CMakeLists.txt | 12 ------------
2 files changed, 10 insertions(+), 32 deletions(-)
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 626df81250638..7a99d3fc9ac14 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -17,26 +17,16 @@ if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
project(offload C CXX ASM)
endif()
-set(ENABLE_LIBOMPTARGET ON)
-# Currently libomptarget cannot be compiled on Windows or MacOS X.
-# Since the device plugins are only supported on Linux anyway,
-# there is no point in trying to compile libomptarget on other OSes.
-# 32-bit systems are not supported either.
-if (APPLE OR WIN32 OR NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
- set(ENABLE_LIBOMPTARGET OFF)
-endif()
-
-option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
- ${ENABLE_LIBOMPTARGET})
-if (OPENMP_ENABLE_LIBOMPTARGET)
- # Check that the library can actually be built.
- if (APPLE OR WIN32)
- message(FATAL_ERROR "libomptarget cannot be built on Windows and MacOS X!")
- elseif (NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
- message(FATAL_ERROR "Host compiler must support C++17 to build libomptarget!")
- elseif (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
- message(FATAL_ERROR "libomptarget on 32-bit systems are not supported!")
- endif()
+# Check that the library can actually be built.
+if(APPLE OR WIN32 OR WASM)
+ message(WARNING "libomptarget cannot be built on Windows and MacOS X!")
+ return()
+elseif(NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
+ message(WARNING "Host compiler must support C++17 to build libomptarget!")
+ return()
+elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
+ message(WARNING "libomptarget on 32-bit systems are not yet supported!")
+ return()
endif()
if(OPENMP_STANDALONE_BUILD)
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index 9097ca5623000..33bfdc8630eff 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -97,18 +97,6 @@ set(OPENMP_TEST_FLAGS "" CACHE STRING
set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING
"OpenMP compiler flag to use for testing OpenMP runtime libraries.")
-set(ENABLE_LIBOMPTARGET ON)
-# Currently libomptarget cannot be compiled on Windows or MacOS X.
-# Since the device plugins are only supported on Linux anyway,
-# there is no point in trying to compile libomptarget on other OSes.
-# 32-bit systems are not supported either.
-if (APPLE OR WIN32 OR WASM OR NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES
- OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8 OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
- set(ENABLE_LIBOMPTARGET OFF)
-endif()
-
-option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
- ${ENABLE_LIBOMPTARGET})
option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
# Header install location
>From 2fe9f1fd62c85c499a13c56308bd28848c0bdf40 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 15 May 2024 11:07:40 -0500
Subject: [PATCH 2/2] Update offload/CMakeLists.txt
Co-authored-by: Sylvestre Ledru <sylvestre at debian.org>
---
offload/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 7a99d3fc9ac14..1d8cab240924e 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -25,7 +25,7 @@ elseif(NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
message(WARNING "Host compiler must support C++17 to build libomptarget!")
return()
elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
- message(WARNING "libomptarget on 32-bit systems are not yet supported!")
+ message(WARNING "libomptarget on 32-bit systems is not supported!")
return()
endif()
More information about the llvm-commits
mailing list