[10/11] allocate_once: Apply asm redirection before first use

Message ID 20221028173532.876027-11-adhemerval.zanella@linaro.org
State Committed
Commit 8161978f89c3454e1b70e08efd98923e6a317a56
Headers
Series Initial fixes for clang build support |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Adhemerval Zanella Netto Oct. 28, 2022, 5:35 p.m. UTC
  Compilers may not be able to apply asm redirections to functions
after these functions are used for the first time, e.g. clang 13.
---
 include/allocate_once.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
  

Comments

Fangrui Song Oct. 29, 2022, 12:34 a.m. UTC | #1
On 2022-10-28, Adhemerval Zanella via Libc-alpha wrote:
>Compilers may not be able to apply asm redirections to functions
>after these functions are used for the first time, e.g. clang 13.

Ditto.  You may say 15.  This fixed a dozen errors like:



In file included from alloc_buffer_alloc_array.c:19:
../include/alloc_buffer.h:382:20: error: cannot apply asm label to function after its first use
libc_hidden_proto (__libc_alloc_buffer_allocate)
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:613:58: note: expanded from macro 'libc_hidden_proto'
# define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
                                            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~
./../include/libc-symbols.h:513:19: note: expanded from macro 'hidden_proto'
   __hidden_proto (name, , __GI_##name, ##attrs)
   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:519:33: note: expanded from macro '__hidden_proto'
   extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
                                 ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from alloc_buffer_alloc_array.c:19:
../include/alloc_buffer.h:383:20: error: cannot apply asm label to function after its first use
libc_hidden_proto (__libc_alloc_buffer_copy_bytes)
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:613:58: note: expanded from macro 'libc_hidden_proto'

Reviewed-by: Fangrui Song <maskray@google.com>
  

Patch

diff --git a/include/allocate_once.h b/include/allocate_once.h
index a487d641d5..d8cc08824c 100644
--- a/include/allocate_once.h
+++ b/include/allocate_once.h
@@ -27,6 +27,9 @@  void *__libc_allocate_once_slow (void **__place,
                                  void (*__deallocate) (void *__closure,
                                                        void *__ptr),
                                  void *__closure);
+#ifndef _ISOMAC
+libc_hidden_proto (__libc_allocate_once_slow)
+#endif
 
 /* Return an a pointer to an allocated and initialized data structure.
    If this function returns a non-NULL value, the caller can assume
@@ -88,8 +91,4 @@  allocate_once (void **__place, void *(*__allocate) (void *__closure),
                                       __closure);
 }
 
-#ifndef _ISOMAC
-libc_hidden_proto (__libc_allocate_once_slow)
-#endif
-
 #endif /* _ALLOCATE_ONCE_H */