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 <ben@huntsmans.net>
Tested-by: Ben Huntsman <ben@huntsmans.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
This commit is contained in:
Andrew Deason 2024-12-18 17:44:06 -06:00
parent a7cd613437
commit 5196ca7b54
7 changed files with 16 additions and 1 deletions

View File

@ -10,6 +10,9 @@ srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config include @TOP_OBJDIR@/src/config/Makefile.config
include @TOP_OBJDIR@/src/config/Makefile.pthread 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 # What to make
@ -34,7 +37,7 @@ UAFSLIBS=$(top_builddir)/src/cmd/liboafs_cmd.la \
FUSE_LIBS=@FUSE_LIBS@ FUSE_LIBS=@FUSE_LIBS@
LDFLAGS_afsd = $(AFSD_LDFLAGS) LDFLAGS_afsd = $(AFSD_LDFLAGS) $(AFSD_KERNEL_LDFLAGS)
afsd: afsd.o afsd_kernel.o $(AFSLIBS) $(AFSD_LIBS) afsd: afsd.o afsd_kernel.o $(AFSLIBS) $(AFSD_LIBS)
$(LT_LDRULE_static) afsd.o afsd_kernel.o $(NON_SHARED) \ $(LT_LDRULE_static) afsd.o afsd_kernel.o $(NON_SHARED) \
$(AFSLIBS) ${AFSD_LIBS} $(LIB_hcrypto) $(LIB_roken) $(MT_LIBS) $(AFSLIBS) ${AFSD_LIBS} $(LIB_hcrypto) $(LIB_roken) $(MT_LIBS)

View File

@ -708,6 +708,13 @@ else
esac esac
fi 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 dnl add additional checks if compilers support the flags
AS_IF([test "x$enable_checking" != "xno"], AS_IF([test "x$enable_checking" != "xno"],
[AX_APPEND_COMPILE_FLAGS([-Wimplicit-fallthrough], [XCFLAGS], [-Werror]) [AX_APPEND_COMPILE_FLAGS([-Wimplicit-fallthrough], [XCFLAGS], [-Werror])

View File

@ -137,6 +137,7 @@ afsint.ss.o: ../fsint/afsint.ss.c
state_analyzer.o: ${VICED}/state_analyzer.c state_analyzer.o: ${VICED}/state_analyzer.c
$(AFS_CCRULE) $(VICED)/state_analyzer.c $(AFS_CCRULE) $(VICED)/state_analyzer.c
@AIX_ONLY@LDFLAGS_dafileserver = -Wl,-bI:../sys/afsl.exp
dafileserver: ${objects} ${LIBS} dafileserver: ${objects} ${LIBS}
$(LT_LDRULE_static) ${objects} \ $(LT_LDRULE_static) ${objects} \
${LIBS} $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} ${LIBS} $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS}

View File

@ -135,6 +135,7 @@ ihandle.o: ${VOL}/ihandle.c
namei_ops.o: ${VOL}/namei_ops.c namei_ops.o: ${VOL}/namei_ops.c
$(AFS_CCRULE) $(VOL)/namei_ops.c $(AFS_CCRULE) $(VOL)/namei_ops.c
@AIX_ONLY@LDFLAGS_davolserver = -Wl,-bI:../sys/afsl.exp
davolserver: ${objects} ${LIBS} davolserver: ${objects} ${LIBS}
$(LT_LDRULE_static) ${objects} ${LIBS} $(LIB_hcrypto) $(LIB_roken) \ $(LT_LDRULE_static) ${objects} ${LIBS} $(LIB_hcrypto) $(LIB_roken) \
${MT_LIBS} ${XLIBS} ${MT_LIBS} ${XLIBS}

View File

@ -180,6 +180,7 @@ vos: vos.o ${VOSOBJS} ${VLSERVEROBJS} $(LIBS_client)
$(LT_LDRULE_static) vos.o ${VOSOBJS} ${VLSERVEROBJS} $(LIBS_client) \ $(LT_LDRULE_static) vos.o ${VOSOBJS} ${VLSERVEROBJS} $(LIBS_client) \
$(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS}
@AIX_ONLY@LDFLAGS_volserver = -Wl,-bI:../sys/afsl.exp
volserver: ${objects} $(LIBS_server) volserver: ${objects} $(LIBS_server)
$(LT_LDRULE_static) ${objects} $(LIBS_server) \ $(LT_LDRULE_static) ${objects} $(LIBS_server) \
$(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS}

View File

@ -126,6 +126,7 @@ namei_ops.o: ${VOL}/namei_ops.c
afsint.ss.o: ../fsint/afsint.ss.c afsint.ss.o: ../fsint/afsint.ss.c
$(AFS_CCRULE) ../fsint/afsint.ss.c $(AFS_CCRULE) ../fsint/afsint.ss.c
@AIX_ONLY@LDFLAGS_fileserver = -Wl,-bI:../sys/afsl.exp
fileserver: ${objects} ${LIBS} fileserver: ${objects} ${LIBS}
$(LT_LDRULE_static) ${objects} \ $(LT_LDRULE_static) ${objects} \
${LIBS} $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} ${LIBS} $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS}

View File

@ -106,6 +106,7 @@ vos: vos.o libvolser.a ${LIBS}
$(AFS_LDRULE) vos.o libvolser.a \ $(AFS_LDRULE) vos.o libvolser.a \
${LIBS} $(LIB_roken) ${XLIBS} ${LIBS} $(LIB_roken) ${XLIBS}
@AIX_ONLY@LDFLAGS_volserver = -Wl,-bI:../sys/afsl.exp
volserver: $(SOBJS) volerr.lo volint.xdr.lo volint.cs.lo \ volserver: $(SOBJS) volerr.lo volint.xdr.lo volint.cs.lo \
$(LIBS) ${TOP_LIBDIR}/libdir.a $(LIBS) ${TOP_LIBDIR}/libdir.a
$(AFS_LDRULE) $(SOBJS) .lwp/volerr.o .lwp/volint.xdr.o .lwp/volint.cs.o \ $(AFS_LDRULE) $(SOBJS) .lwp/volerr.o .lwp/volint.xdr.o .lwp/volint.cs.o \