resolv, rt: Change some extern inline functions to static inline

Message ID 20260501005428.4105376-1-pcc@google.com (mailing list archive)
State Committed
Commit c20e60e3507ac1fd859131e81ac237a663267c45
Headers
Series resolv, rt: Change some extern inline functions to static inline |

Checks

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

Commit Message

Peter Collingbourne May 1, 2026, 12:54 a.m. UTC
  The following functions:

__aio_create_helper_thread
__aio_start_notify_thread
__gai_create_helper_thread
__gai_start_notify_thread

are declared as extern inline, but no translation unit provides their
real definitions. This can lead to a link failure if the functions are
not inlined. Fix it by declaring them as static inline instead.
---
 resolv/gai_misc.c                  | 2 +-
 rt/aio_misc.c                      | 2 +-
 sysdeps/mach/hurd/gai_misc.h       | 4 ++--
 sysdeps/nptl/gai_misc.h            | 4 ++--
 sysdeps/unix/sysv/linux/aio_misc.h | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)
  

Comments

Florian Weimer May 1, 2026, 8:39 a.m. UTC | #1
* Peter Collingbourne:

> The following functions:
>
> __aio_create_helper_thread
> __aio_start_notify_thread
> __gai_create_helper_thread
> __gai_start_notify_thread
>
> are declared as extern inline, but no translation unit provides their
> real definitions. This can lead to a link failure if the functions are
> not inlined. Fix it by declaring them as static inline instead.

I would drop the “inline” as well, encouraging the compiler to make
the inlining decision.
  
Peter Collingbourne May 1, 2026, 4:43 p.m. UTC | #2
On Fri, May 1, 2026 at 1:39 AM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * Peter Collingbourne:
>
> > The following functions:
> >
> > __aio_create_helper_thread
> > __aio_start_notify_thread
> > __gai_create_helper_thread
> > __gai_start_notify_thread
> >
> > are declared as extern inline, but no translation unit provides their
> > real definitions. This can lead to a link failure if the functions are
> > not inlined. Fix it by declaring them as static inline instead.
>
> I would drop the “inline” as well, encouraging the compiler to make
> the inlining decision.

That causes some build failures, e.g.

In file included from aio_error.c:30:
../sysdeps/unix/sysv/linux/aio_misc.h:38:1: error: ‘__aio_create_helper_thread’
defined but not used [-Werror=unused-function]
   38 | __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/aio_misc.h:29:1: error: ‘__aio_start_notify_thread’ d
efined but not used [-Werror=unused-function]
   29 | __aio_start_notify_thread (void)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~

Peter
  
Cristian Rodriguez May 2, 2026, 2:50 p.m. UTC | #3
On Fri, May 1, 2026 at 12:43 PM Peter Collingbourne <pcc@google.com> wrote:
>
> On Fri, May 1, 2026 at 1:39 AM Florian Weimer <fw@deneb.enyo.de> wrote:
> >
> > * Peter Collingbourne:
> >
> > > The following functions:
> > >
> > > __aio_create_helper_thread
> > > __aio_start_notify_thread
> > > __gai_create_helper_thread
> > > __gai_start_notify_thread
> > >
> > > are declared as extern inline, but no translation unit provides their
> > > real definitions. This can lead to a link failure if the functions are
> > > not inlined. Fix it by declaring them as static inline instead.
> >
> > I would drop the “inline” as well, encouraging the compiler to make
> > the inlining decision.
>
> That causes some build failures, e.g.
>
> In file included from aio_error.c:30:
> ../sysdeps/unix/sysv/linux/aio_misc.h:38:1: error: ‘__aio_create_helper_thread’
> defined but not used [-Werror=unused-function]
>    38 | __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ../sysdeps/unix/sysv/linux/aio_misc.h:29:1: error: ‘__aio_start_notify_thread’ d
> efined but not used [-Werror=unused-function]
>    29 | __aio_start_notify_thread (void)
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~


So, they need a __attribute_maybe_unused__ annotation.
  
Florian Weimer May 2, 2026, 4:31 p.m. UTC | #4
* Cristian Rodriguez:

> On Fri, May 1, 2026 at 12:43 PM Peter Collingbourne <pcc@google.com> wrote:
>>
>> On Fri, May 1, 2026 at 1:39 AM Florian Weimer <fw@deneb.enyo.de> wrote:
>> >
>> > * Peter Collingbourne:
>> >
>> > > The following functions:
>> > >
>> > > __aio_create_helper_thread
>> > > __aio_start_notify_thread
>> > > __gai_create_helper_thread
>> > > __gai_start_notify_thread
>> > >
>> > > are declared as extern inline, but no translation unit provides their
>> > > real definitions. This can lead to a link failure if the functions are
>> > > not inlined. Fix it by declaring them as static inline instead.
>> >
>> > I would drop the “inline” as well, encouraging the compiler to make
>> > the inlining decision.
>>
>> That causes some build failures, e.g.
>>
>> In file included from aio_error.c:30:
>> ../sysdeps/unix/sysv/linux/aio_misc.h:38:1: error: ‘__aio_create_helper_thread’
>> defined but not used [-Werror=unused-function]
>>    38 | __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
>>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> ../sysdeps/unix/sysv/linux/aio_misc.h:29:1: error: ‘__aio_start_notify_thread’ d
>> efined but not used [-Werror=unused-function]
>>    29 | __aio_start_notify_thread (void)
>>       | ^~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> So, they need a __attribute_maybe_unused__ annotation.

Yeah, or we should clean this up properly: It seems to me a generic
implementation of__aio_create_helper_thread could use
internal_signal_block_all.  And drop the stack size reduction
for __aio_create_helper_thread, perhaps.

Or use separate .c files with proper sysdeps overrides.
  
Florian Weimer May 4, 2026, 1:34 p.m. UTC | #5
* Cristian Rodriguez:

> On Fri, May 1, 2026 at 12:43 PM Peter Collingbourne <pcc@google.com> wrote:
>>
>> On Fri, May 1, 2026 at 1:39 AM Florian Weimer <fw@deneb.enyo.de> wrote:
>> >
>> > * Peter Collingbourne:
>> >
>> > > The following functions:
>> > >
>> > > __aio_create_helper_thread
>> > > __aio_start_notify_thread
>> > > __gai_create_helper_thread
>> > > __gai_start_notify_thread
>> > >
>> > > are declared as extern inline, but no translation unit provides their
>> > > real definitions. This can lead to a link failure if the functions are
>> > > not inlined. Fix it by declaring them as static inline instead.
>> >
>> > I would drop the “inline” as well, encouraging the compiler to make
>> > the inlining decision.
>>
>> That causes some build failures, e.g.
>>
>> In file included from aio_error.c:30:
>> ../sysdeps/unix/sysv/linux/aio_misc.h:38:1: error: ‘__aio_create_helper_thread’
>> defined but not used [-Werror=unused-function]
>>    38 | __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
>>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> ../sysdeps/unix/sysv/linux/aio_misc.h:29:1: error: ‘__aio_start_notify_thread’ d
>> efined but not used [-Werror=unused-function]
>>    29 | __aio_start_notify_thread (void)
>>       | ^~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> So, they need a __attribute_maybe_unused__ annotation.

Peter, could you post a v2 with this additional change?

Thanks,
Florian
  
Peter Collingbourne May 4, 2026, 5:51 p.m. UTC | #6
On Mon, May 4, 2026 at 6:34 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Cristian Rodriguez:
>
> > On Fri, May 1, 2026 at 12:43 PM Peter Collingbourne <pcc@google.com> wrote:
> >>
> >> On Fri, May 1, 2026 at 1:39 AM Florian Weimer <fw@deneb.enyo.de> wrote:
> >> >
> >> > * Peter Collingbourne:
> >> >
> >> > > The following functions:
> >> > >
> >> > > __aio_create_helper_thread
> >> > > __aio_start_notify_thread
> >> > > __gai_create_helper_thread
> >> > > __gai_start_notify_thread
> >> > >
> >> > > are declared as extern inline, but no translation unit provides their
> >> > > real definitions. This can lead to a link failure if the functions are
> >> > > not inlined. Fix it by declaring them as static inline instead.
> >> >
> >> > I would drop the “inline” as well, encouraging the compiler to make
> >> > the inlining decision.
> >>
> >> That causes some build failures, e.g.
> >>
> >> In file included from aio_error.c:30:
> >> ../sysdeps/unix/sysv/linux/aio_misc.h:38:1: error: ‘__aio_create_helper_thread’
> >> defined but not used [-Werror=unused-function]
> >>    38 | __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
> >>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> >> ../sysdeps/unix/sysv/linux/aio_misc.h:29:1: error: ‘__aio_start_notify_thread’ d
> >> efined but not used [-Werror=unused-function]
> >>    29 | __aio_start_notify_thread (void)
> >>       | ^~~~~~~~~~~~~~~~~~~~~~~~~
> >
> >
> > So, they need a __attribute_maybe_unused__ annotation.
>
> Peter, could you post a v2 with this additional change?

Setting aside whether it's really worth trying to encourage these
functions to be inlined (they start threads, which is expensive
anyway), "static inline __always_inline" seems like a better
expression of our intent, so I did that in v2.

Peter
  
Florian Weimer May 5, 2026, 8:31 a.m. UTC | #7
* Peter Collingbourne:

> The following functions:
>
> __aio_create_helper_thread
> __aio_start_notify_thread
> __gai_create_helper_thread
> __gai_start_notify_thread
>
> are declared as extern inline, but no translation unit provides their
> real definitions. This can lead to a link failure if the functions are
> not inlined. Fix it by declaring them as static inline instead.

This is better than the other patch, so let's use it.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Peter, can you push this yourself?

Thansk,
Florian
  
Peter Collingbourne May 5, 2026, 5:57 p.m. UTC | #8
On Tue, May 5, 2026 at 1:31 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Peter Collingbourne:
>
> > The following functions:
> >
> > __aio_create_helper_thread
> > __aio_start_notify_thread
> > __gai_create_helper_thread
> > __gai_start_notify_thread
> >
> > are declared as extern inline, but no translation unit provides their
> > real definitions. This can lead to a link failure if the functions are
> > not inlined. Fix it by declaring them as static inline instead.
>
> This is better than the other patch, so let's use it.
>
> Reviewed-by: Florian Weimer <fweimer@redhat.com>
>
> Peter, can you push this yourself?

I don't have access, can you do that for me please?

Peter
  
Peter Collingbourne May 8, 2026, 5:22 p.m. UTC | #9
On Tue, May 5, 2026 at 10:57 AM Peter Collingbourne <pcc@google.com> wrote:
>
> On Tue, May 5, 2026 at 1:31 AM Florian Weimer <fweimer@redhat.com> wrote:
> >
> > * Peter Collingbourne:
> >
> > > The following functions:
> > >
> > > __aio_create_helper_thread
> > > __aio_start_notify_thread
> > > __gai_create_helper_thread
> > > __gai_start_notify_thread
> > >
> > > are declared as extern inline, but no translation unit provides their
> > > real definitions. This can lead to a link failure if the functions are
> > > not inlined. Fix it by declaring them as static inline instead.
> >
> > This is better than the other patch, so let's use it.
> >
> > Reviewed-by: Florian Weimer <fweimer@redhat.com>
> >
> > Peter, can you push this yourself?
>
> I don't have access, can you do that for me please?

Ping

Peter
  
Florian Weimer May 8, 2026, 5:54 p.m. UTC | #10
* Peter Collingbourne:

> On Tue, May 5, 2026 at 10:57 AM Peter Collingbourne <pcc@google.com> wrote:
>>
>> On Tue, May 5, 2026 at 1:31 AM Florian Weimer <fweimer@redhat.com> wrote:
>> >
>> > * Peter Collingbourne:
>> >
>> > > The following functions:
>> > >
>> > > __aio_create_helper_thread
>> > > __aio_start_notify_thread
>> > > __gai_create_helper_thread
>> > > __gai_start_notify_thread
>> > >
>> > > are declared as extern inline, but no translation unit provides their
>> > > real definitions. This can lead to a link failure if the functions are
>> > > not inlined. Fix it by declaring them as static inline instead.
>> >
>> > This is better than the other patch, so let's use it.
>> >
>> > Reviewed-by: Florian Weimer <fweimer@redhat.com>
>> >
>> > Peter, can you push this yourself?
>>
>> I don't have access, can you do that for me please?
>
> Ping

Sorry, pushed now.

Thanks,
Florian
  

Patch

diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c
index 5cf6d7c149..3f13dc4520 100644
--- a/resolv/gai_misc.c
+++ b/resolv/gai_misc.c
@@ -28,7 +28,7 @@ 
 #ifndef gai_create_helper_thread
 # define gai_create_helper_thread __gai_create_helper_thread
 
-extern inline int
+static inline int
 __gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {
diff --git a/rt/aio_misc.c b/rt/aio_misc.c
index 724486e66f..639d693418 100644
--- a/rt/aio_misc.c
+++ b/rt/aio_misc.c
@@ -33,7 +33,7 @@ 
 #ifndef aio_create_helper_thread
 # define aio_create_helper_thread __aio_create_helper_thread
 
-extern inline int
+static inline int
 __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), void *arg)
 {
   pthread_attr_t attr;
diff --git a/sysdeps/mach/hurd/gai_misc.h b/sysdeps/mach/hurd/gai_misc.h
index 0237e59bf6..832c5ae1b6 100644
--- a/sysdeps/mach/hurd/gai_misc.h
+++ b/sysdeps/mach/hurd/gai_misc.h
@@ -22,7 +22,7 @@ 
 #define gai_start_notify_thread __gai_start_notify_thread
 #define gai_create_helper_thread __gai_create_helper_thread
 
-extern inline void
+static inline void
 __gai_start_notify_thread (void)
 {
   sigset_t ss;
@@ -32,7 +32,7 @@  __gai_start_notify_thread (void)
   assert_perror (sigerr);
 }
 
-extern inline int
+static inline int
 __gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {
diff --git a/sysdeps/nptl/gai_misc.h b/sysdeps/nptl/gai_misc.h
index 0416e271f4..8461fa88bf 100644
--- a/sysdeps/nptl/gai_misc.h
+++ b/sysdeps/nptl/gai_misc.h
@@ -76,7 +76,7 @@ 
 #define gai_start_notify_thread __gai_start_notify_thread
 #define gai_create_helper_thread __gai_create_helper_thread
 
-extern inline void
+static inline void
 __gai_start_notify_thread (void)
 {
   sigset_t ss;
@@ -84,7 +84,7 @@  __gai_start_notify_thread (void)
   (void) __pthread_sigmask (SIG_SETMASK, &ss, NULL);
 }
 
-extern inline int
+static inline int
 __gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {
diff --git a/sysdeps/unix/sysv/linux/aio_misc.h b/sysdeps/unix/sysv/linux/aio_misc.h
index 578ff1cf27..81a917f42d 100644
--- a/sysdeps/unix/sysv/linux/aio_misc.h
+++ b/sysdeps/unix/sysv/linux/aio_misc.h
@@ -25,7 +25,7 @@ 
 # define aio_start_notify_thread __aio_start_notify_thread
 # define aio_create_helper_thread __aio_create_helper_thread
 
-extern inline void
+static inline void
 __aio_start_notify_thread (void)
 {
   sigset_t ss;
@@ -34,7 +34,7 @@  __aio_start_notify_thread (void)
 			 __NSIG_BYTES);
 }
 
-extern inline int
+static inline int
 __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {