Skip to contentSkip to conversation

gnupg: Make it build with GCC 10 (which uses -fno-common by default)

PATCH In review Peter Kjellerstedt 3 participants 7 messages Aug 31, 2020 – Oct 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gnupg: Make it build with GCC 10 (which uses -fno-common by default)

---
 ...th-GCC-10-which-uses-fno-common-by-d.patch | 93 +++++++++++++++++++
 recipes-support/gnupg/gnupg_1.4.7.bb          |  3 +-
 2 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 recipes-support/gnupg/gnupg-1.4.7/0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch
recipes-support/gnupg/gnupg-1.4.7/0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch new file +93 -0
new file mode 100644
index 0000000..2f84155
@@ -0,0 +1,93 @@
+From 1d0141d77d4f81cfa3213370fb7eeddbf53fc085 Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <[email protected]>
+Date: Tue, 1 Sep 2020 00:29:22 +0200
+Subject: [PATCH] Make it build with GCC 10 (which uses -fno-common by default)
+
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ g10/options.h    | 3 +--
+ include/cipher.h | 2 +-
+ include/iobuf.h  | 2 +-
+ include/memory.h | 2 +-
+ include/mpi.h    | 2 +-
+ tools/mpicalc.c  | 1 +
+ 6 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/g10/options.h b/g10/options.h
+index c5f0f22..33ed333 100644
+--- a/g10/options.h
++++ b/g10/options.h
+@@ -28,8 +28,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 168ab41..794c12b 100644
+--- a/include/cipher.h
++++ b/include/cipher.h
+@@ -109,7 +109,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 a1d58c9..25f682b 100644
+--- a/include/iobuf.h
++++ b/include/iobuf.h
+@@ -73,7 +73,7 @@ struct iobuf_struct {
+ };
+ 
+ #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/memory.h b/include/memory.h
+index 895d8a7..217d316 100644
+--- a/include/memory.h
++++ b/include/memory.h
+@@ -87,7 +87,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 81061d3..d529bda 100644
+--- a/include/mpi.h
++++ b/include/mpi.h
+@@ -38,7 +38,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/mpicalc.c b/tools/mpicalc.c
+index 1df27d9..647dfbd 100644
+--- a/tools/mpicalc.c
++++ b/tools/mpicalc.c
+@@ -30,6 +30,7 @@
+ #include <stdlib.h>
+ #include <ctype.h>
+ 
++#define INCLUDED_BY_MAIN_MODULE 1
+ #include "util.h"
+ #include "mpi.h"
+ #include "i18n.h"
recipes-support/gnupg/gnupg_1.4.7.bb +2 -1
index 6a950fd..6258809 100644
@@ -20,7 +20,8 @@ SRC_URI = "${GNUPG_MIRROR}/gnupg/gnupg-${PV}.tar.bz2 \
            file://CVE-2013-4242.patch \
            file://fix-ustar-check-issue.patch \
            file://0001-Make-it-build-with-gettext-0.20.patch \
-          "
+           file://0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch \
+           "
 
 SRC_URI[md5sum] = "b06a141cca5cd1a55bbdd25ab833303c"
 SRC_URI[sha256sum] = "69d18b7d193f62ca27ed4febcb4c9044aa0c95305d3258fe902e2fae5fc6468d"
#1 lore raw

With this patch applied, I get the following errors when using the latest master branches:

| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_limb_space':
| mpiutil.c:(.text+0x84): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc':
| mpiutil.c:(.text+0xda): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_secure':
| mpiutil.c:(.text+0x14a): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free_limb_space':
| mpiutil.c:(.text+0x1c7): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free':
| mpiutil.c:(.text+0x267): undefined reference to `memory_debug_mode'
| ../util/libutil.a(iobuf.o): In function `file_filter':
| iobuf.c:(.text+0x1c0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x1ea): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x2e0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x305): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o): In function `underflow':
| iobuf.c:(.text+0x4b3): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o):iobuf.c:(.text+0x567): more undefined

references to `iobuf_debug_mode' follow
| collect2: error: ld returned 1 exit status

If I revert this commit, gnupg-native will again build correctly. Any ideas?

Quoted 122 lines · Peter Kjellerstedt
---
 ...th-GCC-10-which-uses-fno-common-by-d.patch | 93 +++++++++++++++++++
 recipes-support/gnupg/gnupg_1.4.7.bb          |  3 +-
 2 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 recipes-support/gnupg/gnupg-1.4.7/0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch
recipes-support/gnupg/gnupg-1.4.7/0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch new file +93 -0
new file mode 100644
index 0000000..2f84155
@@ -0,0 +1,93 @@
+From 1d0141d77d4f81cfa3213370fb7eeddbf53fc085 Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <[email protected]>
+Date: Tue, 1 Sep 2020 00:29:22 +0200
+Subject: [PATCH] Make it build with GCC 10 (which uses -fno-common by default)
+
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ g10/options.h    | 3 +--
+ include/cipher.h | 2 +-
+ include/iobuf.h  | 2 +-
+ include/memory.h | 2 +-
+ include/mpi.h    | 2 +-
+ tools/mpicalc.c  | 1 +
+ 6 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/g10/options.h b/g10/options.h
+index c5f0f22..33ed333 100644
+--- a/g10/options.h
++++ b/g10/options.h
+@@ -28,8 +28,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 168ab41..794c12b 100644
+--- a/include/cipher.h
++++ b/include/cipher.h
+@@ -109,7 +109,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 a1d58c9..25f682b 100644
+--- a/include/iobuf.h
++++ b/include/iobuf.h
+@@ -73,7 +73,7 @@ struct iobuf_struct {
+ };
+
+ #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/memory.h b/include/memory.h
+index 895d8a7..217d316 100644
+--- a/include/memory.h
++++ b/include/memory.h
+@@ -87,7 +87,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 81061d3..d529bda 100644
+--- a/include/mpi.h
++++ b/include/mpi.h
+@@ -38,7 +38,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/mpicalc.c b/tools/mpicalc.c
+index 1df27d9..647dfbd 100644
+--- a/tools/mpicalc.c
++++ b/tools/mpicalc.c
+@@ -30,6 +30,7 @@
+ #include <stdlib.h>
+ #include <ctype.h>
+
++#define INCLUDED_BY_MAIN_MODULE 1
+ #include "util.h"
+ #include "mpi.h"
+ #include "i18n.h"
recipes-support/gnupg/gnupg_1.4.7.bb +2 -1
index 6a950fd..6258809 100644
@@ -20,7 +20,8 @@ SRC_URI = "${GNUPG_MIRROR}/gnupg/gnupg-${PV}.tar.bz2 \
            file://CVE-2013-4242.patch \
            file://fix-ustar-check-issue.patch \
            file://0001-Make-it-build-with-gettext-0.20.patch \
-          "
+           file://0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch \
+           "
 
 SRC_URI[md5sum] = "b06a141cca5cd1a55bbdd25ab833303c"
 SRC_URI[sha256sum] = "69d18b7d193f62ca27ed4febcb4c9044aa0c95305d3258fe902e2fae5fc6468d"
#2 lore raw
Quoted 22 lines · Joshua Watt

With this patch applied, I get the following errors when using the latest master branches:

| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_limb_space':
| mpiutil.c:(.text+0x84): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc':
| mpiutil.c:(.text+0xda): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_secure':
| mpiutil.c:(.text+0x14a): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free_limb_space':
| mpiutil.c:(.text+0x1c7): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free':
| mpiutil.c:(.text+0x267): undefined reference to `memory_debug_mode'
| ../util/libutil.a(iobuf.o): In function `file_filter':
| iobuf.c:(.text+0x1c0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x1ea): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x2e0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x305): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o): In function `underflow':
| iobuf.c:(.text+0x4b3): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o):iobuf.c:(.text+0x567): more undefined
Quoted 5 lines

references to `iobuf_debug_mode' follow
| collect2: error: ld returned 1 exit status

If I revert this commit, gnupg-native will again build correctly. Any ideas?

does it help if you add -fno-common to native CFLAGS

Quoted 127 lines
Quoted 122 lines · Peter Kjellerstedt
---
 ...th-GCC-10-which-uses-fno-common-by-d.patch | 93 +++++++++++++++++++
 recipes-support/gnupg/gnupg_1.4.7.bb          |  3 +-
 2 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 recipes-support/gnupg/gnupg-1.4.7/0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch
recipes-support/gnupg/gnupg-1.4.7/0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch new file +93 -0
new file mode 100644
index 0000000..2f84155
@@ -0,0 +1,93 @@
+From 1d0141d77d4f81cfa3213370fb7eeddbf53fc085 Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <[email protected]>
+Date: Tue, 1 Sep 2020 00:29:22 +0200
+Subject: [PATCH] Make it build with GCC 10 (which uses -fno-common by default)
+
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ g10/options.h    | 3 +--
+ include/cipher.h | 2 +-
+ include/iobuf.h  | 2 +-
+ include/memory.h | 2 +-
+ include/mpi.h    | 2 +-
+ tools/mpicalc.c  | 1 +
+ 6 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/g10/options.h b/g10/options.h
+index c5f0f22..33ed333 100644
+--- a/g10/options.h
++++ b/g10/options.h
+@@ -28,8 +28,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 168ab41..794c12b 100644
+--- a/include/cipher.h
++++ b/include/cipher.h
+@@ -109,7 +109,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 a1d58c9..25f682b 100644
+--- a/include/iobuf.h
++++ b/include/iobuf.h
+@@ -73,7 +73,7 @@ struct iobuf_struct {
+ };
+
+ #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/memory.h b/include/memory.h
+index 895d8a7..217d316 100644
+--- a/include/memory.h
++++ b/include/memory.h
+@@ -87,7 +87,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 81061d3..d529bda 100644
+--- a/include/mpi.h
++++ b/include/mpi.h
+@@ -38,7 +38,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/mpicalc.c b/tools/mpicalc.c
+index 1df27d9..647dfbd 100644
+--- a/tools/mpicalc.c
++++ b/tools/mpicalc.c
+@@ -30,6 +30,7 @@
+ #include <stdlib.h>
+ #include <ctype.h>
+
++#define INCLUDED_BY_MAIN_MODULE 1
+ #include "util.h"
+ #include "mpi.h"
+ #include "i18n.h"
recipes-support/gnupg/gnupg_1.4.7.bb +2 -1
index 6a950fd..6258809 100644
@@ -20,7 +20,8 @@ SRC_URI = "${GNUPG_MIRROR}/gnupg/gnupg-${PV}.tar.bz2 \
            file://CVE-2013-4242.patch \
            file://fix-ustar-check-issue.patch \
            file://0001-Make-it-build-with-gettext-0.20.patch \
-          "
+           file://0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch \
+           "
 
 SRC_URI[md5sum] = "b06a141cca5cd1a55bbdd25ab833303c"
 SRC_URI[sha256sum] = "69d18b7d193f62ca27ed4febcb4c9044aa0c95305d3258fe902e2fae5fc6468d"
#3 lore raw
Quoted 27 lines · Khem Raj
Quoted 25 lines · Joshua Watt

With this patch applied, I get the following errors when using the latest master branches:

| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_limb_space':
| mpiutil.c:(.text+0x84): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc':
| mpiutil.c:(.text+0xda): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_secure':
| mpiutil.c:(.text+0x14a): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free_limb_space':
| mpiutil.c:(.text+0x1c7): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free':
| mpiutil.c:(.text+0x267): undefined reference to `memory_debug_mode'
| ../util/libutil.a(iobuf.o): In function `file_filter':
| iobuf.c:(.text+0x1c0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x1ea): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x2e0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x305): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o): In function `underflow':
| iobuf.c:(.text+0x4b3): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o):iobuf.c:(.text+0x567): more undefined

references to `iobuf_debug_mode' follow
| collect2: error: ld returned 1 exit status

Quoted 4 lines
Quoted 2 lines

If I revert this commit, gnupg-native will again build correctly. Any ideas?

does it help if you add -fno-common to native CFLAGS

No. It works in all cases if I remove the patch and use "-fcommon" though. Oddly enough, in my build having the patch caused the target recipe to fail one way, and not having it caused it to fail another way.... not sure what's going on there, but I suspect for something this old, adding "-fcommon" to restore the original behavior makes the most sense.

Quoted 128 lines
Quoted 128 lines
Quoted 122 lines · Peter Kjellerstedt
---
 ...th-GCC-10-which-uses-fno-common-by-d.patch | 93 +++++++++++++++++++
 recipes-support/gnupg/gnupg_1.4.7.bb          |  3 +-
 2 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 recipes-support/gnupg/gnupg-1.4.7/0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch
recipes-support/gnupg/gnupg-1.4.7/0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch new file +93 -0
new file mode 100644
index 0000000..2f84155
@@ -0,0 +1,93 @@
+From 1d0141d77d4f81cfa3213370fb7eeddbf53fc085 Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <[email protected]>
+Date: Tue, 1 Sep 2020 00:29:22 +0200
+Subject: [PATCH] Make it build with GCC 10 (which uses -fno-common by default)
+
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ g10/options.h    | 3 +--
+ include/cipher.h | 2 +-
+ include/iobuf.h  | 2 +-
+ include/memory.h | 2 +-
+ include/mpi.h    | 2 +-
+ tools/mpicalc.c  | 1 +
+ 6 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/g10/options.h b/g10/options.h
+index c5f0f22..33ed333 100644
+--- a/g10/options.h
++++ b/g10/options.h
+@@ -28,8 +28,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 168ab41..794c12b 100644
+--- a/include/cipher.h
++++ b/include/cipher.h
+@@ -109,7 +109,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 a1d58c9..25f682b 100644
+--- a/include/iobuf.h
++++ b/include/iobuf.h
+@@ -73,7 +73,7 @@ struct iobuf_struct {
+ };
+
+ #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/memory.h b/include/memory.h
+index 895d8a7..217d316 100644
+--- a/include/memory.h
++++ b/include/memory.h
+@@ -87,7 +87,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 81061d3..d529bda 100644
+--- a/include/mpi.h
++++ b/include/mpi.h
+@@ -38,7 +38,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/mpicalc.c b/tools/mpicalc.c
+index 1df27d9..647dfbd 100644
+--- a/tools/mpicalc.c
++++ b/tools/mpicalc.c
+@@ -30,6 +30,7 @@
+ #include <stdlib.h>
+ #include <ctype.h>
+
++#define INCLUDED_BY_MAIN_MODULE 1
+ #include "util.h"
+ #include "mpi.h"
+ #include "i18n.h"
recipes-support/gnupg/gnupg_1.4.7.bb +2 -1
index 6a950fd..6258809 100644
@@ -20,7 +20,8 @@ SRC_URI = "${GNUPG_MIRROR}/gnupg/gnupg-${PV}.tar.bz2 \
            file://CVE-2013-4242.patch \
            file://fix-ustar-check-issue.patch \
            file://0001-Make-it-build-with-gettext-0.20.patch \
-          "
+           file://0001-Make-it-build-with-GCC-10-which-uses-fno-common-by-d.patch \
+           "
 
 SRC_URI[md5sum] = "b06a141cca5cd1a55bbdd25ab833303c"
 SRC_URI[sha256sum] = "69d18b7d193f62ca27ed4febcb4c9044aa0c95305d3258fe902e2fae5fc6468d"
#4 lore raw
Quoted 10 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Joshua Watt
Sent: den 1 oktober 2020 15:27
To: Khem Raj <[email protected]>
Cc: Peter Kjellerstedt <[email protected]>; [email protected]
Subject: Re: [yocto] [meta-gplv2] [PATCH] gnupg: Make it build with GCC 10 (which uses -fno-common by default)

Quoted 31 lines
Quoted 2 lines · Khem Raj

On Wed, Sep 30, 2020 at 1:37 PM Joshua Watt <[email protected]>

Quoted 27 lines · wrote:
Quoted 27 lines

With this patch applied, I get the following errors when using the latest master branches:

| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_limb_space':
| mpiutil.c:(.text+0x84): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc':
| mpiutil.c:(.text+0xda): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_secure':
| mpiutil.c:(.text+0x14a): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free_limb_space':
| mpiutil.c:(.text+0x1c7): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free':
| mpiutil.c:(.text+0x267): undefined reference to `memory_debug_mode'
| ../util/libutil.a(iobuf.o): In function `file_filter':
| iobuf.c:(.text+0x1c0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x1ea): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x2e0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x305): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o): In function `underflow':
| iobuf.c:(.text+0x4b3): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o):iobuf.c:(.text+0x567): more undefined

references to `iobuf_debug_mode' follow
| collect2: error: ld returned 1 exit status

If I revert this commit, gnupg-native will again build correctly. Any ideas?

Interesting. I had not considered building the recipes from meta-gplv2 for native as we only use them for target builds.

Quoted 6 lines
Quoted 1 line

does it help if you add -fno-common to native CFLAGS

No. It works in all cases if I remove the patch and use "-fcommon" though. Oddly enough, in my build having the patch caused the target recipe to fail one way, and not having it caused it to fail another way....

Are you saying you still have build failures when building gnupg for target as well, with the patch applied?

Quoted 3 lines

not sure what's going on there, but I suspect for something this old, adding "-fcommon" to restore the original behavior makes the most sense.

Anyway, I get the same errors as above when I try building it for native using gcc 9.3.1. I'll look into it and see if I can improve the patch, or if I will have to resort to using -fcommon.

//Peter

#5 lore raw
Quoted 42 lines · Peter Kjellerstedt
Quoted 10 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Joshua Watt
Sent: den 1 oktober 2020 15:27
To: Khem Raj <[email protected]>
Cc: Peter Kjellerstedt <[email protected]>; [email protected]
Subject: Re: [yocto] [meta-gplv2] [PATCH] gnupg: Make it build with GCC 10 (which uses -fno-common by default)

Quoted 29 lines
Quoted 1 line · Khem Raj

On Wed, Sep 30, 2020 at 1:37 PM Joshua Watt <[email protected]>

Quoted 26 lines · wrote:
Quoted 26 lines

With this patch applied, I get the following errors when using the latest master branches:

| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_limb_space':
| mpiutil.c:(.text+0x84): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc':
| mpiutil.c:(.text+0xda): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_secure':
| mpiutil.c:(.text+0x14a): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free_limb_space':
| mpiutil.c:(.text+0x1c7): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free':
| mpiutil.c:(.text+0x267): undefined reference to `memory_debug_mode'
| ../util/libutil.a(iobuf.o): In function `file_filter':
| iobuf.c:(.text+0x1c0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x1ea): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x2e0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x305): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o): In function `underflow':
| iobuf.c:(.text+0x4b3): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o):iobuf.c:(.text+0x567): more undefined

references to `iobuf_debug_mode' follow
| collect2: error: ld returned 1 exit status

If I revert this commit, gnupg-native will again build correctly. Any ideas?

Interesting. I had not considered building the recipes from meta-gplv2 for native as we only use them for target builds.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

does it help if you add -fno-common to native CFLAGS

No. It works in all cases if I remove the patch and use "-fcommon" though. Oddly enough, in my build having the patch caused the target recipe to fail one way, and not having it caused it to fail another way....

Are you saying you still have build failures when building gnupg for target as well, with the patch applied?

Correct. I don't remember exactly, but there was no combination of "-fno-common" and the patch that worked for both native and target cases. The only way I could get it to work for both was without the patch and with "-fcommon"

Quoted 10 lines
Quoted 4 lines

not sure what's going on there, but I suspect for something this old, adding "-fcommon" to restore the original behavior makes the most sense.

Anyway, I get the same errors as above when I try building it for native using gcc 9.3.1. I'll look into it and see if I can improve the patch, or if I will have to resort to using -fcommon.

//Peter

#6 lore raw
In reply to Peter Kjellerstedt
Quoted 50 lines · Peter Kjellerstedt
Quoted 10 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Joshua Watt
Sent: den 1 oktober 2020 15:27
To: Khem Raj <[email protected]>
Cc: Peter Kjellerstedt <[email protected]>; [email protected]
Subject: Re: [yocto] [meta-gplv2] [PATCH] gnupg: Make it build with GCC 10 (which uses -fno-common by default)

Quoted 29 lines
Quoted 1 line · Khem Raj

On Wed, Sep 30, 2020 at 1:37 PM Joshua Watt <[email protected]>

Quoted 26 lines · wrote:
Quoted 26 lines

With this patch applied, I get the following errors when using the latest master branches:

| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_limb_space':
| mpiutil.c:(.text+0x84): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc':
| mpiutil.c:(.text+0xda): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_alloc_secure':
| mpiutil.c:(.text+0x14a): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free_limb_space':
| mpiutil.c:(.text+0x1c7): undefined reference to `memory_debug_mode'
| ../mpi/libmpi.a(mpiutil.o): In function `mpi_free':
| mpiutil.c:(.text+0x267): undefined reference to `memory_debug_mode'
| ../util/libutil.a(iobuf.o): In function `file_filter':
| iobuf.c:(.text+0x1c0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x1ea): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x2e0): undefined reference to `iobuf_debug_mode'
| iobuf.c:(.text+0x305): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o): In function `underflow':
| iobuf.c:(.text+0x4b3): undefined reference to `iobuf_debug_mode'
| ../util/libutil.a(iobuf.o):iobuf.c:(.text+0x567): more undefined

references to `iobuf_debug_mode' follow
| collect2: error: ld returned 1 exit status

If I revert this commit, gnupg-native will again build correctly. Any ideas?

Interesting. I had not considered building the recipes from meta-gplv2 for native as we only use them for target builds.

Quoted 5 lines
Quoted 1 line

does it help if you add -fno-common to native CFLAGS

No. It works in all cases if I remove the patch and use "-fcommon" though. Oddly enough, in my build having the patch caused the target recipe to fail one way, and not having it caused it to fail another way....

Are you saying you still have build failures when building gnupg for target as well, with the patch applied?

Quoted 6 lines
Quoted 3 lines

not sure what's going on there, but I suspect for something this old, adding "-fcommon" to restore the original behavior makes the most sense.

Anyway, I get the same errors as above when I try building it for native using gcc 9.3.1. I'll look into it and see if I can improve the patch, or if I will have to resort to using -fcommon.

Any update on this?

FWIW, I think with something this old it's probably best to keep the -fcommon behavior rather than try to patch around it.

Quoted 3 lines

//Peter