[Buildroot] [git commit branch/2020.02.x] package/gnupg: fix build with gcc 10

Peter Korsgaard peter at korsgaard.com
Mon Jun 1 20:17:47 UTC 2020


commit: https://git.buildroot.net/buildroot/commit/?id=a19732f1b86a5342f701406cbeaf8b77754e2359
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2020.02.x

This commit backports an upstream patch made for gnupg2 into gnupg, in
order to fix build failures with gcc 10 due to the use of
-fno-common. Due to the code differences between upstream gnupg2 and
the old gnupg 1.x, the backport is in fact more a rewrite than an
actual backport.

Fixes:

  http://autobuild.buildroot.net/results/496a18833505dc589f7ae58f2c7e5fe80fe9af79/

Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
(cherry picked from commit 75e82c42c6a4612c7385a32dcb82ca9cb5d866bd)
Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
---
 ...ays-use-EXTERN_UNLESS_MAIN_MODULE-pattern.patch | 156 +++++++++++++++++++++
 1 file changed, 156 insertions(+)

diff --git a/package/gnupg/0001-build-Always-use-EXTERN_UNLESS_MAIN_MODULE-pattern.patch b/package/gnupg/0001-build-Always-use-EXTERN_UNLESS_MAIN_MODULE-pattern.patch
new file mode 100644
index 0000000000..9f0ba1b01e
--- /dev/null
+++ b/package/gnupg/0001-build-Always-use-EXTERN_UNLESS_MAIN_MODULE-pattern.patch
@@ -0,0 +1,156 @@
+From 45ef4455a60929932d1499cf718c1c9f59af9f26 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
+Date: Tue, 26 May 2020 22:57:05 +0200
+Subject: [PATCH] build: Always use EXTERN_UNLESS_MAIN_MODULE pattern
+
+This patch is loosely based on upstream commit
+6aff8a132815a84bab69401c1e7de96ec549fbf2 ("build: Always use
+EXTERN_UNLESS_MAIN_MODULE pattern."). However, this upstream commit
+applies to gnupg2, and the code base has changed quite significantly
+compared to gnupg 1.x, so upstream's patch cannot be applied
+as-is. The goal of the patch is to make sure each variable is only
+defined once, ass gcc 10 now default to -fno-common.
+
+Essentially, this patch mainly fixes the EXTERN_UNLESS_MAIN_MODULE
+define so that it really expands to "extern" when
+INCLUDED_BY_MAIN_MODULE is not defined, even on non-RiscOS
+systems. Contrary to upstream's patch we however do not factorize the
+multiple EXTERN_UNLESS_MAIN_MODULE definitions into a single place as
+it requires too many changes: instead we simply fix the few
+definitions of this macro.
+
+Once the macro is fixed, two places need to define
+INCLUDED_BY_MAIN_MODULE: tools/bftest.c and tools/mpicalc.c so that
+when they include the common headers, their variables are at least
+defined once.
+
+The iobuf.{c,h} case is handled differently: iobuf.h gains an
+unconditional "extern", with the variable being added to iobuf.c. This
+is identical to what upstream's
+6aff8a132815a84bab69401c1e7de96ec549fbf2 is doing.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
+---
+ g10/options.h    | 3 +--
+ include/cipher.h | 2 +-
+ include/iobuf.h  | 9 +--------
+ include/memory.h | 2 +-
+ include/mpi.h    | 2 +-
+ tools/bftest.c   | 1 +
+ tools/mpicalc.c  | 1 +
+ util/iobuf.c     | 2 ++
+ 8 files changed, 9 insertions(+), 13 deletions(-)
+
+diff --git a/g10/options.h b/g10/options.h
+index 0ac6e7755..bae19e9e3 100644
+--- a/g10/options.h
++++ b/g10/options.h
+@@ -26,8 +26,7 @@
+ #include "packet.h"
+ 
+ #ifndef EXTERN_UNLESS_MAIN_MODULE
+-/* Norcraft can't cope with common symbols */
+-#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
++#if !defined (INCLUDED_BY_MAIN_MODULE)
+ #define EXTERN_UNLESS_MAIN_MODULE extern
+ #else
+ #define EXTERN_UNLESS_MAIN_MODULE
+diff --git a/include/cipher.h b/include/cipher.h
+index dd4af18cb..6ef6e6829 100644
+--- a/include/cipher.h
++++ b/include/cipher.h
+@@ -115,7 +115,7 @@ struct gcry_md_context {
+ typedef struct gcry_md_context *MD_HANDLE;
+ 
+ #ifndef EXTERN_UNLESS_MAIN_MODULE
+-#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
++#if !defined (INCLUDED_BY_MAIN_MODULE)
+ #define EXTERN_UNLESS_MAIN_MODULE extern
+ #else
+ #define EXTERN_UNLESS_MAIN_MODULE
+diff --git a/include/iobuf.h b/include/iobuf.h
+index 030f8c8e9..b4d26b7e1 100644
+--- a/include/iobuf.h
++++ b/include/iobuf.h
+@@ -69,14 +69,7 @@ struct iobuf_struct {
+     } unget;
+ };
+ 
+-#ifndef EXTERN_UNLESS_MAIN_MODULE
+-#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
+-#define EXTERN_UNLESS_MAIN_MODULE extern
+-#else
+-#define EXTERN_UNLESS_MAIN_MODULE 
+-#endif
+-#endif
+-EXTERN_UNLESS_MAIN_MODULE int iobuf_debug_mode;
++extern int iobuf_debug_mode;
+ 
+ void  iobuf_enable_special_filenames ( int yes );
+ int   iobuf_is_pipe_filename (const char *fname);
+diff --git a/include/memory.h b/include/memory.h
+index d414a9b2e..6698337e3 100644
+--- a/include/memory.h
++++ b/include/memory.h
+@@ -91,7 +91,7 @@ unsigned secmem_get_flags(void);
+ #define DBG_MEMSTAT   memory_stat_debug_mode
+ 
+ #ifndef EXTERN_UNLESS_MAIN_MODULE
+-#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
++#if !defined (INCLUDED_BY_MAIN_MODULE)
+ #define EXTERN_UNLESS_MAIN_MODULE extern
+ #else
+ #define EXTERN_UNLESS_MAIN_MODULE 
+diff --git a/include/mpi.h b/include/mpi.h
+index a4c16f5af..7a45ff805 100644
+--- a/include/mpi.h
++++ b/include/mpi.h
+@@ -36,7 +36,7 @@
+ #include "memory.h"
+ 
+ #ifndef EXTERN_UNLESS_MAIN_MODULE
+-#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
++#if !defined (INCLUDED_BY_MAIN_MODULE)
+ #define EXTERN_UNLESS_MAIN_MODULE extern
+ #else
+ #define EXTERN_UNLESS_MAIN_MODULE 
+diff --git a/tools/bftest.c b/tools/bftest.c
+index 8a1572c2b..5afd7e125 100644
+--- a/tools/bftest.c
++++ b/tools/bftest.c
+@@ -26,6 +26,7 @@
+ #include <fcntl.h>
+ #endif
+ 
++#define INCLUDED_BY_MAIN_MODULE
+ #include "util.h"
+ #include "cipher.h"
+ #include "i18n.h"
+diff --git a/tools/mpicalc.c b/tools/mpicalc.c
+index 46e5fc824..31acd82a4 100644
+--- a/tools/mpicalc.c
++++ b/tools/mpicalc.c
+@@ -31,6 +31,7 @@
+ #include <stdlib.h>
+ #include <ctype.h>
+ 
++#define INCLUDED_BY_MAIN_MODULE
+ #include "util.h"
+ #include "mpi.h"
+ #include "i18n.h"
+diff --git a/util/iobuf.c b/util/iobuf.c
+index c8442929a..0d9ee4cec 100644
+--- a/util/iobuf.c
++++ b/util/iobuf.c
+@@ -113,6 +113,8 @@ typedef struct {
+  static CLOSE_CACHE close_cache;
+ #endif
+ 
++int iobuf_debug_mode;
++
+ #ifdef _WIN32
+ typedef struct {
+     int sock;
+-- 
+2.26.2
+


More information about the buildroot mailing list