[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 03:54:26 PST 2025
https://github.com/lhames created https://github.com/llvm/llvm-project/pull/172155
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.
>From 3631ded602dfaa7418b3187d3066d535736ba0c5 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 | 3 +++
2 files changed, 9 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..ea2611c1ec9e9 100644
--- a/orc-rt/unittests/CMakeLists.txt
+++ b/orc-rt/unittests/CMakeLists.txt
@@ -9,6 +9,9 @@ endif ()
function(add_orc_rt_unittest test_dirname)
add_unittest(OrcRTUnitTests ${test_dirname} ${ARGN})
+
+ # Apply ORC_RT_COMPILE_FLAGS to the unittest target
+ target_compile_options(${test_dirname} PRIVATE ${ORC_RT_COMPILE_FLAGS})
endfunction()
add_orc_rt_unittest(CoreTests
More information about the llvm-commits
mailing list