!11 fix build error with gcc 10

From: @wang_yue111
Reviewed-by: @yangzhao_kl
Signed-off-by: @yangzhao_kl
This commit is contained in:
openeuler-ci-bot 2021-08-09 03:11:16 +00:00 committed by Gitee
commit 4142e0b878
3 changed files with 107 additions and 1 deletions

View File

@ -0,0 +1,34 @@
From 77a79358cc72174cbba0dd44e313f6d06d96dbf4 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Thu, 2 Jan 2020 09:51:52 -0600
Subject: [PATCH] Refactor: attrd: properly declare global variables as extern in header
Restores buildability with GCC 10
---
daemons/attrd/pacemaker-attrd.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/daemons/attrd/pacemaker-attrd.h b/daemons/attrd/pacemaker-attrd.h
index cc8e29ee1e..7b5ba03388 100644
--- a/daemons/attrd/pacemaker-attrd.h
+++ b/daemons/attrd/pacemaker-attrd.h
@@ -1,5 +1,7 @@
/*
- * Copyright 2013-2018 Andrew Beekhof <andrew@beekhof.net>
+ * Copyright 2013-2020 the Pacemaker project contributors
+ *
+ * The version control history for this file may have further details.
*
* This source code is licensed under the GNU General Public License version 2
* or later (GPLv2+) WITHOUT ANY WARRANTY.
@@ -106,8 +108,8 @@ typedef struct attribute_value_s {
gboolean seen;
} attribute_value_t;
-crm_cluster_t *attrd_cluster;
-GHashTable *attributes;
+extern crm_cluster_t *attrd_cluster;
+extern GHashTable *attributes;
#define attrd_send_ack(client, id, flags) \
crm_ipcs_send_ack((client), (id), (flags), "ack", __FUNCTION__, __LINE__)

View File

@ -0,0 +1,65 @@
From 2f2bd2f0236a311feb162d5e2a320b9b8d8ceb5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Tue, 21 Jan 2020 18:24:44 +0100
Subject: [PATCH] Build: get ready for implicit -fno-common with upcoming GCC
10
Currently, -fno-common yields (and only yields, slightly restructured):
> /usr/bin/ld:
> pacemaker_execd-execd_commands.o:
> pcmk/daemons/execd/pacemaker-execd.h:23:
> multiple definition of `rsc_list';
> + pacemaker_execd-pacemaker-execd.o:
> pcmk/daemons/execd/pacemaker-execd.h:23:
> first defined here
>
> pacemaker_execd-execd_alerts.o:
> pcmk/daemons/execd/pacemaker-execd.h:23:
> multiple definition of `rsc_list';
> + pacemaker_execd-pacemaker-execd.o:
> pcmk/daemons/execd/pacemaker-execd.h:23:
> first defined here
>
> collect2: error: ld returned 1 exit status
The problem is that a global (with external linkage) variable without
explicit "extern" stands for "tentative definition" (as opposed to mere
reference to existing object with external linkage otherwise),
and these won't get automagically merged in -fno-common case (which
is going to be a default in upcoming GCC 10).
Solution is to explicitly add "extern" storage-class specifiers
at what's indeed meant as non-tentative reference in the header
files that are going to be included from various translation
units that will end up in the same link.
No more attempts at finding these was performed, just the only instance
that got hit in practice (see above) receives this treatment, since
manual work simply doesn't scale. Either a static analysis can be
employed to mark other potential show-stoppers, or we'll just deal
with the issues on case-by-case basis (with the gargantuan assistence
of CI systems).
References:
https://gcc.gnu.org/gcc-10/porting_to.html#common
---
daemons/execd/pacemaker-execd.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemons/execd/pacemaker-execd.h b/daemons/execd/pacemaker-execd.h
index 4a52d91..dab3ccd 100644
--- a/daemons/execd/pacemaker-execd.h
+++ b/daemons/execd/pacemaker-execd.h
@@ -20,7 +20,7 @@
# include <gnutls/gnutls.h>
# endif
-GHashTable *rsc_list;
+extern GHashTable *rsc_list;
typedef struct lrmd_rsc_s {
char *rsc_id;
--
2.23.0

View File

@ -14,7 +14,7 @@
## can be incremented to build packages reliably considered "newer" ## can be incremented to build packages reliably considered "newer"
## than previously built packages with the same pcmkversion) ## than previously built packages with the same pcmkversion)
%global pcmkversion 2.0.3 %global pcmkversion 2.0.3
%global specversion 2 %global specversion 3
## Upstream commit (or git tag, such as "Pacemaker-" plus the ## Upstream commit (or git tag, such as "Pacemaker-" plus the
## {pcmkversion} macro for an official release) to use for this package ## {pcmkversion} macro for an official release) to use for this package
@ -131,6 +131,8 @@ Source1: https://github.com/%{github_owner}/%{nagios_name}/archive/%{nagio
# --- # ---
Patch0: Build-fix-unability-to-build-with-Inkscape-1.0-beta-.patch Patch0: Build-fix-unability-to-build-with-Inkscape-1.0-beta-.patch
Patch1: Resolve-the-failure-of-time-matching-in-test-cases.patch Patch1: Resolve-the-failure-of-time-matching-in-test-cases.patch
Patch2: fix-multiple-definition-of-attributes-error.patch
Patch3: fix-multiple-definition-of-rsc_list-error.patch
Requires: resource-agents Requires: resource-agents
Requires: %{name}-libs%{?_isa} = %{version}-%{release} Requires: %{name}-libs%{?_isa} = %{version}-%{release}
@ -339,6 +341,8 @@ monitor resources.
%__scm_setup_git %__scm_setup_git
%patch0 -p1 %patch0 -p1
%patch1 -p1 %patch1 -p1
%patch2 -p1
%patch3 -p1
%build %build
@ -701,6 +705,9 @@ exit 0
%license %{nagios_name}-%{nagios_hash}/COPYING %license %{nagios_name}-%{nagios_hash}/COPYING
%changelog %changelog
* Sat Aug 07 2021 wangyue <wangyue92@huawei.com> - 2.0.3-3
- fix build error with gcc 10
* Tue Mar 23 2021 jiangxinyu <jiangxinyu@kylinos.cn> - 2.0.3-2 * Tue Mar 23 2021 jiangxinyu <jiangxinyu@kylinos.cn> - 2.0.3-2
- Add 'Resolve-the-failure-of-time-matching-in-test-cases.patch' file 2.0.3-2 - Add 'Resolve-the-failure-of-time-matching-in-test-cases.patch' file 2.0.3-2