File 0051-LU-16115-build-Linux-5.17-external-module-support.patch of Package lustre_2_12
From 945ab61176213e082dfd6b3a2a35aa4687e31129 Mon Sep 17 00:00:00 2001
From: Shaun Tancheff <shaun.tancheff@hpe.com>
Date: Mon, 3 Oct 2022 14:51:16 +0700
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.
Test-Parameters: trivial
HPE-bug-id: LUS-11190
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I997b6987ef37a8c5b9d8f0984e81d9402a2ea705
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48360
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
autoMakefile.am | 7 ++++++-
build/Makefile | 6 ++++++
config/lustre-build-linux.m4 | 33 +++++++++++++++++++++++++++++++--
config/lustre-build.m4 | 1 +
4 files changed, 44 insertions(+), 3 deletions(-)
--- 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 \
--- 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),)
--- a/config/lustre-build-linux.m4
+++ b/config/lustre-build-linux.m4
@@ -35,8 +35,25 @@ AC_CACHE_CHECK([for external module buil
[$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])],
@@ -46,6 +63,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
@@ -350,9 +370,18 @@ Consult build/README.kernel-source for d
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,
[], [], [], [
@@ -548,7 +577,7 @@ 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
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/')
-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${SPL:-$ZFS/include/spl}} -include $CONFIG_INCLUDE" -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${SPL:-$ZFS/include/spl}} -include $CONFIG_INCLUDE" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $MAKE_KMOD_ENV $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
[$4],
[_AC_MSG_LOG_CONFTEST
m4_ifvaln([$5],[$5])dnl])
--- a/config/lustre-build.m4
+++ b/config/lustre-build.m4
@@ -423,6 +423,7 @@ AM_CONDITIONAL([USE_QUILT], [test x$use_
AM_CONDITIONAL([RHEL], [test x$RHEL_KERNEL = xyes])
AM_CONDITIONAL([SUSE], [test x$SUSE_KERNEL = xyes])
AM_CONDITIONAL([UBUNTU], [test x$UBUNTU_KERNEL = xyes])
+AM_CONDITIONAL([DEQUOTE_CC_VERSION_TEXT], [test x$lb_cv_dequote_CC_VERSION_TEXT = xyes])
# Sanity check for PCLMULQDQ instruction availability
# PCLMULQDQ instruction is a new instruction available beginning with