From 150ca3c410f0017fcf39dbd1dfeda947889f843a Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Tue, 19 Nov 2024 17:30:56 -0600 Subject: [PATCH] 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 Reviewed-by: Ben Huntsman Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk --- src/rx/test/Makefile.in | 2 +- src/rxkad/test/Makefile.in | 1 - src/tests/Makefile.in | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rx/test/Makefile.in b/src/rx/test/Makefile.in index f1dcfe279a..fdff1b9d7c 100644 --- a/src/rx/test/Makefile.in +++ b/src/rx/test/Makefile.in @@ -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 diff --git a/src/rxkad/test/Makefile.in b/src/rxkad/test/Makefile.in index c0ea1374d9..7edea1d439 100644 --- a/src/rxkad/test/Makefile.in +++ b/src/rxkad/test/Makefile.in @@ -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 \ diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in index 32365659af..5cebd35366 100644 --- a/src/tests/Makefile.in +++ b/src/tests/Makefile.in @@ -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 \