Reported from a RHEL-family build:
/bin/ld: API_lex.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//usr/lib64/libdl.so.2: error adding symbols: DSO missing from command line
make[2]: *** [Makefile:192: ../../bin/4glc] Error 1
4glc calls dlclose() itself - the .spec-generated API_lex.c and
API_parse.c declare their own prototype for it and call it from
A4GLLEX_clrlibptr() - so it has to link against libdl in its own right,
not lean on libaubit4gl having pulled it in. Nothing put -ldl on the
line: configure has worked out USE_LIBDL correctly all along, but no
Makefile ever used it, and EXTRALIBS - which the link lines do use - is
substituted empty.
It only shows on some distributions because glibc 2.34 merged libdl
into libc. On Debian and Ubuntu dlclose resolves out of libc and the
missing library is invisible; on RHEL, Alma and Rocky 8, where
libdl.so.2 is still its own object, the link fails. compilers/pcode has
the same direct calls and so had the same latent problem.
USE_LIBDL now goes into EXTRASYSTEMLIBS, which every link rule already
uses, so this covers the executables rather than just the one that was
reported. It is empty on macOS, where dlopen is in libc anyway, and
-ldl still links harmlessly on a merged-libc glibc - the stub library
is kept for compatibility - so nothing needs to be conditional beyond
what configure already decides.
Verified: -ldl now appears on the 4glc link line, 4glc rebuilds and
runs, and the end-to-end probes still pass.