From a4a302f6771ed9002a89273bdba92f9dcf6a9d81 Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Fri, 25 Sep 2020 16:52:55 +0800 Subject: [PATCH] Fix gcc10 -fno-common compile issue this change has given better compatible with both gcc8 and gcc10 toolchain, should be maintained util 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 --- dump.spec | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dump.spec b/dump.spec index 9b5cb54..36b0bb2 100644 --- a/dump.spec +++ b/dump.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 %define PREVER b46 %define DUMP_VERSION 0.4%{PREVER} @@ -5,7 +6,7 @@ Summary: Programs for backing up and restoring ext2/ext3/ext4 filesystems Name: dump Epoch: 1 Version: 0.4 -Release: 0.36.%{PREVER}%{?dist} +Release: 0.36.%{PREVER}%{anolis_release}%{?dist} License: BSD Group: Applications/Archiving URL: http://dump.sourceforge.net/ @@ -54,7 +55,7 @@ done autoreconf -fiv export CFLAGS="$RPM_OPT_FLAGS -Wall -Wpointer-arith -Wstrict-prototypes \ --Wmissing-prototypes -Wno-char-subscripts -fno-strict-aliasing" +-Wmissing-prototypes -Wno-char-subscripts -fno-strict-aliasing -fcommon" # XXX --enable-kerberos needs krcmd %configure --disable-static \ @@ -109,6 +110,9 @@ rm -rf %{buildroot} %{_mandir}/man8/rrestore.8* %changelog +* Tue Nov 23 2021 Weitao Zhou 0.4-0.36.b46.0.1 +- Fix FTBFS by enabling '-fcommon' for compatible with gcc10 build + * Wed Feb 07 2018 Fedora Release Engineering - 1:0.4-0.36.b46 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild -- Gitee