diff options
| author | Mingming Liu <mingmingl@google.com> | 2025-09-10 15:25:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-10 15:25:31 -0700 |
| commit | 1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch) | |
| tree | 57f4b1f313c8cf74eed8819870f39c36ea263c68 /libc/src/stdlib | |
| parent | 898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff) | |
| parent | b8cefcb601ddaa18482555c4ff363c01a270c2fe (diff) | |
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'libc/src/stdlib')
| -rw-r--r-- | libc/src/stdlib/exit.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libc/src/stdlib/exit.cpp b/libc/src/stdlib/exit.cpp index 28a6f8a63c0c..f26d48ac00d7 100644 --- a/libc/src/stdlib/exit.cpp +++ b/libc/src/stdlib/exit.cpp @@ -15,7 +15,21 @@ namespace LIBC_NAMESPACE_DECL { extern "C" void __cxa_finalize(void *); +// exit needs to clean up TLS and call associated destructors. +// TODO: Strictly speaking, it is not valid to call exit in overlay mode +// as we have no way to ensure system libc will call the TLS destructors. +// We should run exit related tests in hermetic mode but this is currently +// blocked by https://github.com/llvm/llvm-project/issues/133925. +extern "C" [[gnu::weak]] void __cxa_thread_finalize(); + +// TODO: use recursive mutex to protect this routine. [[noreturn]] LLVM_LIBC_FUNCTION(void, exit, (int status)) { +// FIXME: The NVPTX target does not support external weak symbols correctly +// despite being an ELF platform. Disable pending a future split. +#if !defined(LIBC_TARGET_ARCH_IS_NVPTX) + if (__cxa_thread_finalize) + __cxa_thread_finalize(); +#endif __cxa_finalize(nullptr); internal::exit(status); } |
