When building GNU libiconv with option --enable-relocatable, without compiler optimizations (e.g. with CFLAGS=-g), on a platform that is old or fringe (such as NetBSD 7), a compilation error occurs during the 'make install' step, while linking the reloc-wrapper:
gcc -std=gnu11 -g -I../srclib -I../srclib -I.. -DHAVE_CONFIG_H -DIN_RELOCWRAPPER -DNO_XMALLOC -DINSTALLPREFIX=\"/home/bruno/inst\" -DINSTALLDIR=\"/home/bruno/inst/bin\" -DLIBPATHVAR=\"LD_LIBRARY_PATH\" -DLIBDIRS=\"/home/bruno/inst/lib\", -DEXEEXT=\"\" ../srclib/relocwrapper.c ../srclib/progname.c ../srclib/progreloc.c ../srclib/areadlink.c ../srclib/careadlinkat.c ../srclib/allocator.c ../srclib/readlink.c ../srclib/stat.c ../srclib/canonicalize-lgpl.c ../srclib/malloc/scratch_buffer_dupfree.c ../srclib/malloc/scratch_buffer_grow.c ../srclib/malloc/scratch_buffer_grow_preserve.c ../srclib/malloc/scratch_buffer_set_array_size.c ../srclib/malloc.c ../srclib/realloc.c ../srclib/free.c ../srclib/mempcpy.c ../srclib/rawmemchr.c ../srclib/malloca.c ../srclib/relocatable.c ../srclib/setenv.c ../srclib/c-ctype.c -o /home/bruno/inst/bin/iconv.wrapper /var/tmp//ccWVClby.o: In function `rpl_stat': /home/bruno/libiconv-1.17/src/../srclib/stat.c:436: undefined reference to `stat_time_normalize' Makefile:113: recipe for target 'install' failed gmake[1]: *** [install] Error 1 The cause is that the file srclib/stat-time.o, which defines the symbol 'stat_time_normalize' when not optimizing, is not part of the link. This patch fixes it. 2024-11-10 Bruno Haible <br...@clisp.org> relocatable-prog-wrapper: Fix compilation error on NetBSD 7. Reported by Ionut Cosmin Mihai <ionut.cosmin.mi...@gmail.com> in <https://lists.gnu.org/archive/html/bug-gnu-libiconv/2024-11/msg00000.html>. * lib/relocwrapper.c: Fix dependency tree. * modules/relocatable-prog-wrapper (Files): Add lib/stat-time.h, lib/stat-time.c. * build-aux/install-reloc (func_create_wrapper): Compile also stat-time.c. diff --git a/build-aux/install-reloc b/build-aux/install-reloc index ea2e5cc6da..b471df66d9 100755 --- a/build-aux/install-reloc +++ b/build-aux/install-reloc @@ -287,6 +287,7 @@ func_create_wrapper () "$srcdir"/allocator.c \ "$srcdir"/readlink.c \ "$srcdir"/stat.c \ + "$srcdir"/stat-time.c \ "$srcdir"/canonicalize-lgpl.c \ "$srcdir"/malloc/scratch_buffer_grow.c \ "$srcdir"/malloc/scratch_buffer_grow_preserve.c \ diff --git a/lib/relocwrapper.c b/lib/relocwrapper.c index b40f88cfdf..8d28f04436 100644 --- a/lib/relocwrapper.c +++ b/lib/relocwrapper.c @@ -22,6 +22,7 @@ -> stat -> filename -> pathmax + -> stat-time -> verify -> areadlink -> careadlinkat diff --git a/modules/relocatable-prog-wrapper b/modules/relocatable-prog-wrapper index 7e0625b1f3..859e097851 100644 --- a/modules/relocatable-prog-wrapper +++ b/modules/relocatable-prog-wrapper @@ -16,6 +16,8 @@ lib/allocator.h lib/allocator.c lib/readlink.c lib/stat.c +lib/stat-time.h +lib/stat-time.c lib/canonicalize-lgpl.c lib/scratch_buffer.h lib/malloc/scratch_buffer.h