[compiler-rt] [asan] Enable exceptions for asan_new_delete.cpp translation unit (PR #200719)
David Justo via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 10:56:16 PDT 2026
================
@@ -143,6 +143,19 @@ set(ASAN_DYNAMIC_CFLAGS ${ASAN_CFLAGS})
append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC
-ftls-model=initial-exec ASAN_DYNAMIC_CFLAGS)
+# asan_new_delete.cpp throws std::bad_alloc, so the translation units that
+# build it need -fexceptions and access to <new> (drop -nostdinc++). Only
+# the C++ slices (RTAsan_cxx in the static build and RTAsan_dynamic_cxx in
+# the dynamic build) opt into these flags — the rest of the runtime keeps
+# -fno-exceptions / -nostdinc++.
+set(ASAN_CXX_CFLAGS ${ASAN_CFLAGS})
+list(REMOVE_ITEM ASAN_CXX_CFLAGS -fno-exceptions -nostdinc++)
+append_list_if(COMPILER_RT_HAS_FEXCEPTIONS_FLAG -fexceptions ASAN_CXX_CFLAGS)
----------------
davidmrdavid wrote:
Sweet, thanks!
https://github.com/llvm/llvm-project/pull/200719
More information about the llvm-commits
mailing list