[llvm] [orc-rt] Ensure EH/RTTI=On overrides LLVM opts, applies to unit tests. (PR #172155)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 13 04:52:56 PST 2025


https://github.com/lhames updated https://github.com/llvm/llvm-project/pull/172155

>From 5f8fe07cc370f3e3fe5563eea24f7e911949139f Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Sat, 13 Dec 2025 22:43:02 +1100
Subject: [PATCH] [orc-rt] Ensure EH/RTTI=On overrides LLVM opts, applies to
 unit tests.

When -DORC_RT_ENABLE_EXCEPTIONS=On and -DORC_RT_ENABLE_RTTI=On are passed we
need to ensure that the resulting compiler flags (e.g. -fexceptions, -frtti
for clang/GCC) are appended so that we override any inherited options (e.g.
-fno-exceptions, -fno-rtti) from LLVM.

Updates unit tests to ensure that these compiler options are applied to them
too.
---
 orc-rt/CMakeLists.txt           | 8 ++++++--
 orc-rt/unittests/CMakeLists.txt | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/orc-rt/CMakeLists.txt b/orc-rt/CMakeLists.txt
index 5da7cc7fbe299..95b7b852138e7 100644
--- a/orc-rt/CMakeLists.txt
+++ b/orc-rt/CMakeLists.txt
@@ -44,11 +44,15 @@ set(ORC_RT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
 # Configure RTTI and exceptions compile flags
 set(ORC_RT_COMPILE_FLAGS)
-if(NOT ORC_RT_ENABLE_RTTI)
+if(ORC_RT_ENABLE_RTTI)
+  list(APPEND ORC_RT_COMPILE_FLAGS -frtti)
+else()
   list(APPEND ORC_RT_COMPILE_FLAGS -fno-rtti)
 endif()
 
-if(NOT ORC_RT_ENABLE_EXCEPTIONS)
+if(ORC_RT_ENABLE_EXCEPTIONS)
+  list(APPEND ORC_RT_COMPILE_FLAGS -fexceptions)
+else()
   list(APPEND ORC_RT_COMPILE_FLAGS -fno-exceptions)
 endif()
 
diff --git a/orc-rt/unittests/CMakeLists.txt b/orc-rt/unittests/CMakeLists.txt
index c43ec17b54de3..569c8a585bd29 100644
--- a/orc-rt/unittests/CMakeLists.txt
+++ b/orc-rt/unittests/CMakeLists.txt
@@ -39,4 +39,5 @@ add_orc_rt_unittest(CoreTests
   span-test.cpp
   DISABLE_LLVM_LINK_LLVM_DYLIB
   )
+target_compile_options(CoreTests PRIVATE ${ORC_RT_COMPILE_FLAGS})
 target_link_libraries(CoreTests PRIVATE orc-rt-executor)



More information about the llvm-commits mailing list