Skip to content

Commit f14a662

Browse files
committed
Disable exceptions for CUDA as well
1 parent c0d60be commit f14a662

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ function (add_flangrt_library name)
6565
set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Libraries")
6666
endif ()
6767

68+
# Minimum required C++ version for Flang-RT, even if CMAKE_CXX_STANDARD is defined to something else.
6869
target_compile_features(${name} PRIVATE cxx_std_17)
70+
71+
# Use compiler-specific options to disable exceptions and RTTI.
6972
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
7073
target_compile_options(${name} PRIVATE
7174
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>
@@ -80,6 +83,19 @@ function (add_flangrt_library name)
8083
)
8184
endif ()
8285

86+
# Also for CUDA source when compiling with FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA
87+
if (CMAKE_CUDA_COMPILER_ID MATCHES "NVIDIA")
88+
# Assuming gcc as host compiler.
89+
target_compile_options(${name} PRIVATE
90+
$<$<COMPILE_LANGUAGE:CUDA>:--no-exceptions -Xcompiler -fno-rtti -Xcompiler -fno-unwind-tables -Xcompiler -fno-asynchronous-unwind-tables>
91+
)
92+
else ()
93+
# Assuming a clang-compatible CUDA compiler.
94+
target_compile_options(${name} PRIVATE
95+
$<$<COMPILE_LANGUAGE:CUDA>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>
96+
)
97+
endif ()
98+
8399
# Flang-rt's public headers
84100
target_include_directories(${name} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
85101

0 commit comments

Comments
 (0)