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