From 5196ca7b545b2df67545bb548e6115492235aeaa Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 18 Dec 2024 17:44:06 -0600 Subject: [PATCH] AIX: Link syscall users with -Wl,-bI:afsl.exp When building with --disable-static on AIX, linking various binaries that call syscall() currently fail: /bin/sh ../../libtool --quiet --mode=link --tag=CC /opt/IBM/xlC/16.1.0/bin/xlc_r -static [...] -o afsd afsd.o afsd_kernel.o [...] ld: 0711-317 ERROR: Undefined symbol: .syscall ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. make: The error code from the last command is 8. There is indeed no symbol 'syscall', because that is a (confusingly-named) syscall provided by our libafs kernel module. To tell the linker that syscall() is a syscall, import our afsl.exp by passing the -Wl,-bI: flag to the linker for all binaries that call it. To make it easier to see what's going on, add the AIX_ONLY subst var, to make it easy to create an AIX-only line in the relevant Makefiles. Change-Id: Id57bf9e6a438c57eded693a1e4ed39b08d36e3c7 Reviewed-on: https://gerrit.openafs.org/15999 Reviewed-by: Ben Huntsman Tested-by: Ben Huntsman Reviewed-by: Michael Meffie Reviewed-by: Mark Vitale Tested-by: BuildBot Reviewed-by: Andrew Deason --- src/afsd/Makefile.in | 5 ++++- src/cf/osconf.m4 | 7 +++++++ src/dviced/Makefile.in | 1 + src/dvolser/Makefile.in | 1 + src/tvolser/Makefile.in | 1 + src/viced/Makefile.in | 1 + src/volser/Makefile.in | 1 + 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/afsd/Makefile.in b/src/afsd/Makefile.in index 84e4b6418c..1ea788ed50 100644 --- a/src/afsd/Makefile.in +++ b/src/afsd/Makefile.in @@ -10,6 +10,9 @@ srcdir=@srcdir@ include @TOP_OBJDIR@/src/config/Makefile.config include @TOP_OBJDIR@/src/config/Makefile.pthread +# On AIX, we need to import afsl.exp so the linker can understand that +# syscall() is a syscall provided by libafs. +@AIX_ONLY@AFSD_KERNEL_LDFLAGS=-Wl,-bI:../sys/afsl.exp # # What to make @@ -34,7 +37,7 @@ UAFSLIBS=$(top_builddir)/src/cmd/liboafs_cmd.la \ FUSE_LIBS=@FUSE_LIBS@ -LDFLAGS_afsd = $(AFSD_LDFLAGS) +LDFLAGS_afsd = $(AFSD_LDFLAGS) $(AFSD_KERNEL_LDFLAGS) afsd: afsd.o afsd_kernel.o $(AFSLIBS) $(AFSD_LIBS) $(LT_LDRULE_static) afsd.o afsd_kernel.o $(NON_SHARED) \ $(AFSLIBS) ${AFSD_LIBS} $(LIB_hcrypto) $(LIB_roken) $(MT_LIBS) diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index 72c012ca0d..c3d8864ec0 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -708,6 +708,13 @@ else esac fi +dnl For convenience for AIX-only Makefile quirks, comment out all @AIX_ONLY@ +dnl lines in our Makefiles on non-AIX. +AIX_ONLY='#' +AS_CASE([$AFS_SYSNAME], + [rs_aix*], [AIX_ONLY=]) +AC_SUBST([AIX_ONLY]) + dnl add additional checks if compilers support the flags AS_IF([test "x$enable_checking" != "xno"], [AX_APPEND_COMPILE_FLAGS([-Wimplicit-fallthrough], [XCFLAGS], [-Werror]) diff --git a/src/dviced/Makefile.in b/src/dviced/Makefile.in index 086dbe5f0f..bc8b050083 100644 --- a/src/dviced/Makefile.in +++ b/src/dviced/Makefile.in @@ -137,6 +137,7 @@ afsint.ss.o: ../fsint/afsint.ss.c state_analyzer.o: ${VICED}/state_analyzer.c $(AFS_CCRULE) $(VICED)/state_analyzer.c +@AIX_ONLY@LDFLAGS_dafileserver = -Wl,-bI:../sys/afsl.exp dafileserver: ${objects} ${LIBS} $(LT_LDRULE_static) ${objects} \ ${LIBS} $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} diff --git a/src/dvolser/Makefile.in b/src/dvolser/Makefile.in index 41bec98856..b474f7cb91 100644 --- a/src/dvolser/Makefile.in +++ b/src/dvolser/Makefile.in @@ -135,6 +135,7 @@ ihandle.o: ${VOL}/ihandle.c namei_ops.o: ${VOL}/namei_ops.c $(AFS_CCRULE) $(VOL)/namei_ops.c +@AIX_ONLY@LDFLAGS_davolserver = -Wl,-bI:../sys/afsl.exp davolserver: ${objects} ${LIBS} $(LT_LDRULE_static) ${objects} ${LIBS} $(LIB_hcrypto) $(LIB_roken) \ ${MT_LIBS} ${XLIBS} diff --git a/src/tvolser/Makefile.in b/src/tvolser/Makefile.in index 0a7e0c5480..0f0c8e21a8 100644 --- a/src/tvolser/Makefile.in +++ b/src/tvolser/Makefile.in @@ -180,6 +180,7 @@ vos: vos.o ${VOSOBJS} ${VLSERVEROBJS} $(LIBS_client) $(LT_LDRULE_static) vos.o ${VOSOBJS} ${VLSERVEROBJS} $(LIBS_client) \ $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} +@AIX_ONLY@LDFLAGS_volserver = -Wl,-bI:../sys/afsl.exp volserver: ${objects} $(LIBS_server) $(LT_LDRULE_static) ${objects} $(LIBS_server) \ $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} diff --git a/src/viced/Makefile.in b/src/viced/Makefile.in index 46575d74a6..427b81ffb3 100644 --- a/src/viced/Makefile.in +++ b/src/viced/Makefile.in @@ -126,6 +126,7 @@ namei_ops.o: ${VOL}/namei_ops.c afsint.ss.o: ../fsint/afsint.ss.c $(AFS_CCRULE) ../fsint/afsint.ss.c +@AIX_ONLY@LDFLAGS_fileserver = -Wl,-bI:../sys/afsl.exp fileserver: ${objects} ${LIBS} $(LT_LDRULE_static) ${objects} \ ${LIBS} $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} diff --git a/src/volser/Makefile.in b/src/volser/Makefile.in index 62b1e0bffb..e6437d2f55 100644 --- a/src/volser/Makefile.in +++ b/src/volser/Makefile.in @@ -106,6 +106,7 @@ vos: vos.o libvolser.a ${LIBS} $(AFS_LDRULE) vos.o libvolser.a \ ${LIBS} $(LIB_roken) ${XLIBS} +@AIX_ONLY@LDFLAGS_volserver = -Wl,-bI:../sys/afsl.exp volserver: $(SOBJS) volerr.lo volint.xdr.lo volint.cs.lo \ $(LIBS) ${TOP_LIBDIR}/libdir.a $(AFS_LDRULE) $(SOBJS) .lwp/volerr.o .lwp/volint.xdr.o .lwp/volint.cs.o \