From 521d31471f4c99fca541087a0e37d0862c41ba17 Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Wed, 28 Oct 2020 15:11:49 +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 --- 1001-xfsprogs-gcc10.patch | 129 ++++++++++++++++++++++++++++++++++++++ xfsprogs.spec | 12 +++- 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 1001-xfsprogs-gcc10.patch diff --git a/1001-xfsprogs-gcc10.patch b/1001-xfsprogs-gcc10.patch new file mode 100644 index 0000000..cdf20f0 --- /dev/null +++ b/1001-xfsprogs-gcc10.patch @@ -0,0 +1,129 @@ +From 123b851389ef9a012a469ef982ac7b819db59342 Mon Sep 17 00:00:00 2001 +From: Eric Sandeen +Date: Thu, 30 Jan 2020 13:34:17 -0500 +Subject: xfsprogs: do not redeclare globals provided by libraries + +In each of these cases, db, logprint, and mdrestore are redeclaring +as a global variable something which was already provided by a +library they link with. + +gcc now defaults to -fno-common and trips over these global variables +which are declared in utilities as well as in libxfs and libxlog, and +it causes the build to fail. + +Signed-off-by: Eric Sandeen +Reviewed-by: Darrick J. Wong +Reviewed-by: Christoph Hellwig +Signed-off-by: Eric Sandeen +--- + mdrestore/xfs_mdrestore.c | 1 - + 1 file changed, 1 deletion(-) + +(limited to 'mdrestore/xfs_mdrestore.c') + +diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c +index 3375e0806..1cd399dbc 100644 +--- a/mdrestore/xfs_mdrestore.c ++++ b/mdrestore/xfs_mdrestore.c +@@ -7,7 +7,6 @@ + #include "libxfs.h" + #include "xfs_metadump.h" + +-char *progname; + static int show_progress = 0; + static int show_info = 0; + static int progress_since_warning = 0; +-- +cgit 1.2.3-1.el7 +From 123b851389ef9a012a469ef982ac7b819db59342 Mon Sep 17 00:00:00 2001 +From: Eric Sandeen +Date: Thu, 30 Jan 2020 13:34:17 -0500 +Subject: xfsprogs: do not redeclare globals provided by libraries + +In each of these cases, db, logprint, and mdrestore are redeclaring +as a global variable something which was already provided by a +library they link with. + +gcc now defaults to -fno-common and trips over these global variables +which are declared in utilities as well as in libxfs and libxlog, and +it causes the build to fail. + +Signed-off-by: Eric Sandeen +Reviewed-by: Darrick J. Wong +Reviewed-by: Christoph Hellwig +Signed-off-by: Eric Sandeen +--- + logprint/logprint.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +(limited to 'logprint/logprint.c') + +diff --git a/logprint/logprint.c b/logprint/logprint.c +index 7754a2a6e..511a32aca 100644 +--- a/logprint/logprint.c ++++ b/logprint/logprint.c +@@ -24,7 +24,6 @@ int print_buffer; + int print_overwrite; + int print_no_data; + int print_no_print; +-int print_exit = 1; /* -e is now default. specify -c to override */ + static int print_operation = OP_PRINT; + + static void +@@ -132,6 +131,7 @@ main(int argc, char **argv) + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + memset(&mount, 0, sizeof(mount)); ++ print_exit = 1; /* -e is now default. specify -c to override */ + + progname = basename(argv[0]); + while ((c = getopt(argc, argv, "bC:cdefl:iqnors:tDVv")) != EOF) { +@@ -152,7 +152,7 @@ main(int argc, char **argv) + case 'e': + /* -e is now default + */ +- print_exit++; ++ print_exit = 1; + break; + case 'C': + print_operation = OP_COPY; +-- +cgit 1.2.3-1.el7 +From 123b851389ef9a012a469ef982ac7b819db59342 Mon Sep 17 00:00:00 2001 +From: Eric Sandeen +Date: Thu, 30 Jan 2020 13:34:17 -0500 +Subject: xfsprogs: do not redeclare globals provided by libraries + +In each of these cases, db, logprint, and mdrestore are redeclaring +as a global variable something which was already provided by a +library they link with. + +gcc now defaults to -fno-common and trips over these global variables +which are declared in utilities as well as in libxfs and libxlog, and +it causes the build to fail. + +Signed-off-by: Eric Sandeen +Reviewed-by: Darrick J. Wong +Reviewed-by: Christoph Hellwig +Signed-off-by: Eric Sandeen +--- + db/init.c | 1 - + 1 file changed, 1 deletion(-) + +(limited to 'db/init.c') + +diff --git a/db/init.c b/db/init.c +index 455220a86..0ac373685 100644 +--- a/db/init.c ++++ b/db/init.c +@@ -27,7 +27,6 @@ static int force; + static struct xfs_mount xmount; + struct xfs_mount *mp; + static struct xlog xlog; +-libxfs_init_t x; + xfs_agnumber_t cur_agno = NULLAGNUMBER; + + static void +-- +cgit 1.2.3-1.el7 + diff --git a/xfsprogs.spec b/xfsprogs.spec index 47d05ff..b220a81 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -1,7 +1,8 @@ +%define anolis_release .0.1 Summary: Utilities for managing the XFS filesystem Name: xfsprogs Version: 5.0.0 -Release: 9%{?dist} +Release: 9%{anolis_release}%{?dist} License: GPL+ and LGPLv2+ Group: System Environment/Base URL: https://xfs.wiki.kernel.org @@ -41,6 +42,11 @@ Patch20: xfsprogs-5.8.0-xfs_quota-command-error-message-improvement.patch Patch21: xfsprogs-5.8.0-xfs_quota-display-warning-limits-when-printing-quota.patch Patch22: xfsprogs-5.8.0-xfs_quota-state-command-should-report-ugp-grace-time.patch +# Begin: Anolis customized patches +# backport patch from upstream +Patch1001: 1001-xfsprogs-gcc10.patch +# End: Anolis customized patches + %description A set of commands to use the XFS filesystem, including mkfs.xfs. @@ -93,6 +99,7 @@ also want to install xfsprogs. %patch20 -p1 %patch21 -p1 %patch22 -p1 +%patch1001 -p1 %build export tagname=CC @@ -152,6 +159,9 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* %{_libdir}/*.so %changelog +* Thu Jan 20 2022 Weitao Zhou - 5.0.0-9.0.1 +- Fix gcc10 -fno-common compile issue for compatible with gcc10 build + * Thu Jul 08 2021 Bill O'Donnell 5.0.0-9 - xfs_quota: state command should report ugp grace time (#1949743) -- Gitee