From e030709dc7be0be011a86ffdb95ac39e10cd7fbf Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Wed, 8 Mar 2023 11:51:08 -0800 Subject: [PATCH] LU-16115 build: Linux 5.17 external module support Linux commit v5.16-rc3-26-g129ab0d2d9f3 Added quotes around "$(CONFIG_CC_VERSION_TEXT)", however .config stores CONFIG_CC_VERSION_TEXT with quotes thus breaking the GNU make Makefile for external modules. We need to supply a non-quoted value and override the value in .config before it is used. Lustre-change: https://review.whamcloud.com/48360 Lustre-commit: 945ab61176213e082dfd6b3a2a35aa4687e31129 Test-Parameters: trivial HPE-bug-id: LUS-11190 Signed-off-by: Shaun Tancheff Change-Id: I997b6987ef37a8c5b9d8f0984e81d9402a2ea705 Reviewed-by: Jian Yu Reviewed-by: Andreas Dilger Reviewed-by: jsimmons Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49114 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- autoMakefile.am | 7 ++++++- build/Makefile | 6 ++++++ config/lustre-build-linux.m4 | 39 ++++++++++++++++++++++++++++++++++----- config/lustre-build.m4 | 1 + 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/autoMakefile.am b/autoMakefile.am index 3448fc3..8c2eeb7 100644 --- a/autoMakefile.am +++ b/autoMakefile.am @@ -16,6 +16,10 @@ DIST_SUBDIRS := ldiskfs \ AUTOMAKE_OPTIONS = foreign +if DEQUOTE_CC_VERSION_TEXT +DEQUOTE = yes +endif + FIND_TAG_FILES_CMD = find $(top_srcdir) \ -path $(top_srcdir)/ldiskfs/linux-stage \ -prune -false -o -type f -name '*.[hc]' @@ -72,7 +76,8 @@ if LINUX all-am: modules modules: undef.h ldiskfs-sources - $(MAKE) LDFLAGS= CC="$(CC)" -C $(LINUX_OBJ) \ + $(MAKE) DEQUOTE_CC_VERSION_TEXT=$(DEQUOTE) \ + LDFLAGS= CC="$(CC)" -C $(LINUX_OBJ) \ -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \ LINUXINCLUDE='-I$$(srctree)/arch/$$(SRCARCH)/include -Iarch/$$(SRCARCH)/include/generated -Iinclude $$(if $$(KBUILD_SRC)$$(building_out_of_srctree),-Iinclude2 -I$$(srctree)/include) -I$$(srctree)/arch/$$(SRCARCH)/include/uapi -Iarch/$$(SRCARCH)/include/generated/uapi -I$$(srctree)/include/uapi -Iinclude/generated/uapi -include $(CONFIG_INCLUDE)' \ $(MODULE_TARGET)=$(PWD) -o tmp_include_depends -o scripts -o \ diff --git a/build/Makefile b/build/Makefile index 5241494..b5f2f69 100644 --- a/build/Makefile +++ b/build/Makefile @@ -25,10 +25,16 @@ else # so "include Makefile" below includes $LINUX/Makefile, not this file include $(LUSTRE_LINUX_CONFIG) include Makefile +ifeq ($(DEQUOTE_CC_VERSION_TEXT),yes) +CONFIG_CC_VERSION_TEXT=$(shell echo ${CONFIG_CC_VERSION_TEXT:1:-1}) +endif endif # LUSTRE_LINUX_CONFIG else # PATCHLEVEL +ifeq ($(DEQUOTE_CC_VERSION_TEXT),yes) +CONFIG_CC_VERSION_TEXT=$(shell echo ${CONFIG_CC_VERSION_TEXT:1:-1}) +endif # case #3 ifneq ($(LUSTRE_KERNEL_TEST),) diff --git a/config/lustre-build-linux.m4 b/config/lustre-build-linux.m4 index 43947bb..db1b2ea 100644 --- a/config/lustre-build-linux.m4 +++ b/config/lustre-build-linux.m4 @@ -30,8 +30,25 @@ AC_CACHE_CHECK([for external module build target], lb_cv_module_target, [$makerule LUSTRE_KERNEL_TEST=conftest.i], [test -s build/conftest.i], [lb_cv_module_target="M58"], [ + makerule="" + lb_cv_dequote_CC_VERSION_TEXT=yes + LB_LINUX_TRY_MAKE([], [], + [$makerule LUSTRE_KERNEL_TEST=conftest.i], + [test -s build/conftest.i], + [lb_cv_module_target="M517"], [ AC_MSG_ERROR([kernel module make failed; check config.log for details]) - ])])]) + ])])])]) +]) +# Linux commit v5.16-rc3-26-g129ab0d2d9f3 +# added quotes around "$(CONFIG_CC_VERSION_TEXT)", however .config stores +# CONFIG_CC_VERSION_TEXT with quotes thus breaking the GNU make Makefile +# for external modules. +# Workaround by providing a non-quoted value to override the value in .config +unset lb_cv_dequote_CC_VERSION_TEXT +AC_CACHE_CHECK([for compiler version text], lb_cv_dequote_CC_VERSION_TEXT, [ + AS_IF([test "x$lb_cv_module_target" = "xM517"], + [lb_cv_dequote_CC_VERSION_TEXT=yes], + [lb_cv_dequote_CC_VERSION_TEXT=yes]) ]) AS_IF([test -z "$lb_cv_module_target"], [AC_MSG_ERROR([unknown external module build target])], @@ -41,6 +58,9 @@ AS_IF([test -z "$lb_cv_module_target"], [test "x$lb_cv_module_target" = "xM58"], [makerule="" lb_cv_module_target="M"], +[test "x$lb_cv_module_target" = "xM517"], + [makerule="" + lb_cv_module_target="M"], [test "x$lb_cv_module_target" = "xM"], [makerule="_module_$PWD/build"]) MODULE_TARGET=$lb_cv_module_target @@ -373,9 +393,18 @@ Consult build/README.kernel-source for details. EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS" ]) +AS_IF([test -n SUBARCH], +[SUBARCH=$(echo $target_cpu | sed -e 's/powerpc.*/powerpc/' -e 's/ppc.*/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/' -e 's/k1om/x86/' -e 's/aarch64.*/arm64/' -e 's/armv7.*/arm/') +]) + # this is needed before we can build modules LB_LINUX_VERSION +# --- Parallel config for kernel v5.17+ +AS_IF([test "x$lb_cv_dequote_CC_VERSION_TEXT" = "xyes"], [ + CC_VERSION_TEXT=$(gcc --version | head -n1 | tr ' ()' '.') + MAKE_KMOD_ENV="CONFIG_CC_VERSION_TEXT='$CC_VERSION_TEXT'"]) + # --- check that we can build modules at all LB_CHECK_COMPILE([that modules can be built at all], build_modules, [], [], [], [ @@ -574,7 +603,7 @@ MODULE_LICENSE("GPL");]) AC_DEFUN([LB_LINUX_COMPILE_IFELSE], [m4_ifvaln([$1], [AC_LANG_CONFTEST([AC_LANG_SOURCE([$1])])])dnl rm -f build/conftest.o build/conftest.mod.c build/conftest.ko -AS_IF([AC_TRY_COMMAND(cp conftest.c build && make -d [$2] LDFLAGS= ${LD:+LD="$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_CHECK_INCLUDE -I$LINUX/arch/$SUBARCH/include -Iinclude -Iarch/$SUBARCH/include/generated -I$LINUX/include -Iinclude2 -I$LINUX/include/uapi -Iinclude/generated -I$LINUX/arch/$SUBARCH/include/uapi -Iarch/$SUBARCH/include/generated/uapi -I$LINUX/include/uapi -Iinclude/generated/uapi ${SPL_OBJ:+-include $SPL_OBJ/spl_config.h} ${ZFS_OBJ:+-include $ZFS_OBJ/zfs_config.h} ${SPL:+-I$SPL/include } ${ZFS:+-I$ZFS -I$ZFS/include -I$ZFS/include/os/linux/kernel -I$ZFS/include/os/linux/spl -I$ZFS/include/os/linux/zfs -I${SPL:-$ZFS/include/spl}} -include $CONFIG_INCLUDE" KBUILD_EXTRA_SYMBOLS="${ZFS_OBJ:+$ZFS_OBJ/Module.symvers} $KBUILD_EXTRA_SYMBOLS" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])], +AS_IF([AC_TRY_COMMAND(cp conftest.c build && make -d [$2] DEQUOTE_CC_VERSION_TEXT=$lb_cv_dequote_CC_VERSION_TEXT LDFLAGS= ${LD:+LD="$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_CHECK_INCLUDE -I$LINUX/arch/$SUBARCH/include -Iinclude -Iarch/$SUBARCH/include/generated -I$LINUX/include -Iinclude2 -I$LINUX/include/uapi -Iinclude/generated -I$LINUX/arch/$SUBARCH/include/uapi -Iarch/$SUBARCH/include/generated/uapi -I$LINUX/include/uapi -Iinclude/generated/uapi ${SPL_OBJ:+-include $SPL_OBJ/spl_config.h} ${ZFS_OBJ:+-include $ZFS_OBJ/zfs_config.h} ${SPL:+-I$SPL/include } ${ZFS:+-I$ZFS -I$ZFS/include -I$ZFS/include/os/linux/kernel -I$ZFS/include/os/linux/spl -I$ZFS/include/os/linux/zfs -I${SPL:-$ZFS/include/spl}} -include $CONFIG_INCLUDE" KBUILD_EXTRA_SYMBOLS="${ZFS_OBJ:+$ZFS_OBJ/Module.symvers} $KBUILD_EXTRA_SYMBOLS" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])], [$4], [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])dnl]) @@ -725,7 +754,7 @@ AC_DEFUN([LB2_LINUX_CONFTEST_MAKEFILE], [ cat - <<_EOF >$file # Example command line to manually build source -# make modules -C $LINUX_OBJ $ARCH_UM M=${TEST_DIR}/$1 +# make modules -C $LINUX_OBJ $ARCH_UM M=${TEST_DIR}/$1 $MAKE_KMOD_ENV ${LD:+LD="$LD"} CC=$CC @@ -793,10 +822,10 @@ AC_DEFUN([LB2_LINUX_TEST_COMPILE], [ J=${TEST_JOBS:-$(nproc)} AC_MSG_NOTICE([Making $1 in $D]) - AC_MSG_NOTICE([KBUILD_MODPOST_NOFINAL="yes" make modules -k -j${J} -C $LINUX_OBJ $ARCH_UM M=${D}]) + AC_MSG_NOTICE([KBUILD_MODPOST_NOFINAL="yes" make modules -k -j${J} -C $LINUX_OBJ $ARCH_UM M=${D} $MAKE_KMOD_ENV]) AC_TRY_COMMAND([KBUILD_MODPOST_NOFINAL="yes" - make modules -k -j${J} -C $LINUX_OBJ $ARCH_UM M=${D} >${L} 2>&1]) + make modules -k -j${J} -C $LINUX_OBJ $ARCH_UM M=${D} $MAKE_KMOD_ENV >${L} 2>&1]) AS_IF([test -f ${L}], [AS_IF([test -f $2/Makefile], [mv $2/Makefile $2/Makefile.compile.$1])], diff --git a/config/lustre-build.m4 b/config/lustre-build.m4 index afe606e..28eb3ec 100644 --- a/config/lustre-build.m4 +++ b/config/lustre-build.m4 @@ -452,6 +452,7 @@ AM_CONDITIONAL([RHEL], [test -f /etc/redhat-release]) AM_CONDITIONAL([SUSE], [test -f /etc/SUSE-brand -o -f /etc/SuSE-release]) AM_CONDITIONAL([UBUNTU], [test x$UBUNTU_KERNEL = xyes]) AM_CONDITIONAL([BUILD_LUTF], [test x$enable_lutf = xyes]) +AM_CONDITIONAL([DEQUOTE_CC_VERSION_TEXT], [test x$lb_cv_dequote_CC_VERSION_TEXT = xyes]) LN_CONDITIONALS LC_CONDITIONALS -- 1.8.3.1