[libcxx-commits] [libcxx] [libc++] Encode the standard version in the ABI tag (PR #218527)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 17 12:52:02 PDT 2026


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/218527

>From b4722350fa4c240afa136334b0f3bb2672272bb4 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 24 Aug 2026 17:13:01 -0400
Subject: [PATCH 1/3] [libc++] Encode the standard version in the ABI tag

This prevents ODR mismatch issues from biting us across standard versions.

Fixes #218524
---
 libcxx/include/__configuration/attributes.h | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libcxx/include/__configuration/attributes.h b/libcxx/include/__configuration/attributes.h
index 2f8841fce0a078..8041581e649ba7 100644
--- a/libcxx/include/__configuration/attributes.h
+++ b/libcxx/include/__configuration/attributes.h
@@ -150,10 +150,17 @@
 #  define _LIBCPP_EXCEPTIONS_SIG e
 #endif
 
-#define _LIBCPP_ODR_SIGNATURE                                                                                          \
-  _LIBCPP_CONCAT(                                                                                                      \
-      _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_ASSERTION_SEMANTIC_SIG), _LIBCPP_EXCEPTIONS_SIG),   \
-      _LIBCPP_VERSION)
+#define _LIBCPP_STANDARD_VERSION_SIG _LIBCPP_CONCAT(std, _LIBCPP_STD_VER)
+
+// clang-format off
+#define _LIBCPP_ODR_SIGNATURE                                                                                           \
+  _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_CONCAT(                                                          \
+    _LIBCPP_HARDENING_SIG,                                                                                              \
+    _LIBCPP_ASSERTION_SEMANTIC_SIG),                                                                                    \
+    _LIBCPP_EXCEPTIONS_SIG),                                                                                            \
+    _LIBCPP_VERSION),                                                                                                   \
+    _LIBCPP_STANDARD_VERSION_SIG)
+// clang-format on
 
 // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
 // on two levels:

>From d5748eddf22afd245154f331b5a6dced99f496eb Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 17 Sep 2026 12:45:44 -0700
Subject: [PATCH 2/3] Drop std prefix

---
 libcxx/include/__configuration/attributes.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libcxx/include/__configuration/attributes.h b/libcxx/include/__configuration/attributes.h
index 8041581e649ba7..5c045edd8f0a25 100644
--- a/libcxx/include/__configuration/attributes.h
+++ b/libcxx/include/__configuration/attributes.h
@@ -150,16 +150,14 @@
 #  define _LIBCPP_EXCEPTIONS_SIG e
 #endif
 
-#define _LIBCPP_STANDARD_VERSION_SIG _LIBCPP_CONCAT(std, _LIBCPP_STD_VER)
-
 // clang-format off
 #define _LIBCPP_ODR_SIGNATURE                                                                                           \
   _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_CONCAT(                                                          \
-    _LIBCPP_HARDENING_SIG,                                                                                              \
+    _LIBCPP_VERSION,                                                                                                    \
+    _LIBCPP_HARDENING_SIG),                                                                                             \
     _LIBCPP_ASSERTION_SEMANTIC_SIG),                                                                                    \
     _LIBCPP_EXCEPTIONS_SIG),                                                                                            \
-    _LIBCPP_VERSION),                                                                                                   \
-    _LIBCPP_STANDARD_VERSION_SIG)
+    _LIBCPP_STD_VER)
 // clang-format on
 
 // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved

>From ec0c550f369557cf09599557d484345f8ec9aee8 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 17 Sep 2026 12:49:55 -0700
Subject: [PATCH 3/3] Update docs

---
 libcxx/docs/Hardening.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libcxx/docs/Hardening.rst b/libcxx/docs/Hardening.rst
index 8178a25e826489..469a160cc58ae8 100644
--- a/libcxx/docs/Hardening.rst
+++ b/libcxx/docs/Hardening.rst
@@ -460,14 +460,15 @@ a binary and determine whether it was built with hardening enabled.
   design -- new releases increase the version number. The following describes
   the state of the latest release and is for informational purposes only.
 
-The first character of an ABI tag encodes the hardening mode:
+The first part of the ABI tag is the libc++ version. Then, the first character
+that follows encodes the hardening mode:
 
 - ``f`` -- [f]ast mode;
 - ``s`` -- extensive ("[s]afe") mode;
 - ``d`` -- [d]ebug mode;
 - ``n`` -- [n]one mode.
 
-The second character of an ABI tag encodes the assertion semantic:
+The second character that follows encodes the assertion semantic:
 
 - ``i`` -- [i]gnore semantic;
 - ``o`` -- [o]bserve semantic;



More information about the libcxx-commits mailing list