Subject: [PATCH] build: fix link errors on AIX

From: Collin Funk <[email-masked]>
Date: Tue, 04 Mar 2025 19:38:17 -0800

On AIX, I see the following:

  CCLD     src/cppi
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status

This is due to some gnulib functions using mbrtoc32, etc. which use
locks.

The following patch adds the link flags.

Collin

>From 14dd28ec99b351d54ee1406000815a1f9ff4069d Mon Sep 17 00:00:00 2001
From: Collin Funk <[email-masked]>
Date: Tue, 4 Mar 2025 19:33:37 -0800
Subject: [PATCH] build: fix link errors on AIX

* src/local.mk (LDADD): Add libraries listed by gnulib-tool --import.
* .gitignore: Add files generated by Gnulib.
---
 .gitignore   | 20 ++++++++++++++++++++
 src/local.mk |  4 +++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index ecb861c..25c40c5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,17 +25,37 @@
 /lex.backup
 /lib/*.o
 /lib/.gitignore
+/lib/alloca.h
 /lib/arg-nonnull.h
 /lib/c++defs.h
 /lib/charset.alias
 /lib/config.h
 /lib/configmake.h
+/lib/error.h
+/lib/fcntl.h
 /lib/glthread
 /lib/gnulib.mk.bak
+/lib/inttypes.h
 /lib/libcppi.a
+/lib/limits.h
 /lib/link-warning.h
+/lib/locale.h
+/lib/obstack.h
 /lib/stamp-h1
+/lib/stddef.h
+/lib/stdio.h
+/lib/stdlib.h
+/lib/string.h
+/lib/sys/
+/lib/time.h
+/lib/uchar.h
+/lib/unictype.h
+/lib/unictype/
+/lib/unistd.h
+/lib/unitypes.h
 /lib/warn-on-use.h
+/lib/wchar.h
+/lib/wctype.h
 /m4
 /m4/.gitignore
 /maint.mk
diff --git a/src/local.mk b/src/local.mk
index c43c32e..5717831 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -20,7 +20,9 @@ GPERF = gperf
 
 AM_CPPFLAGS += -I$(top_srcdir)/lib -Isrc -I$(top_srcdir)/src
 
-LDADD = $(top_builddir)/lib/libcppi.a $(LIBINTL) $(top_builddir)/lib/libcppi.a
+LDADD = $(top_builddir)/lib/libcppi.a $(LIBINTL) \
+  $(top_builddir)/lib/libcppi.a $(HARD_LOCALE_LIB) $(LIBC32CONV) \
+  $(LIBUNISTRING) $(MBRTOWC_LIB) $(SETLOCALE_NULL_LIB)
 
 GPERF_OPTIONS = \
   -C -N cpp_cond_lookup -n -t -s 6 -k '*' --language=ANSI-C
-- 
2.48.1