Skip to content

Commit 12cbccc

Browse files
authored
[OpenMP] Add extra flags to libomptarget and plugin builds (#74520)
1 parent 3745f47 commit 12cbccc

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

openmp/libomptarget/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@ if(LIBOMPTARGET_ENABLE_DEBUG)
7575
add_definitions(-DOMPTARGET_DEBUG)
7676
endif()
7777

78+
# No exceptions and no RTTI, except if requested.
79+
set(offload_compile_flags -fno-exceptions)
80+
if(NOT LLVM_ENABLE_RTTI)
81+
set(offload_compile_flags ${offload_compile_flags} -fno-rtti)
82+
endif()
83+
84+
# If LTO is not explicitly disabled we check if we can enable it and do so.
85+
set(LIBOMPTARGET_USE_LTO TRUE CACHE BOOL "Use LTO for the offload runtimes if available")
86+
if (LIBOMPTARGET_USE_LTO)
87+
include(CheckIPOSupported)
88+
check_ipo_supported(RESULT use_lto OUTPUT output)
89+
if(use_lto)
90+
set(offload_compile_flags ${offload_compile_flags} -flto)
91+
set(offload_link_flags ${offload_link_flags} -flto)
92+
else()
93+
message(WARNING "LTO is not supported: ${output}")
94+
endif()
95+
endif()
96+
7897
# OMPT support for libomptarget
7998
# Follow host OMPT support and check if host support has been requested.
8099
# LIBOMP_HAVE_OMPT_SUPPORT indicates whether host OMPT support has been implemented.

openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ target_compile_definitions(PluginCommon PRIVATE
8888
DEBUG_PREFIX="PluginInterface"
8989
)
9090

91+
target_compile_options(PluginCommon PUBLIC ${offload_compile_flags})
92+
target_link_options(PluginCommon PUBLIC ${offload_link_flags})
93+
9194
target_include_directories(PluginCommon
9295
PRIVATE
9396
${LIBOMPTARGET_INCLUDE_DIR}

openmp/libomptarget/src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ target_compile_definitions(omptarget PRIVATE
5555
DEBUG_PREFIX="omptarget"
5656
)
5757

58+
target_compile_options(omptarget PUBLIC ${offload_compile_flags})
59+
target_link_options(omptarget PUBLIC ${offload_link_flags})
60+
5861
macro(check_plugin_target target)
5962
if (TARGET omptarget.rtl.${target})
6063
list(APPEND LIBOMPTARGET_PLUGINS_TO_LOAD ${target})

0 commit comments

Comments
 (0)