From cce41f838cba984add9027893de815621aa701db Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Sun, 27 Sep 2020 20:11:19 +0800 Subject: [PATCH] Fix gcc10 -fno-common compile issue until upstream fixes this change has given better compatible with gcc10 toolchain, should be maintained util upstream fixes 'multiple definition ...' warnings Default to -fno-common A common mistake in C is omitting extern when declaring a global variable in a header file. If the header is included by several files it results in multiple definitions of the same variable. In previous GCC versions this error is ignored. GCC 10 defaults to -fno-common, which means a linker error will now be reported. To fix this, use extern in header files when declaring global variables, and ensure each global is defined in exactly one C file. If tentative definitions of particular variables need to be placed in a common block, __attribute__((__common__)) can be used to force that behavior even in code compiled without -fcommon. As a workaround, legacy C code where all tentative definitions should be placed into a common block can be compiled with -fcommon. int x; // tentative definition - avoid in header files extern int y; // correct declaration in a header file refer url: https://gcc.gnu.org/gcc-10/porting_to.html Signed-off-by: Liwei Ge Signed-off-by: weitao zhou --- ...fns-of-cli_default_conn_timeout-and-.patch | 101 ++++++++++++++++++ glusterfs.spec | 13 ++- 2 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 1001-cli-duplicate-defns-of-cli_default_conn_timeout-and-.patch diff --git a/1001-cli-duplicate-defns-of-cli_default_conn_timeout-and-.patch b/1001-cli-duplicate-defns-of-cli_default_conn_timeout-and-.patch new file mode 100644 index 0000000..47c63d8 --- /dev/null +++ b/1001-cli-duplicate-defns-of-cli_default_conn_timeout-and-.patch @@ -0,0 +1,101 @@ +From 5ccd50176b4e45abf528ef6870c332ef5f05448e Mon Sep 17 00:00:00 2001 +From: "Kaleb S. KEITHLEY" +Date: Thu, 2 Jan 2020 07:46:23 -0500 +Subject: [PATCH] cli: duplicate defns of cli_default_conn_timeout and + cli_ten_minutes_timeout + +Winter is coming. So is gcc-10. + +Compiling with gcc-10-20191219 snapshot reveals dupe defns of +cli_default_conn_timeout and cli_ten_minutes_timeout in +.../cli/src/cli.[ch] due to missing extern decl. + +There are many changes coming in gcc-10 described in +https://gcc.gnu.org/gcc-10/changes.html + +compiling cli.c with gcc-9 we see: + ... + .quad .LC88 + .comm cli_ten_minutes_timeout,4,4 + .comm cli_default_conn_timeout,4,4 + .text + .Letext0: + ... + +and with gcc-10: + ... + .quad .LC88 + .globl cli_ten_minutes_timeout + .bss + .align 4 + .type cli_ten_minutes_timeout, @object + .size cli_ten_minutes_timeout, 4 + cli_ten_minutes_timeout: + .zero 4 + .globl cli_default_conn_timeout + .align 4 + .type cli_default_conn_timeout, @object + .size cli_default_conn_timeout, 4 + cli_default_conn_timeout: + .zero 4 + .text + .Letext0: + ... + +which is reflected in the .o file as (gcc-9): +... +0000000000000004 C cli_ten_minutes_timeout +0000000000000004 C cli_default_conn_timeout +... + +and (gcc-10): +... +0000000000000020 B cli_ten_minutes_timeout +0000000000000024 B cli_default_conn_timeout +... + +See nm(1) and ld(1) for a description C (common) and B (BSS) and how +they are treated by the linker. + +Note: gcc-10 will land in Fedora-32! + +Change-Id: I54ea485736a4910254eeb21222ad263721cdef3c +Fixes: bz#1793492 +Signed-off-by: Kaleb S. KEITHLEY +--- + cli/src/cli.c | 3 +++ + cli/src/cli.h | 4 ++-- + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/cli/src/cli.c b/cli/src/cli.c +index fac32d3e9..6ac9c7901 100644 +--- a/cli/src/cli.c ++++ b/cli/src/cli.c +@@ -84,6 +84,9 @@ rpc_clnt_prog_t *cli_rpc_prog; + + extern struct rpc_clnt_program cli_prog; + ++int cli_default_conn_timeout = 120; ++int cli_ten_minutes_timeout = 600; ++ + static int + glusterfs_ctx_defaults_init(glusterfs_ctx_t *ctx) + { +diff --git a/cli/src/cli.h b/cli/src/cli.h +index 7166991a7..09d824ed0 100644 +--- a/cli/src/cli.h ++++ b/cli/src/cli.h +@@ -39,8 +39,8 @@ enum argp_option_keys { + ARGP_PORT_KEY = 'p', + }; + +-int cli_default_conn_timeout; +-int cli_ten_minutes_timeout; ++extern int cli_default_conn_timeout; ++extern int cli_ten_minutes_timeout; + + typedef enum { + COLD_BRICK_COUNT, +-- +2.24.1 + diff --git a/glusterfs.spec b/glusterfs.spec index c0e2ed4..3f20f7f 100644 --- a/glusterfs.spec +++ b/glusterfs.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 %global _hardened_build 1 %global _for_fedora_koji_builds 0 @@ -233,11 +234,11 @@ Summary: Distributed File System %if ( 0%{_for_fedora_koji_builds} ) Name: glusterfs Version: 3.8.0 -Release: 0.1%{?prereltag:.%{prereltag}}%{?dist} +Release: 0.1%{?prereltag:.%{prereltag}}%{anolis_release}%{?dist} %else Name: glusterfs Version: 6.0 -Release: 56.4%{?dist} +Release: 56.4%{anolis_release}%{?dist} ExcludeArch: i686 %endif License: GPLv2 or LGPLv3+ @@ -860,6 +861,11 @@ Patch0542: 0542-xlaotrs-mgmt-Fixing-coverity-issue-1445996.patch Patch0543: 0543-glusterd-handle-custom-xlator-failure-cases.patch Patch0544: 0544-RHGS-3.5.4-rebuild-to-ship-with-RHEL-8.5.patch +# Begin: Anolis customized patches +# port patch from fc33 +Patch1001: 1001-cli-duplicate-defns-of-cli_default_conn_timeout-and-.patch +# End: Anolis customized patches + %description GlusterFS is a distributed file-system capable of scaling to several petabytes. It aggregates various storage bricks over Infiniband RDMA @@ -2601,6 +2607,9 @@ fi %endif %changelog +* Thu Jan 20 2022 Weitao Zhou 6.0-56.4.0.1 +- Fix gcc10 -fno-common compile issue for compatible with gcc10 build + * Mon Aug 30 2021 Gluster Jenkins - 6.0-56.4 - Add gating.yaml, fixes bugs bz#1996984 -- Gitee