[Openmp-commits] [openmp] [OpenMP] Add extra flags to libomptarget and plugin builds (PR #74520)
Johannes Doerfert via Openmp-commits
openmp-commits at lists.llvm.org
Tue Dec 5 16:00:55 PST 2023
https://github.com/jdoerfert updated https://github.com/llvm/llvm-project/pull/74520
>From f505868953d07125f67bcbb79be426a6deee1a13 Mon Sep 17 00:00:00 2001
From: Johannes Doerfert <johannes at jdoerfert.de>
Date: Tue, 5 Dec 2023 12:35:04 -0800
Subject: [PATCH] [OpenMP] Add extra flags to libomptarget and plugin builds
---
openmp/libomptarget/CMakeLists.txt | 19 +++++++++++++++++++
.../plugins-nextgen/common/CMakeLists.txt | 3 +++
openmp/libomptarget/src/CMakeLists.txt | 3 +++
3 files changed, 25 insertions(+)
diff --git a/openmp/libomptarget/CMakeLists.txt b/openmp/libomptarget/CMakeLists.txt
index 972b887c7c952..fe895d5bc3254 100644
--- a/openmp/libomptarget/CMakeLists.txt
+++ b/openmp/libomptarget/CMakeLists.txt
@@ -75,6 +75,25 @@ if(LIBOMPTARGET_ENABLE_DEBUG)
add_definitions(-DOMPTARGET_DEBUG)
endif()
+# No exceptions and no RTTI, except if requested.
+set(offload_compile_flags -fno-exceptions)
+if(NOT LLVM_ENABLE_RTTI)
+ set(offload_compile_flags ${offload_compile_flags} -fno-rtti)
+endif()
+
+# If LTO is not explicitly disabled we check if we can enable it and do so.
+set(LIBOMPTARGET_USE_LTO TRUE CACHE BOOL "Use LTO for the offload runtimes if available")
+if (LIBOMPTARGET_USE_LTO)
+ include(CheckIPOSupported)
+ check_ipo_supported(RESULT use_lto OUTPUT output)
+ if(use_lto)
+ set(offload_compile_flags ${offload_compile_flags} -flto)
+ set(offload_link_flags ${offload_link_flags} -flto)
+ else()
+ message(WARNING "LTO is not supported: ${output}")
+ endif()
+endif()
+
# OMPT support for libomptarget
# Follow host OMPT support and check if host support has been requested.
# LIBOMP_HAVE_OMPT_SUPPORT indicates whether host OMPT support has been implemented.
diff --git a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
index 5b332ed3d2f41..8ae3ff2a6d291 100644
--- a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
@@ -88,6 +88,9 @@ target_compile_definitions(PluginCommon PRIVATE
DEBUG_PREFIX="PluginInterface"
)
+target_compile_options(PluginCommon PUBLIC ${offload_compile_flags})
+target_link_options(PluginCommon PUBLIC ${offload_link_flags})
+
target_include_directories(PluginCommon
PRIVATE
${LIBOMPTARGET_INCLUDE_DIR}
diff --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt
index 7c311f738ac8e..253e9f0aa176f 100644
--- a/openmp/libomptarget/src/CMakeLists.txt
+++ b/openmp/libomptarget/src/CMakeLists.txt
@@ -55,6 +55,9 @@ target_compile_definitions(omptarget PRIVATE
DEBUG_PREFIX="omptarget"
)
+target_compile_options(omptarget PUBLIC ${offload_compile_flags})
+target_link_options(omptarget PUBLIC ${offload_link_flags})
+
# libomptarget.so needs to be aware of where the plugins live as they
# are now separated in the build directory.
set_target_properties(omptarget PROPERTIES
More information about the Openmp-commits
mailing list