From 47ae78862ea5c9e9a97ffb16bd9e2c3d0bdfe47f Mon Sep 17 00:00:00 2001 From: Jacob Wang Date: Tue, 29 Sep 2020 17:22:00 +0800 Subject: [PATCH] use extern in header files when declaring global variables this change has given better compatible with both gcc8 and gcc10 toolchain, should be maintained util upstream fixes 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 this change has given better compatible with gcc10 toolchain, should be maintained util upstream fixes 'multiple definition ...' warnings Signed-off-by: weitao zhou --- ...rasdaemon-avoid-multiple-definitions.patch | 24 +++++++++++++++++++ rasdaemon.spec | 13 +++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 1001-rasdaemon-avoid-multiple-definitions.patch diff --git a/1001-rasdaemon-avoid-multiple-definitions.patch b/1001-rasdaemon-avoid-multiple-definitions.patch new file mode 100644 index 0000000..109587b --- /dev/null +++ b/1001-rasdaemon-avoid-multiple-definitions.patch @@ -0,0 +1,24 @@ +commit fd982af0a307edc5d3e56011d2e045015b1efd4b +Author: Mauro Carvalho Chehab +Date: Mon Mar 30 01:22:24 2020 +0200 + + ras-record.h: define an external var as such + + Otherwise, newer versions of gcc will produce multiple symbols, + causing link breakages. + + Signed-off-by: Mauro Carvalho Chehab + +diff --git a/ras-record.h b/ras-record.h +index 5311c67caf44..0d2a481c23dd 100644 +--- a/ras-record.h ++++ b/ras-record.h +@@ -25,7 +25,7 @@ + + extern long user_hz; + +-struct ras_events *ras; ++extern struct ras_events *ras; + + struct ras_mc_event { + char timestamp[64]; diff --git a/rasdaemon.spec b/rasdaemon.spec index 06b5a17..e8b462e 100755 --- a/rasdaemon.spec +++ b/rasdaemon.spec @@ -1,6 +1,7 @@ +%define anolis_release .0.1 Name: rasdaemon Version: 0.6.1 -Release: 6%{?dist} +Release: 6%{anolis_release}%{?dist} Summary: Utility to receive RAS error tracings Group: Applications/System License: GPLv2 @@ -32,6 +33,11 @@ Patch6: 8704a85d8dc3483423ec2934fee8132f85f8fdb6.patch Patch7: cc2ce5c65ed5a42eaa97aa3659854add6d808da5.patch Patch8: 854364ba44aee9bc5646f6537fc744b0b54aff37.patch +# Begin: Anolis customized patches +# Backport from fc32 to fix FTBFS on gcc10 +Patch1001: 1001-rasdaemon-avoid-multiple-definitions.patch +# End: Anolis customized patches + %description %{name} is a RAS (Reliability, Availability and Serviceability) logging tool. It currently records memory errors, using the EDAC tracing events. @@ -53,6 +59,8 @@ an utility for reporting current error counts from the EDAC sysfs files. %patch7 -p1 %patch8 -p1 +%patch1001 -p1 + %build %ifarch %{arm} aarch64 %configure --enable-mce --enable-aer --enable-sqlite3 --enable-extlog --enable-abrt-report --enable-non-standard --enable-hisi-ns-decode --enable-arm @@ -78,6 +86,9 @@ rm INSTALL %{buildroot}/usr/include/*.h %{_sysconfdir}/ras/dimm_labels.d %changelog +* Thu Jan 20 2022 Weitao Zhou - 0.6.1-6.0.1 +- use extern in header files when declaring global variables for compatible gcc10 build + * Wed May 26 2021 Aristeu Rozanski 0.6.1-6 - Add support for AMD SMCA [1965011] -- Gitee