diff mbox series

libgcc: Avoid warnings on __gcc_nested_func_ptr_created [PR113402]

Message ID Zbo3RMjefh5jKiRX@tucnak
State New
Headers show
Series libgcc: Avoid warnings on __gcc_nested_func_ptr_created [PR113402] | expand

Commit Message

Jakub Jelinek Jan. 31, 2024, 12:04 p.m. UTC
On Sun, Jan 28, 2024 at 11:02:33AM +0000, Iain Sandoe wrote:
> 	* config/aarch64/heap-trampoline.c: Rename
> 	__builtin_nested_func_ptr_created to __gcc_nested_func_ptr_created and
> 	__builtin_nested_func_ptr_deleted to __gcc_nested_func_ptr_deleted.
> 	* config/i386/heap-trampoline.c: Likewise.
> 	* libgcc2.h: Likewise.

I'm seeing hundreds of
In file included from ../../../libgcc/libgcc2.c:56:
../../../libgcc/libgcc2.h:32:13: warning: conflicting types for built-in function ‘__gcc_nested_func_ptr_created’; expected ‘void(void *, void *, void *)’ [-Wbuiltin-declaration-mismatch]
   32 | extern void __gcc_nested_func_ptr_created (void *, void *, void **);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warnings.

Either we need to add like in r14-6218
#pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
(but in that case because of the libgcc2.h prototype (why is it there?)
it would need to be also with #pragma GCC diagnostic push/pop around),
or we could go with just following how the builtins are prototyped on the
compiler side and only cast to void ** when dereferencing (which is in
a single spot in each TU).

2024-01-31  Jakub Jelinek  <jakub@redhat.com>

	* libgcc2.h (__gcc_nested_func_ptr_created): Change type of last
	argument from void ** to void *.
	* config/i386/heap-trampoline.c (__gcc_nested_func_ptr_created):
	Change type of dst from void ** to void * and cast dst to void **
	before dereferencing it.
	* config/aarch64/heap-trampoline.c (__gcc_nested_func_ptr_created):
	Likewise.



	Jakub

Comments

Jakub Jelinek Feb. 1, 2024, 8:22 a.m. UTC | #1
On Wed, Jan 31, 2024 at 01:04:20PM +0100, Jakub Jelinek wrote:
> On Sun, Jan 28, 2024 at 11:02:33AM +0000, Iain Sandoe wrote:
> > 	* config/aarch64/heap-trampoline.c: Rename
> > 	__builtin_nested_func_ptr_created to __gcc_nested_func_ptr_created and
> > 	__builtin_nested_func_ptr_deleted to __gcc_nested_func_ptr_deleted.
> > 	* config/i386/heap-trampoline.c: Likewise.
> > 	* libgcc2.h: Likewise.
> 
> I'm seeing hundreds of
> In file included from ../../../libgcc/libgcc2.c:56:
> ../../../libgcc/libgcc2.h:32:13: warning: conflicting types for built-in function ‘__gcc_nested_func_ptr_created’; expected ‘void(void *, void *, void *)’ [-Wbuiltin-declaration-mismatch]
>    32 | extern void __gcc_nested_func_ptr_created (void *, void *, void **);
>       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> warnings.
> 
> Either we need to add like in r14-6218
> #pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
> (but in that case because of the libgcc2.h prototype (why is it there?)
> it would need to be also with #pragma GCC diagnostic push/pop around),
> or we could go with just following how the builtins are prototyped on the
> compiler side and only cast to void ** when dereferencing (which is in
> a single spot in each TU).

Bootstrapped/regtested on x86_64-linux and i686-linux successfully.

> 2024-01-31  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* libgcc2.h (__gcc_nested_func_ptr_created): Change type of last
> 	argument from void ** to void *.
> 	* config/i386/heap-trampoline.c (__gcc_nested_func_ptr_created):
> 	Change type of dst from void ** to void * and cast dst to void **
> 	before dereferencing it.
> 	* config/aarch64/heap-trampoline.c (__gcc_nested_func_ptr_created):
> 	Likewise.

	Jakub
Richard Biener Feb. 1, 2024, 8:51 a.m. UTC | #2
On Thu, Feb 1, 2024 at 9:23 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Wed, Jan 31, 2024 at 01:04:20PM +0100, Jakub Jelinek wrote:
> > On Sun, Jan 28, 2024 at 11:02:33AM +0000, Iain Sandoe wrote:
> > >     * config/aarch64/heap-trampoline.c: Rename
> > >     __builtin_nested_func_ptr_created to __gcc_nested_func_ptr_created and
> > >     __builtin_nested_func_ptr_deleted to __gcc_nested_func_ptr_deleted.
> > >     * config/i386/heap-trampoline.c: Likewise.
> > >     * libgcc2.h: Likewise.
> >
> > I'm seeing hundreds of
> > In file included from ../../../libgcc/libgcc2.c:56:
> > ../../../libgcc/libgcc2.h:32:13: warning: conflicting types for built-in function ‘__gcc_nested_func_ptr_created’; expected ‘void(void *, void *, void *)’ [-Wbuiltin-declaration-mismatch]
> >    32 | extern void __gcc_nested_func_ptr_created (void *, void *, void **);
> >       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > warnings.
> >
> > Either we need to add like in r14-6218
> > #pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
> > (but in that case because of the libgcc2.h prototype (why is it there?)
> > it would need to be also with #pragma GCC diagnostic push/pop around),
> > or we could go with just following how the builtins are prototyped on the
> > compiler side and only cast to void ** when dereferencing (which is in
> > a single spot in each TU).
>
> Bootstrapped/regtested on x86_64-linux and i686-linux successfully.

Looks obvious to me.

Richard.

> > 2024-01-31  Jakub Jelinek  <jakub@redhat.com>
> >
> >       * libgcc2.h (__gcc_nested_func_ptr_created): Change type of last
> >       argument from void ** to void *.
> >       * config/i386/heap-trampoline.c (__gcc_nested_func_ptr_created):
> >       Change type of dst from void ** to void * and cast dst to void **
> >       before dereferencing it.
> >       * config/aarch64/heap-trampoline.c (__gcc_nested_func_ptr_created):
> >       Likewise.
>
>         Jakub
>
Iain Sandoe Feb. 1, 2024, 8 p.m. UTC | #3
> On 1 Feb 2024, at 08:51, Richard Biener <richard.guenther@gmail.com> wrote:
> 
> On Thu, Feb 1, 2024 at 9:23 AM Jakub Jelinek <jakub@redhat.com> wrote:
>> 
>> On Wed, Jan 31, 2024 at 01:04:20PM +0100, Jakub Jelinek wrote:
>>> On Sun, Jan 28, 2024 at 11:02:33AM +0000, Iain Sandoe wrote:
>>>>    * config/aarch64/heap-trampoline.c: Rename
>>>>    __builtin_nested_func_ptr_created to __gcc_nested_func_ptr_created and
>>>>    __builtin_nested_func_ptr_deleted to __gcc_nested_func_ptr_deleted.
>>>>    * config/i386/heap-trampoline.c: Likewise.
>>>>    * libgcc2.h: Likewise.
>>> 
>>> I'm seeing hundreds of
>>> In file included from ../../../libgcc/libgcc2.c:56:
>>> ../../../libgcc/libgcc2.h:32:13: warning: conflicting types for built-in function ‘__gcc_nested_func_ptr_created’; expected ‘void(void *, void *, void *)’ [-Wbuiltin-declaration-mismatch]
>>>   32 | extern void __gcc_nested_func_ptr_created (void *, void *, void **);
>>>      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> warnings.
>>> 
>>> Either we need to add like in r14-6218
>>> #pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
>>> (but in that case because of the libgcc2.h prototype (why is it there?)
>>> it would need to be also with #pragma GCC diagnostic push/pop around),
>>> or we could go with just following how the builtins are prototyped on the
>>> compiler side and only cast to void ** when dereferencing (which is in
>>> a single spot in each TU).
>> 
>> Bootstrapped/regtested on x86_64-linux and i686-linux successfully.
> 
> Looks obvious to me.

Thanks, also tested on x86_64 darwin; I guess having typed pointers on the builtins
would be a pretty tricky change.

Iain

> 
> Richard.
> 
>>> 2024-01-31  Jakub Jelinek  <jakub@redhat.com>
>>> 
>>>      * libgcc2.h (__gcc_nested_func_ptr_created): Change type of last
>>>      argument from void ** to void *.
>>>      * config/i386/heap-trampoline.c (__gcc_nested_func_ptr_created):
>>>      Change type of dst from void ** to void * and cast dst to void **
>>>      before dereferencing it.
>>>      * config/aarch64/heap-trampoline.c (__gcc_nested_func_ptr_created):
>>>      Likewise.
>> 
>>        Jakub
diff mbox series

Patch

--- libgcc/libgcc2.h.jj	2024-01-29 09:41:20.096387494 +0100
+++ libgcc/libgcc2.h	2024-01-31 12:43:22.702694509 +0100
@@ -29,7 +29,7 @@  see the files COPYING3 and COPYING.RUNTI
 #pragma GCC visibility push(default)
 #endif
 
-extern void __gcc_nested_func_ptr_created (void *, void *, void **);
+extern void __gcc_nested_func_ptr_created (void *, void *, void *);
 extern void __gcc_nested_func_ptr_deleted (void);
 
 extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
--- libgcc/config/i386/heap-trampoline.c.jj	2024-01-31 10:46:36.491743132 +0100
+++ libgcc/config/i386/heap-trampoline.c	2024-01-31 12:44:44.449550698 +0100
@@ -26,7 +26,7 @@  int get_trampolines_per_page (void);
 struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent);
 void *allocate_trampoline_page (void);
 
-void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst);
+void __gcc_nested_func_ptr_created (void *chain, void *func, void *dst);
 void __gcc_nested_func_ptr_deleted (void);
 
 static const uint8_t trampoline_insns[] = {
@@ -115,7 +115,7 @@  allocate_tramp_ctrl (struct tramp_ctrl_d
 
 HEAP_T_ATTR
 void
-__gcc_nested_func_ptr_created (void *chain, void *func, void **dst)
+__gcc_nested_func_ptr_created (void *chain, void *func, void *dst)
 {
   if (tramp_ctrl_curr == NULL)
     {
@@ -158,7 +158,7 @@  __gcc_nested_func_ptr_created (void *cha
   __builtin___clear_cache ((void *)trampoline->insns,
 			   ((void *)trampoline->insns + sizeof(trampoline->insns)));
 
-  *dst = &trampoline->insns;
+  *(void **) dst = &trampoline->insns;
 }
 
 HEAP_T_ATTR
--- libgcc/config/aarch64/heap-trampoline.c.jj	2024-01-31 10:46:36.491743132 +0100
+++ libgcc/config/aarch64/heap-trampoline.c	2024-01-31 12:45:11.282175257 +0100
@@ -26,7 +26,7 @@  int get_trampolines_per_page (void);
 struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent);
 void *allocate_trampoline_page (void);
 
-void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst);
+void __gcc_nested_func_ptr_created (void *chain, void *func, void *dst);
 void __gcc_nested_func_ptr_deleted (void);
 
 #if defined(__gnu_linux__)
@@ -115,7 +115,7 @@  allocate_tramp_ctrl (struct tramp_ctrl_d
 
 HEAP_T_ATTR
 void
-__gcc_nested_func_ptr_created (void *chain, void *func, void **dst)
+__gcc_nested_func_ptr_created (void *chain, void *func, void *dst)
 {
   if (tramp_ctrl_curr == NULL)
     {
@@ -158,7 +158,7 @@  __gcc_nested_func_ptr_created (void *cha
   __builtin___clear_cache ((void *)trampoline->insns,
 			   ((void *)trampoline->insns + sizeof(trampoline->insns)));
 
-  *dst = &trampoline->insns;
+  *(void **) dst = &trampoline->insns;
 }
 
 HEAP_T_ATTR