From 6437e6a0280dbcbae4f9cf37958ee3d8778fb8ec Mon Sep 17 00:00:00 2001 From: songmingliang Date: Wed, 18 May 2022 14:19:50 +0800 Subject: [PATCH 1/2] [gcc10] use extern in header files when declaring global variables to --- 1001-nfs-utils-gcc10.patch | 68 ++++++++++++++++++++++++++++++++++++++ nfs-utils.spec | 10 +++++- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 1001-nfs-utils-gcc10.patch diff --git a/1001-nfs-utils-gcc10.patch b/1001-nfs-utils-gcc10.patch new file mode 100644 index 0000000..609b063 --- /dev/null +++ b/1001-nfs-utils-gcc10.patch @@ -0,0 +1,68 @@ +From 80a9ea81f54fb6bd2147fa247cb06515990deb19 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Tue, 26 Apr 2022 16:53:23 +0800 +Subject: [PATCH] Allow compilation to succeed with -fno-common +When compiled with -fno-common, global variables that are declared +multple times cause an error. With -fcommon (the default), they are +merged. + +Declaring such variable multiple times is probably not a good idea, and +is definitely not necessary. + +This patch changes all the global variables defined in include files to +be explicitly "extern", and where necessary, adds the variable +declaration to a suitable .c file. + +To test, run + CFLAGS=-fno-common ./configure + make +Signed-off-by: NeilBrown +Signed-off-by: Steve Dickson +--- + support/export/v4root.c | 2 -- + utils/statd/statd.c | 2 ++ + utils/statd/statd.h | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/support/export/v4root.c b/support/export/v4root.c +index 4d33117..3654bd7 100644 +--- a/support/export/v4root.c ++++ b/support/export/v4root.c +@@ -28,8 +28,6 @@ + #include "v4root.h" + #include "pseudoflavors.h" + +-int v4root_needed; +- + static nfs_export pseudo_root = { + .m_next = NULL, + .m_client = NULL, +diff --git a/utils/statd/statd.c b/utils/statd/statd.c +index 8eef2ff..665b0fe 100644 +--- a/utils/statd/statd.c ++++ b/utils/statd/statd.c +@@ -68,6 +68,8 @@ static struct option longopts[] = + + extern void sm_prog_1 (struct svc_req *, register SVCXPRT *); + ++stat_chge SM_stat_chge; ++ + #ifdef SIMULATIONS + extern void simulator (int, char **); + #endif +diff --git a/utils/statd/statd.h b/utils/statd/statd.h +index 231ac7e..bb1fecb 100644 +--- a/utils/statd/statd.h ++++ b/utils/statd/statd.h +@@ -41,7 +41,7 @@ extern void load_state(void); + /* + * Host status structure and macros. + */ +-stat_chge SM_stat_chge; ++extern stat_chge SM_stat_chge; + #define MY_NAME SM_stat_chge.mon_name + #define MY_STATE SM_stat_chge.state + +-- +2.18.4 + diff --git a/nfs-utils.spec b/nfs-utils.spec index 0a9e740..abba3f1 100644 --- a/nfs-utils.spec +++ b/nfs-utils.spec @@ -1,8 +1,9 @@ +%define anolis_release .0.1 Summary: NFS utilities and supporting clients and daemons for the kernel NFS server Name: nfs-utils URL: http://linux-nfs.org/ Version: 2.3.3 -Release: 51%{?dist} +Release: 51%{anolis_release}%{?dist} Epoch: 1 # group all 32bit related archs @@ -98,6 +99,10 @@ Patch102: nfs-utils-2.3.3-idmap-errmsg.patch Patch103: nfs-utils-2.3.1-systemd-gssproxy-restart.patch Patch104: nfs-utils-2.3.1-systemd-svcgssd-removed.patch +# Begin: Anolis customized patches +Patch1001: 1001-nfs-utils-gcc10.patch +# End: Anolis customized patches + Provides: exportfs = %{epoch}:%{version}-%{release} Provides: nfsstat = %{epoch}:%{version}-%{release} Provides: showmount = %{epoch}:%{version}-%{release} @@ -366,6 +371,9 @@ fi %{_libdir}/libnfsidmap.so %changelog +* Wed May 18 2022 Weitao Zhou 2.3.3-51.0.1 +- use extern in header files when declaring global variables for compatible gcc10 build + * Mon Mar 7 2022 Steve Dickson 2.3.3-51 - libnfsidmap: Turn off default verbosity (bz 2057612) -- Gitee From 432efa559de2881ae858a3fe1488ed2bb5d9154b Mon Sep 17 00:00:00 2001 From: songmingliang Date: Wed, 18 May 2022 14:24:40 +0800 Subject: [PATCH 2/2] Allow compilation to succeed with -fno-common --- ...mpilation-to-succeed-with-fno-common.patch | 66 +++++++++++++++++++ nfs-utils.spec | 3 + 2 files changed, 69 insertions(+) create mode 100644 1002-Allow-compilation-to-succeed-with-fno-common.patch diff --git a/1002-Allow-compilation-to-succeed-with-fno-common.patch b/1002-Allow-compilation-to-succeed-with-fno-common.patch new file mode 100644 index 0000000..a9c7dc9 --- /dev/null +++ b/1002-Allow-compilation-to-succeed-with-fno-common.patch @@ -0,0 +1,66 @@ +From 050d33d0c81fe82d004fe75b25415232e110756e Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Tue, 26 Apr 2022 17:02:57 +0800 +Subject: [PATCH] Allow compilation to succeed with -fno-common +When compiled with -fno-common, global variables that are declared +multple times cause an error. With -fcommon (the default), they are +merged. + +Declaring such variable multiple times is probably not a good idea, and +is definitely not necessary. + +This patch changes all the global variables defined in include files to +be explicitly "extern", and where necessary, adds the variable +declaration to a suitable .c file. + +To test, run + CFLAGS=-fno-common ./configure + make + +Signed-off-by: NeilBrown +Signed-off-by: Steve Dickson +--- + utils/nfsdcld/cld-internal.h | 11 +++++------ + utils/nfsdcld/nfsdcld.c | 6 ++++++ + 2 files changed, 11 insertions(+), 6 deletions(-) + +diff --git a/utils/nfsdcld/cld-internal.h b/utils/nfsdcld/cld-internal.h +index 05f01be..e8216c9 100644 +--- a/utils/nfsdcld/cld-internal.h ++++ b/utils/nfsdcld/cld-internal.h +@@ -35,10 +35,9 @@ struct cld_client { + } cl_u; + }; + +-uint64_t current_epoch; +-uint64_t recovery_epoch; +-int first_time; +-int num_cltrack_records; +-int num_legacy_records; +- ++extern uint64_t current_epoch; ++extern uint64_t recovery_epoch; ++extern int first_time; ++extern int num_cltrack_records; ++extern int num_legacy_records; + #endif /* _CLD_INTERNAL_H_ */ +diff --git a/utils/nfsdcld/nfsdcld.c b/utils/nfsdcld/nfsdcld.c +index 2ad1001..be65562 100644 +--- a/utils/nfsdcld/nfsdcld.c ++++ b/utils/nfsdcld/nfsdcld.c +@@ -69,6 +69,12 @@ static int inotify_fd = -1; + static struct event pipedir_event; + static bool old_kernel = false; + ++uint64_t current_epoch; ++uint64_t recovery_epoch; ++int first_time; ++int num_cltrack_records; ++int num_legacy_records; ++ + static struct option longopts[] = + { + { "help", 0, NULL, 'h' }, +-- +2.18.4 + diff --git a/nfs-utils.spec b/nfs-utils.spec index abba3f1..4ee67c6 100644 --- a/nfs-utils.spec +++ b/nfs-utils.spec @@ -101,6 +101,8 @@ Patch104: nfs-utils-2.3.1-systemd-svcgssd-removed.patch # Begin: Anolis customized patches Patch1001: 1001-nfs-utils-gcc10.patch +# backport patch from upstream +Patch1002: 1002-Allow-compilation-to-succeed-with-fno-common.patch # End: Anolis customized patches Provides: exportfs = %{epoch}:%{version}-%{release} @@ -373,6 +375,7 @@ fi %changelog * Wed May 18 2022 Weitao Zhou 2.3.3-51.0.1 - use extern in header files when declaring global variables for compatible gcc10 build +- allow compilation to succeed with -fno-common * Mon Mar 7 2022 Steve Dickson 2.3.3-51 - libnfsidmap: Turn off default verbosity (bz 2057612) -- Gitee