Skip to content

[libc++] Remove a few incorrect _LIBCPP_EXPORTED_FROM_ABI annotations #132602

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

philnik777
Copy link
Contributor

@philnik777 philnik777 commented Mar 23, 2025

This has two benefits:

  • It is less likely that the macro is cargo-culted around
  • We can drop _LIBCPP_HIDE_FROM_ABI at a later date

@philnik777 philnik777 force-pushed the remove_incorrect_exported_from_abi branch 2 times, most recently from 13fd815 to 0d41725 Compare March 27, 2025 12:00
@philnik777 philnik777 marked this pull request as ready for review March 28, 2025 21:40
@philnik777 philnik777 requested a review from a team as a code owner March 28, 2025 21:40
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 28, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 28, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

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

13 Files Affected:

  • (modified) libcxx/include/__charconv/from_chars_result.h (+1-1)
  • (modified) libcxx/include/__charconv/to_chars_result.h (+1-1)
  • (modified) libcxx/include/__filesystem/file_status.h (+1-1)
  • (modified) libcxx/include/__filesystem/path.h (+1-1)
  • (modified) libcxx/include/__filesystem/space_info.h (+1-1)
  • (modified) libcxx/include/__format/formatter_output.h (+1-1)
  • (modified) libcxx/include/__memory_resource/pool_options.h (+1-1)
  • (modified) libcxx/include/__mutex/tag_types.h (+3-3)
  • (modified) libcxx/include/__new/nothrow_t.h (+1-1)
  • (modified) libcxx/include/__system_error/error_category.h (+1-1)
  • (modified) libcxx/include/__thread/id.h (+1-1)
  • (modified) libcxx/include/__tuple/sfinae_helpers.h (+1-1)
  • (modified) libcxx/include/__utility/in_place.h (+1-1)
diff --git a/libcxx/include/__charconv/from_chars_result.h b/libcxx/include/__charconv/from_chars_result.h
index a7bfd6530a8a0..b4ecea3d11451 100644
--- a/libcxx/include/__charconv/from_chars_result.h
+++ b/libcxx/include/__charconv/from_chars_result.h
@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER >= 17
 
-struct _LIBCPP_EXPORTED_FROM_ABI from_chars_result {
+struct from_chars_result {
   const char* ptr;
   errc ec;
 #  if _LIBCPP_STD_VER >= 20
diff --git a/libcxx/include/__charconv/to_chars_result.h b/libcxx/include/__charconv/to_chars_result.h
index 8df0897a49fbb..d217948c39606 100644
--- a/libcxx/include/__charconv/to_chars_result.h
+++ b/libcxx/include/__charconv/to_chars_result.h
@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER >= 17
 
-struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result {
+struct to_chars_result {
   char* ptr;
   errc ec;
 #  if _LIBCPP_STD_VER >= 20
diff --git a/libcxx/include/__filesystem/file_status.h b/libcxx/include/__filesystem/file_status.h
index da316c8b02746..eecaf3c492f03 100644
--- a/libcxx/include/__filesystem/file_status.h
+++ b/libcxx/include/__filesystem/file_status.h
@@ -22,7 +22,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
-class _LIBCPP_EXPORTED_FROM_ABI file_status {
+class file_status {
 public:
   // constructors
   _LIBCPP_HIDE_FROM_ABI file_status() noexcept : file_status(file_type::none) {}
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index a2c28bfd79bb9..f71f305e7a0ee 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -862,7 +862,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
   }
 
   // iterators
-  class _LIBCPP_EXPORTED_FROM_ABI iterator;
+  class iterator;
   typedef iterator const_iterator;
 
   iterator begin() const;
diff --git a/libcxx/include/__filesystem/space_info.h b/libcxx/include/__filesystem/space_info.h
index 3fa57d33096fc..28f7ced40d27d 100644
--- a/libcxx/include/__filesystem/space_info.h
+++ b/libcxx/include/__filesystem/space_info.h
@@ -21,7 +21,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
-struct _LIBCPP_EXPORTED_FROM_ABI space_info {
+struct space_info {
   uintmax_t capacity;
   uintmax_t free;
   uintmax_t available;
diff --git a/libcxx/include/__format/formatter_output.h b/libcxx/include/__format/formatter_output.h
index e1f1309cd2c53..0da44e7cfd630 100644
--- a/libcxx/include/__format/formatter_output.h
+++ b/libcxx/include/__format/formatter_output.h
@@ -63,7 +63,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char __c) {
   return __c;
 }
 
-struct _LIBCPP_EXPORTED_FROM_ABI __padding_size_result {
+struct __padding_size_result {
   size_t __before_;
   size_t __after_;
 };
diff --git a/libcxx/include/__memory_resource/pool_options.h b/libcxx/include/__memory_resource/pool_options.h
index 324b8aaa8502b..fd20ced56795f 100644
--- a/libcxx/include/__memory_resource/pool_options.h
+++ b/libcxx/include/__memory_resource/pool_options.h
@@ -24,7 +24,7 @@ namespace pmr {
 
 // [mem.res.pool.options]
 
-struct _LIBCPP_EXPORTED_FROM_ABI pool_options {
+struct pool_options {
   size_t max_blocks_per_chunk        = 0;
   size_t largest_required_pool_block = 0;
 };
diff --git a/libcxx/include/__mutex/tag_types.h b/libcxx/include/__mutex/tag_types.h
index 2b2dd58ee4e80..36b1a3d92b14e 100644
--- a/libcxx/include/__mutex/tag_types.h
+++ b/libcxx/include/__mutex/tag_types.h
@@ -17,15 +17,15 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-struct _LIBCPP_EXPORTED_FROM_ABI defer_lock_t {
+struct defer_lock_t {
   explicit defer_lock_t() = default;
 };
 
-struct _LIBCPP_EXPORTED_FROM_ABI try_to_lock_t {
+struct try_to_lock_t {
   explicit try_to_lock_t() = default;
 };
 
-struct _LIBCPP_EXPORTED_FROM_ABI adopt_lock_t {
+struct adopt_lock_t {
   explicit adopt_lock_t() = default;
 };
 
diff --git a/libcxx/include/__new/nothrow_t.h b/libcxx/include/__new/nothrow_t.h
index 09c2d03f66ccc..f241dc1577f4b 100644
--- a/libcxx/include/__new/nothrow_t.h
+++ b/libcxx/include/__new/nothrow_t.h
@@ -20,7 +20,7 @@
 #else
 // purposefully not using versioning namespace
 namespace std {
-struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t {
+struct nothrow_t {
   explicit nothrow_t() = default;
 };
 extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow;
diff --git a/libcxx/include/__system_error/error_category.h b/libcxx/include/__system_error/error_category.h
index bfe7bc24a5d3d..cb69fcea0023c 100644
--- a/libcxx/include/__system_error/error_category.h
+++ b/libcxx/include/__system_error/error_category.h
@@ -20,7 +20,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-class _LIBCPP_EXPORTED_FROM_ABI error_condition;
+class error_condition;
 class _LIBCPP_EXPORTED_FROM_ABI error_code;
 
 class _LIBCPP_HIDDEN __do_message;
diff --git a/libcxx/include/__thread/id.h b/libcxx/include/__thread/id.h
index 75c3b3436df7a..28c4f81b151e4 100644
--- a/libcxx/include/__thread/id.h
+++ b/libcxx/include/__thread/id.h
@@ -23,7 +23,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_HAS_THREADS
-class _LIBCPP_EXPORTED_FROM_ABI __thread_id;
+class __thread_id;
 
 namespace this_thread {
 
diff --git a/libcxx/include/__tuple/sfinae_helpers.h b/libcxx/include/__tuple/sfinae_helpers.h
index 4084e8bb31fd8..5b360ae2c0021 100644
--- a/libcxx/include/__tuple/sfinae_helpers.h
+++ b/libcxx/include/__tuple/sfinae_helpers.h
@@ -62,7 +62,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > {
   using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type;
 };
 
-struct _LIBCPP_EXPORTED_FROM_ABI __check_tuple_constructor_fail {
+struct __check_tuple_constructor_fail {
   static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit_default() { return false; }
   static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() { return false; }
   template <class...>
diff --git a/libcxx/include/__utility/in_place.h b/libcxx/include/__utility/in_place.h
index 9b48446d83709..c6c600c201a30 100644
--- a/libcxx/include/__utility/in_place.h
+++ b/libcxx/include/__utility/in_place.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER >= 17
 
-struct _LIBCPP_EXPORTED_FROM_ABI in_place_t {
+struct in_place_t {
   explicit in_place_t() = default;
 };
 inline constexpr in_place_t in_place{};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write a proper commit message! Benefits of this change:

  • First, this means that we'll eventually be able to drop HIDE_FROM_ABI from these classes' methods (after applying HIDE_FROM_ABI to entire scopes). That would be impossible if we keep EXPORTED_FROM_ABI on the class, since that causes all of the class' methods to get exported.
  • This reduces the likelihood of the attribute being copied around when it's not necessary.

Can you update the documentation of _LIBCPP_EXPORTED_FROM_ABI to mention when it should be used on classes? It's not super clear right now.

@philnik777 philnik777 force-pushed the remove_incorrect_exported_from_abi branch from 0d41725 to 74f2fa2 Compare July 23, 2025 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants