Skip to content

Commit afe8f05

Browse files
mgornyjoaosaffran
authored andcommitted
[flang] [runtime] Explicitly disable EH & RTTI (llvm#126920)
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.
1 parent 75f0481 commit afe8f05

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

flang/runtime/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ else()
9999
set(NO_LTO_FLAGS "")
100100
endif()
101101

102+
# based on AddLLVM.cmake
103+
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
104+
set(NO_RTTI_FLAGS "-fno-exceptions -fno-rtti")
105+
elseif (MSVC)
106+
set(NO_RTTI_FLAGS "/EHs-c- /GR-")
107+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
108+
set(NO_RTTI_FLAGS "-qnoeh -qnortti")
109+
endif ()
110+
102111
configure_file(config.h.cmake config.h)
103112
# include_directories is used here instead of target_include_directories
104113
# because add_flang_library creates multiple objects (STATIC/SHARED, OBJECT)
@@ -107,6 +116,7 @@ include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR})
107116

108117
append(${NO_LTO_FLAGS} CMAKE_C_FLAGS)
109118
append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS)
119+
append(${NO_RTTI_FLAGS} CMAKE_CXX_FLAGS)
110120

111121
# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
112122
# to avoid an unwanted dependency on libstdc++/libc++.so.

0 commit comments

Comments
 (0)