llvm-c166/compiler-rt
Justin T. Gibbs 7d2e3e7e5b
[asan] Build the asan_new_delete.cpp C++ slice with -frtti (#213077)
Required by #196388

In preparation for asan's operator new throwing `std::bad_alloc` on OOM,
compile the C++ slice (asan_new_delete.cpp, the only asan TU that
throws) with -frtti instead of the -fno-rtti inherited from ASAN_CFLAGS.

Throwing `std::bad_alloc` needs the type_info for std::bad_alloc. Under
-fno-rtti clang cannot reference the C++ ABI library's canonical
_ZTISt9bad_alloc and instead emits a private, hidden per-image copy of
it. On Mach-O that copy does not coalesce with the definition in
libc++abi, so the type_info the runtime throws with differs from the one
the user's `catch (const std::bad_alloc&)` matches against, and the
program terminates. On ELF the copy is weak with default visibility, so
the linker coalesces every copy to one and the addresses match, but that
coalescing is not guaranteed (e.g. `-Bsymbolic` defeats it).

Building this one TU with -frtti makes clang reference the external
canonical type_info, so the runtime's throw and the user's catch agree
on every platform. The change lives inside the existing exceptions
carve-out, so it only takes effect when the throwing path is compiled
in, and it adds no new library dependency (the exception throw already
requires the C++ ABI library).
2026-08-25 14:30:22 -06:00
..
cmake [asan] Build the asan_new_delete.cpp C++ slice with -frtti (#213077) 2026-08-25 14:30:22 -06:00
docs
include
lib [asan] Build the asan_new_delete.cpp C++ slice with -frtti (#213077) 2026-08-25 14:30:22 -06:00
resources [compiler-rt] Add version info to Windows runtime DLLs (#216408) 2026-08-25 10:04:01 -04:00
test [compiler-rt] Adjust ASan Windows tests for mingw-w64 (#216585) 2026-08-21 11:12:47 -07:00
tools
unittests
utils
www
.clang-tidy
.gitignore
CMakeLists.txt
CREDITS.TXT
LICENSE.TXT
Maintainers.md
README.txt

Compiler-RT
================================

This directory and its subdirectories contain source code for the compiler
support routines.

Compiler-RT is open source software. You may freely distribute it under the
terms of the license agreement found in LICENSE.txt.

================================