Re: link error on Alpine Linux

Reuben Thomas <[email protected]> Sat, 4 Feb 2023 23:45:51 +0000
Newsgroups gmane.comp.printing.a2ps.bugs
Message-ID <CAOnWdoj8gSc07EiyGSt_5Nf6=qX8mYRuJDg2fkQXN+ORVpAVWA@mail.gmail.com>
--00000000000098c60c05f3e86631
Content-Type: text/plain; charset="UTF-8"

On Wed, 1 Feb 2023 at 19:43, Bruno Haible <[email protected]> wrote:

> 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!
>

Unfortunately, as previously discussed on the gnulib list, the regex module
does not support syntax tables, which a2ps uses.
I have tried to clean up the code a bit, removing dead code and assuming a
>= C89 system.

-- 
https://rrt.sc3d.org

--00000000000098c60c05f3e86631
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail=
_attr">On Wed, 1 Feb 2023 at 19:43, Bruno Haible &lt;<a href=3D"mailto:brun=
[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"g=
mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204=
,204,204);padding-left:1ex">On Alpine Linux, the compilation produces warni=
ngs:<br>
<br>
gcc -DHAVE_CONFIG_H -I. -I../../liba2ps -I..=C2=A0 -I.. -I../../liba2ps -I.=
./../lib -I../lib -DLOCALEDIR=3D\&quot;/home/bruno/inst-x86_64-64/share/loc=
ale\&quot; -DSYSCONFFILE=3D\&quot;/home/bruno/inst-x86_64-64/etc/a2ps.cfg\&=
quot; -DHAVE_CONFIG_H -I/home/bruno/inst-x86_64-64/include -Wall=C2=A0 -g -=
O2 -MT libnowarnings_a-regex.o -MD -MP -MF .deps/libnowarnings_a-regex.Tpo =
-c -o libnowarnings_a-regex.o `test -f &#39;regex.c&#39; || echo &#39;../..=
/liba2ps/&#39;`regex.c<br>
../../liba2ps/regex.c: In function &#39;regerror&#39;:<br>
../../liba2ps/regex.c:5785:22: warning: implicit declaration of function &#=
39;__mempcpy&#39;; did you mean &#39;mempcpy&#39;? [-Wimplicit-function-dec=
laration]<br>
=C2=A05785 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*((char *) __mempcpy (=
errbuf, msg, errbuf_size - 1)) =3D &#39;\0&#39;;<br>
=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 ^~~~~~~~~<br>
=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 mempcpy<br>
../../liba2ps/regex.c:5785:13: warning: cast to pointer from integer of dif=
ferent size [-Wint-to-pointer-cast]<br>
=C2=A05785 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*((char *) __mempcpy (=
errbuf, msg, errbuf_size - 1)) =3D &#39;\0&#39;;<br>
=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^<br>
<br>
and later fails with a link error:<br>
<br>
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=C2=A0 -L/home/bruno/ins=
t-x86_64-64/lib ../liba2ps/.libs/liba2ps.a ../liba2ps/libnowarnings.a libpa=
rse.a ../lib/.libs/libgnu.a -lm /home/bruno/inst-x86_64-64/lib/libgc.so -lp=
thread -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<br>
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linu=
x-musl/bin/ld: ../liba2ps/libnowarnings.a(libnowarnings_a-regex.o): in func=
tion `regerror&#39;:<br>
/home/bruno/a2ps-4.14.94/build-64/liba2ps/../../liba2ps/regex.c:5785: undef=
ined reference to `__mempcpy&#39;<br>
collect2: error: ld returned 1 exit status<br>
make[3]: *** [Makefile:1576: a2ps] Error 1<br>
<br>
The cause is in the file liba2ps/regex.c. This is a completely, hopelessly<=
br>
outdated regex code. It&#39;s highly recommended to use to gnulib &#39;rege=
x&#39; module,<br>
which is not only well tested, but also POSIX compliant!<br></blockquote><d=
iv><br></div><div><div style=3D"font-family:arial,helvetica,sans-serif;font=
-size:small" class=3D"gmail_default">Unfortunately, as previously discussed=
 on the gnulib list, the regex module does not support syntax tables, which=
 a2ps uses.<font color=3D"#888888"><br></font></div><div style=3D"font-fami=
ly:arial,helvetica,sans-serif;font-size:small" class=3D"gmail_default">I ha=
ve tried to clean up the code a bit, removing dead code and assuming a &gt;=
=3D C89 system.</div></div><div>=C2=A0</div></div>-- <br><div dir=3D"ltr" c=
lass=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><a href=3D"=
https://rrt.sc3d.org" target=3D"_blank">https://rrt.sc3d.org</a></div></div=
></div></div></div>

--00000000000098c60c05f3e86631--