Skip to content

[libc++abi] Make once_flag constinit in cxa_exception_storage #124627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Jan 27, 2025

This makes it clearer that initialization of this global variable is taking place at compile-time, reducing the likelihood of static initialization order fiasco.

This makes it clearer that initialization of this global variable
is taking place at compile-time, reducing the likelihood of static
initialization order fiasco.
@ldionne ldionne requested a review from a team as a code owner January 27, 2025 21:06
@llvmbot llvmbot added the libc++abi libc++abi C++ Runtime Library. Not libc++. label Jan 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 27, 2025

@llvm/pr-subscribers-libcxxabi

Author: Louis Dionne (ldionne)

Changes

This makes it clearer that initialization of this global variable is taking place at compile-time, reducing the likelihood of static initialization order fiasco.


Full diff: https://github.com/llvm/llvm-project/pull/124627.diff

1 Files Affected:

  • (modified) libcxxabi/src/cxa_exception_storage.cpp (+1-1)
diff --git a/libcxxabi/src/cxa_exception_storage.cpp b/libcxxabi/src/cxa_exception_storage.cpp
index 733f0d470569a2..05da6a48e313cf 100644
--- a/libcxxabi/src/cxa_exception_storage.cpp
+++ b/libcxxabi/src/cxa_exception_storage.cpp
@@ -56,7 +56,7 @@ extern "C" {
 namespace __cxxabiv1 {
 namespace {
     std::__libcpp_tls_key key_;
-    std::__libcpp_exec_once_flag flag_ = _LIBCPP_EXEC_ONCE_INITIALIZER;
+    constinit std::__libcpp_exec_once_flag flag_ = _LIBCPP_EXEC_ONCE_INITIALIZER;
 
     void _LIBCPP_TLS_DESTRUCTOR_CC destruct_(void *p) {
         __free_with_fallback(p);

@ldionne ldionne merged commit a06c893 into llvm:main Jan 28, 2025
79 checks passed
@ldionne ldionne deleted the review/once-flag-constinit branch January 28, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++abi libc++abi C++ Runtime Library. Not libc++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants