Skip to content

[flang] [runtime] Explicitly disable EH & RTTI #126920

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

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

mgorny
Copy link
Member

@mgorny mgorny commented Feb 12, 2025

Explicitly disable EH & RTTI when building Flang runtime library. This fixes the runtime built when Flang is built standalone against system LLVM that was compiled with EH & RTTI enabled.

I think this change may be sufficient to lift the top-level LLVM_ENABLE_EH restriction from Flang. However, I'd prefer if somebody more knowledgeable decided on that.

Explicitly disable EH & RTTI when building Flang runtime library.
This fixes the runtime built when Flang is built standalone against
system LLVM that was compiled with EH & RTTI enabled.

I think this change may be sufficient to lift the top-level
`LLVM_ENABLE_EH` restriction from Flang.  However, I'd prefer
if somebody more knowledgeable decided on that.
@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Feb 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 12, 2025

@llvm/pr-subscribers-flang-runtime

Author: Michał Górny (mgorny)

Changes

Explicitly disable EH & RTTI when building Flang runtime library. This fixes the runtime built when Flang is built standalone against system LLVM that was compiled with EH & RTTI enabled.

I think this change may be sufficient to lift the top-level LLVM_ENABLE_EH restriction from Flang. However, I'd prefer if somebody more knowledgeable decided on that.


Full diff: https://github.com/llvm/llvm-project/pull/126920.diff

1 Files Affected:

  • (modified) flang/runtime/CMakeLists.txt (+10)
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index f651ea83664eb..1f4ee69598918 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -99,6 +99,15 @@ else()
   set(NO_LTO_FLAGS "")
 endif()
 
+# based on AddLLVM.cmake
+if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
+  set(NO_RTTI_FLAGS "-fno-exceptions -fno-rtti")
+elseif (MSVC)
+  set(NO_RTTI_FLAGS "/EHs-c- /GR-")
+elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
+  set(NO_RTTI_FLAGS "-qnoeh -qnortti")
+endif ()
+
 configure_file(config.h.cmake config.h)
 # include_directories is used here instead of target_include_directories
 # because add_flang_library creates multiple objects (STATIC/SHARED, OBJECT)
@@ -107,6 +116,7 @@ include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR})
 
 append(${NO_LTO_FLAGS} CMAKE_C_FLAGS)
 append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS)
+append(${NO_RTTI_FLAGS} CMAKE_CXX_FLAGS)
 
 # Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
 # to avoid an unwanted dependency on libstdc++/libc++.so.

Copy link
Contributor

@vzakhari vzakhari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mgorny mgorny merged commit c665480 into llvm:main Feb 12, 2025
11 checks passed
@mgorny mgorny deleted the flang-runtime-rtti branch February 12, 2025 18:03
flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
Explicitly disable EH & RTTI when building Flang runtime library. This
fixes the runtime built when Flang is built standalone against system
LLVM that was compiled with EH & RTTI enabled.

I think this change may be sufficient to lift the top-level
`LLVM_ENABLE_EH` restriction from Flang. However, I'd prefer if somebody
more knowledgeable decided on that.
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
Explicitly disable EH & RTTI when building Flang runtime library. This
fixes the runtime built when Flang is built standalone against system
LLVM that was compiled with EH & RTTI enabled.

I think this change may be sufficient to lift the top-level
`LLVM_ENABLE_EH` restriction from Flang. However, I'd prefer if somebody
more knowledgeable decided on that.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
Explicitly disable EH & RTTI when building Flang runtime library. This
fixes the runtime built when Flang is built standalone against system
LLVM that was compiled with EH & RTTI enabled.

I think this change may be sufficient to lift the top-level
`LLVM_ENABLE_EH` restriction from Flang. However, I'd prefer if somebody
more knowledgeable decided on that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:runtime flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants