-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OpenMP] Add extra flags to libomptarget and plugin builds #74520
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-openmp Author: Johannes Doerfert (jdoerfert) ChangesFull diff: https://github.com/llvm/llvm-project/pull/74520.diff 2 Files Affected:
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
|
jhuber6
reviewed
Dec 5, 2023
jhuber6
reviewed
Dec 5, 2023
jdoerfert
force-pushed
the
offload_prep10
branch
from
December 5, 2023 23:02
4503259
to
de23f5e
Compare
jdoerfert
force-pushed
the
offload_prep10
branch
from
December 6, 2023 00:00
de23f5e
to
f505868
Compare
jhuber6
reviewed
Dec 6, 2023
jhuber6
approved these changes
Dec 7, 2023
Meinersbur
added a commit
that referenced
this pull request
Jan 26, 2024
…79387) CheckIPOSupported is used to test for working LTO since #74520. However, before CMake 3.24 this will test the default linker and ignore options such as LLVM_ENABLE_LLD. As a result, CMake would test whether LTO works with the default linker but builds with another one. In a typical scenario, libomptarget is compiled with the in-tree Clang, but linked with ld.gold, which requires the LLVMgold plugin, when it actually would work with the lld linker (or also fail because the system lld is too old to understand opaque pointers). Using gcc as the compiler would pass the test, but fail when linking with lld since does not understand gcc's LTO format. Disable LTO by default for now since automatic detection causes too many problems. It causes the openmp-offload-cuda-project buildbot (https://lab.llvm.org/staging/#/builders/151) to fail and LLVM_ENABLE_RUNTIMES=openmp builds will have it implicitly disabled in the vast majority of system configurations anyway.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.