From b8c0a69180a530a5df4d518bf27d211714dafb0c Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Mon, 28 Sep 2020 19:33:40 +0800 Subject: [PATCH] [build][gcc10] Fix gcc10 build issue 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: wb-zh951434 Signed-off-by: weitao zhou --- ...nused-global-variable-missing-extern.patch | 29 ++++++++++++++++++ ...tion-__comps_objmrtree_all-also-stat.patch | 30 +++++++++++++++++++ libcomps.spec | 12 +++++++- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 1001-remove-unused-global-variable-missing-extern.patch create mode 100644 1002-Make-inline-function-__comps_objmrtree_all-also-stat.patch diff --git a/1001-remove-unused-global-variable-missing-extern.patch b/1001-remove-unused-global-variable-missing-extern.patch new file mode 100644 index 0000000..ff808df --- /dev/null +++ b/1001-remove-unused-global-variable-missing-extern.patch @@ -0,0 +1,29 @@ +From 3237f44ba7e4712653b64b36cc58b74d2d56d14f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= +Date: Wed, 29 Jan 2020 09:08:34 +0100 +Subject: [PATCH] Remove unused global variable UnfoObjListIt (RhBug:1793424) + +This global header file variable wasn't declared using extern keyword +which was causing problems with gcc 10 (gcc 10 no longer ignores this +error). + +https://bugzilla.redhat.com/show_bug.cgi?id=1793424 +--- + libcomps/src/comps_objlist.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libcomps/src/comps_objlist.h b/libcomps/src/comps_objlist.h +index 0fcd48b..1d19167 100644 +--- a/libcomps/src/comps_objlist.h ++++ b/libcomps/src/comps_objlist.h +@@ -34,7 +34,7 @@ typedef struct COMPS_ObjListIt COMPS_ObjListIt; + struct COMPS_ObjListIt { + COMPS_Object *comps_obj; + COMPS_ObjListIt *next; +-} UnfoObjListIt; ++}; + + + /** COMPS_Object derivate representing category element in comps.xml structure*/ +-- +2.25.0 diff --git a/1002-Make-inline-function-__comps_objmrtree_all-also-stat.patch b/1002-Make-inline-function-__comps_objmrtree_all-also-stat.patch new file mode 100644 index 0000000..6f1b4da --- /dev/null +++ b/1002-Make-inline-function-__comps_objmrtree_all-also-stat.patch @@ -0,0 +1,30 @@ +From 18f52cb30d577d519190076ab14ff599a6e4a6c3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= +Date: Wed, 29 Jan 2020 09:27:27 +0100 +Subject: [PATCH] Make inline function __comps_objmrtree_all also static + (RhBug:1793424) + +The function isn't used anywhere else and doesn't have any other +external definition present in any other translation unit (which is +causing a compiler error). + +https://bugzilla.redhat.com/show_bug.cgi?id=1793424 +--- + libcomps/src/comps_objmradix.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libcomps/src/comps_objmradix.c b/libcomps/src/comps_objmradix.c +index 22ad262..509457a 100644 +--- a/libcomps/src/comps_objmradix.c ++++ b/libcomps/src/comps_objmradix.c +@@ -605,7 +605,7 @@ inline void comps_objmrtree_pair_destroy_v(void * pair) { + free(pair); + } + +-inline COMPS_HSList* __comps_objmrtree_all(COMPS_ObjMRTree * rt, char keyvalpair) { ++static inline COMPS_HSList* __comps_objmrtree_all(COMPS_ObjMRTree * rt, char keyvalpair) { + COMPS_HSList *to_process, *ret; + COMPS_HSListItem *hsit, *oldit; + size_t x; +-- +1.8.3.1 diff --git a/libcomps.spec b/libcomps.spec index 281f2c3..2dbc284 100644 --- a/libcomps.spec +++ b/libcomps.spec @@ -1,8 +1,9 @@ +%define anolis_release .0.1 %define __cmake_in_source_build 1 Name: libcomps Version: 0.1.16 -Release: 2%{?dist} +Release: 2%{anolis_release}%{?dist} Summary: Comps XML file manipulation library License: GPLv2+ @@ -10,6 +11,12 @@ URL: https://github.com/rpm-software-management/libcomps Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz Patch1: 0001-Dont-print-empty-requires.patch +# Begin: Anolis customized patches +# backport patch from upstream +Patch1001: 1001-remove-unused-global-variable-missing-extern.patch +Patch1002: 1002-Make-inline-function-__comps_objmrtree_all-also-stat.patch +# End: Anolis customized patches + BuildRequires: gcc-c++ BuildRequires: cmake BuildRequires: gcc @@ -115,6 +122,9 @@ popd %{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info %changelog +* Thu Jan 20 2022 Weitao Zhou - 0.1.16-2.0.1 +- Fix gcc10 build issue + * Fri May 21 2021 Pavla Kratochvilova - 0.1.16-2 - Backport patch: Don't print empty requires -- Gitee