[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 15:02:09 PST 2023
https://github.com/jdoerfert updated https://github.com/llvm/llvm-project/pull/74520
>From de23f5ed34ed90b862c27f293a5125fc141c9724 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
---
.../plugins-nextgen/common/CMakeLists.txt | 3 +++
openmp/libomptarget/src/CMakeLists.txt | 22 +++++++++++++++++++
2 files changed, 25 insertions(+)
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..403416a92468c 100644
--- a/openmp/libomptarget/src/CMakeLists.txt
+++ b/openmp/libomptarget/src/CMakeLists.txt
@@ -55,6 +55,28 @@ target_compile_definitions(omptarget PRIVATE
DEBUG_PREFIX="omptarget"
)
+set(offload_compile_flags -fno-exceptions)
+target_compile_options(omptarget PRIVATE )
+
+if(NOT LLVM_ENABLE_RTTI)
+ set(offload_compile_flags ${offload_compile_flags} -fno-rtti)
+endif()
+
+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()
+
+target_compile_options(omptarget PUBLIC ${offload_compile_flags})
+target_link_options(omptarget PUBLIC ${offload_link_flags})
+
+set(offload_link_flags ${offload_link_flags} PARENT_SCOPE)
+set(offload_compile_flags ${offload_compile_flags} PARENT_SCOPE)
+
# 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