link error on Alpine Linux

Bruno Haible <[email protected]> Wed, 01 Feb 2023 20:43:11 +0100
Newsgroups gmane.comp.printing.a2ps.bugs
Message-ID <5308801.nraZDffYO5@nimes>
On Alpine Linux, the compilation produces warnings:

gcc -DHAVE_CONFIG_H -I. -I../../liba2ps -I..  -I.. -I../../liba2ps -I../../lib -I../lib -DLOCALEDIR=\"/home/bruno/inst-x86_64-64/share/locale\" -DSYSCONFFILE=\"/home/bruno/inst-x86_64-64/etc/a2ps.cfg\" -DHAVE_CONFIG_H -I/home/bruno/inst-x86_64-64/include -Wall  -g -O2 -MT libnowarnings_a-regex.o -MD -MP -MF .deps/libnowarnings_a-regex.Tpo -c -o libnowarnings_a-regex.o `test -f 'regex.c' || echo '../../liba2ps/'`regex.c
../../liba2ps/regex.c: In function 'regerror':
../../liba2ps/regex.c:5785:22: warning: implicit declaration of function '__mempcpy'; did you mean 'mempcpy'? [-Wimplicit-function-declaration]
 5785 |           *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
      |                      ^~~~~~~~~
      |                      mempcpy
../../liba2ps/regex.c:5785:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
 5785 |           *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
      |             ^

and later fails with a link error:

libtool: link: gcc -g -O2 -o a2ps main.o read.o sshread.o ssheet.o select.o generate.o delegate.o buffer.o versions.o ffaces.o  -L/home/bruno/inst-x86_64-64/lib ../liba2ps/.libs/liba2ps.a ../liba2ps/libnowarnings.a libparse.a ../lib/.libs/libgnu.a -lm /home/bruno/inst-x86_64-64/lib/libgc.so -lpthread -ldl /home/bruno/inst-x86_64-64/lib/libpaper.so -Wl,-rpath -Wl,/home/bruno/inst-x86_64-64/lib -Wl,-rpath -Wl,/home/bruno/inst-x86_64-64/lib
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: ../liba2ps/libnowarnings.a(libnowarnings_a-regex.o): in function `regerror':
/home/bruno/a2ps-4.14.94/build-64/liba2ps/../../liba2ps/regex.c:5785: undefined reference to `__mempcpy'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:1576: a2ps] Error 1

The cause is in the file liba2ps/regex.c. This is a completely, hopelessly
outdated regex code. It's highly recommended to use to gnulib 'regex' module,
which is not only well tested, but also POSIX compliant!

Bruno