Link LWP binaries with libafshcrypto_lwp.a

Most of our binaries link with -lhcrypto or our internally-built
-lafshcrypto for heimdal-provided crypto code. But we also build an LWP
variant, libafshcrypto_lwp.a, which avoids any pthread calls and is to
be used when linking against LWP instead of pthreads.

Currently, a few binaries link against LWP, but also link against
$(LIB_hcrypto) (which gets expanded to -lhcrypto or -lafshcrypto). This
includes most binaries in src/tests, src/rx/test, and src/rxkad/test,
and has been the case since these commits:

  236cb51b83 rx: Cleanup and build src/rx/test
  1fe1dac4c5 rxkad: Cleanup and build src/rxkad/test
  80c23d958c tests: Make src/tests buildable

On most platforms, this isn't so noticeable; the binaries just get built
for LWP, but have a pthreaded hcrypto and contain references to
pthreads. (hcrypto itself just uses a single global mutex that is
briefly held, and so tends to not cause cause any problems running with
LWP.)

On AIX, this causes a build error when building with --disable-shared,
because we build these programs without linking to the pthreads library:

  /opt/IBM/xlC/16.1.0/bin/cc [...] -o test-setgroups test-setgroups.o [...]/lib/libopr.a -lafshcrypto -lrokenafs
  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.
  make: *** [test-setgroups] Error 8

(Without --disable-shared, this succeeds, presumably because we link
against the libtool libafshcrypto.la library, which is smart enough to
know it depends on pthreads.)

To fix this, link against libafshcrypto_lwp.a for these LWP binaries
instead of $(LIB_hcrypto), like other LWP binaries do. We could maybe
change $(LIB_hcrypto) to expand to libafshcrypto_lwp.a for Makefile.lwp,
but that can be confusing, especially for directories that build both
LWP and pthreaded binaries.

Written in collaboration with ben@huntsmans.net, who noticed the issue
and provided testing.

Change-Id: Ic4eef01c40e3ecdc4a8dc999b21273d7da364d34
Reviewed-on: https://gerrit.openafs.org/15904
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Ben Huntsman <ben@huntsmans.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Andrew Deason 2024-11-19 17:30:56 -06:00
parent 2f26bce858
commit 150ca3c410
3 changed files with 2 additions and 3 deletions

View File

@ -13,7 +13,7 @@ include @TOP_OBJDIR@/src/config/Makefile.lwp
LDIRS= -L.. -L${TOP_LIBDIR}
LIBS= ${TOP_LIBDIR}/libcmd.a ../librx.a ${TOP_LIBDIR}/liblwp.a \
${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libopr.a \
${LIB_hcrypto} ${LIB_roken} ${XLIBS}
${TOP_LIBDIR}/libafshcrypto_lwp.a ${LIB_roken} ${XLIBS}
MODULE_CFLAGS=-DRXDEBUG

View File

@ -27,7 +27,6 @@ LIBS=${TOP_LIBDIR}/libauth.a \
${TOP_LIBDIR}/util.a \
${TOP_LIBDIR}/libopr.a \
${TOP_LIBDIR}/libafsrfc3961.a \
${LIB_hcrypto} \
${LIB_roken}
THLIBS= ${TOP_LIBDIR}/libcmd.a \

View File

@ -23,7 +23,7 @@ INT_LIBS = ${TOP_LIBDIR}/libafsint.a \
COMMON_LIBS = ${LIBS} \
${TOP_LIBDIR}/libopr.a \
${LIB_hcrypto} \
${TOP_LIBDIR}/libafshcrypto_lwp.a \
${LIB_roken}
TEST_PROGRAMS = write-ro-file hello-world read-vs-mmap read-vs-mmap2 \