[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 12:37:30 PST 2023


https://github.com/jdoerfert created https://github.com/llvm/llvm-project/pull/74520

None

>From 4503259bcc55f29f98efaf587c9a21ad7c2abfe1 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        | 16 ++++++++++++++++
 openmp/libomptarget/src/CMakeLists.txt           | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
index 5b332ed3d2f41..7c349ffd2026f 100644
--- a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
@@ -88,6 +88,22 @@ target_compile_definitions(PluginCommon PRIVATE
   DEBUG_PREFIX="PluginInterface"
 )
 
+target_compile_options(PluginCommon PUBLIC -fno-exceptions)
+
+if(NOT LLVM_ENABLE_RTTI)
+	target_compile_options(PluginCommon PUBLIC -fno-rtti)
+endif()
+
+include(CheckIPOSupported)
+check_ipo_supported(RESULT use_lto OUTPUT output)
+if(use_lto)
+	target_compile_options(PluginCommon PUBLIC -flto)
+	target_link_options(PluginCommon PUBLIC -flto)
+else()
+       message(WARNING "LTO is not supported: ${output}")
+endif()
+
+
 target_include_directories(PluginCommon
   PRIVATE
   ${LIBOMPTARGET_INCLUDE_DIR}
diff --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt
index 7c311f738ac8e..e907a1b25566b 100644
--- a/openmp/libomptarget/src/CMakeLists.txt
+++ b/openmp/libomptarget/src/CMakeLists.txt
@@ -55,6 +55,22 @@ target_compile_definitions(omptarget PRIVATE
   DEBUG_PREFIX="omptarget"
 )
 
+target_compile_options(omptarget PRIVATE -fno-exceptions)
+
+if(NOT LLVM_ENABLE_RTTI)
+  target_compile_options(omptarget PRIVATE -fno-rtti)
+endif()
+
+include(CheckIPOSupported)
+check_ipo_supported(RESULT use_lto OUTPUT output)
+if(use_lto)
+	target_compile_options(omptarget PUBLIC -flto)
+	target_link_options(omptarget PUBLIC -flto)
+else()
+       message(WARNING "LTO is not supported: ${output}")
+endif()
+
+
 # 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