[libcxx-commits] [libcxx] [libc++] Fix build failure with libdispatch backend (PR #141606)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 27 06:57:14 PDT 2025


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/141606

We get an error "cannot add 'abi_tag' attribute in a redeclaration" because functions like `__dispatch_apply` are first declared without an ABI tag due to `_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS` inside the header, and then redeclared with an ABI tag in the .cpp file.

>From 68e6bbd045818b349aae7a7bb95993b44e2fffc0 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 27 May 2025 09:54:50 -0400
Subject: [PATCH] [libc++] Fix build failure with libdispatch backend

We get an error "cannot add 'abi_tag' attribute in a redeclaration"
because functions like `__dispatch_apply` are first declared without
an ABI tag due to `_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS` inside
the header, and then redeclared with an ABI tag in the .cpp file.
---
 libcxx/src/pstl/libdispatch.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libcxx/src/pstl/libdispatch.cpp b/libcxx/src/pstl/libdispatch.cpp
index 3dca702341c85..528018358eeb0 100644
--- a/libcxx/src/pstl/libdispatch.cpp
+++ b/libcxx/src/pstl/libdispatch.cpp
@@ -12,6 +12,7 @@
 #include <dispatch/dispatch.h>
 
 _LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 namespace __pstl::__libdispatch {
 
 void __dispatch_apply(size_t chunk_count, void* context, void (*func)(void* context, size_t chunk)) noexcept {
@@ -29,4 +30,5 @@ __chunk_partitions __partition_chunks(ptrdiff_t element_count) noexcept {
 }
 
 } // namespace __pstl::__libdispatch
+_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 _LIBCPP_END_NAMESPACE_STD



More information about the libcxx-commits mailing list