bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: building GNU gettext on AIX


From: Bruno Haible
Subject: Re: building GNU gettext on AIX
Date: Sun, 19 Nov 2023 20:49:38 +0100

I wrote in
<https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636861.html>:
> > The latest issue is that a few files in gettext ignore --disable-pthreads
> > and creates a dependency on pthread_mutex.
> ...
>   * If no, then the simple solution would be to pass the configure option
>       --enable-threads=isoc
>     This should not introduce a link dependency, because the mtx_lock,
>     mtx_unlock, and mtx_init functions are in libc in AIX ≥ 7.2. Currently it
>     does not work (it still uses pthread_mutex_lock and pthread_mutex_unlock
>     despite --enable-threads=isoc). But I could make this work and release
>     a gettext 0.22.4 with the fix.

Alas, this approach does not help reducing the dependency towards libpthreads.
On AIX, pthread_mutex_t and mtx_t are the same type. Thus code like this
===================================================
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <threads.h>

pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER;

int main ()
{
  if (mtx_lock (&lock1) != thrd_success)
    abort ();

  if (mtx_unlock (&lock1) != thrd_success)
    abort ();
}
===================================================
compiles and runs fine. But the library dependencies still contain libpthreads.
This is in 32-bit mode:

$ ldd a.out
a.out needs:
         /usr/lib/libc.a(shr.o)
         /usr/lib/libc.a(cthread.o)
         /usr/lib/libc.a(_shr.o)
         /unix
         /usr/lib/libcrypt.a(shr.o)
         /usr/lib/libpthreads.a(shr_xpg5.o)
         /usr/lib/libpthreads.a(_shr_xpg5.o)
         /usr/lib/libpthreads.a(shr_comm.o)

and this in 64-bit mode:

$ ldd a.out 
a.out needs:
         /usr/lib/libc.a(shr_64.o)
         /usr/lib/libc.a(cthread_64.o)
         /usr/lib/libc.a(_shr_64.o)
         /unix
         /usr/lib/libcrypt.a(shr_64.o)
         /usr/lib/libpthreads.a(shr_xpg5_64.o)
         /usr/lib/libpthreads.a(_shr_xpg5_64.o)

Apparently the mtx_* functions are provided by
  /usr/lib/libc.a(cthread_64.o)
and this one depends on
  /usr/lib/libpthreads.a(shr_xpg5_64.o)
  /usr/lib/libpthreads.a(_shr_xpg5_64.o)

So, there can be only three ways to build GCC on AIX:

  - With --disable-nls. No i18n, no libpthreads dependency.
  - With --enable-nls, linked against a libintl created in the build
    tree with --disable-shared --disable-threads (requires gettext ≥ 0.22.4).
    Has i18n, but no libpthreads dependency.
  - With --enable-nls, linked against a public libintl. Depends on libpthreads.

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]