Page MenuHome GnuPG

gnugp1: Fix build errors with gcc-10
Testing, NormalPublic


The gnugp1 package fails to build with gcc-10 This is a direct result of gcc defaulting to -fno-common, see also

A simple but somewhat ugly fix was to tweak the build options to restore the previous behaviour, this is what Fedora did in However, I would prefer a nicer approach. Rewriting the code might become somewhat bigger work, I tried a few things but no luck. So I'd prefer to enhance the definition of EXTERN_UNLESS_MAIN_MODULE as for example:

--- a/g10/options.h
+++ b/g10/options.h
@@ -29,6 +29,8 @@
 /* Norcraft can't cope with common symbols */
 #if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
+#elif defined (__GNUC__) && __GNUC__ >= 10
+#define EXTERN_UNLESS_MAIN_MODULE __attribute__((__common__))



External Link

Event Timeline

You may want to check that clang supports this attribute as well.

According to list of attributes in the clang 12 documention, there is no such attribute in clang. However, the clang-11 compiler (as seen in Debian) does not define __GNUC__, so the proposed patch does not affect the status when building with clang.

Sure that the FreeBSD compiler does not define it? I am pretty sure it does.

Thus better add a

&& !defined(__clang__)
werner triaged this task as Normal priority.Jan 5 2021, 9:06 AM

After some more checking: LLVM-11 introduced the same behaviour in that regard, but appearently not a pragma/attribute to override this:

Also, FreeBSD just enabled -fcommon to deal with that situation:

As a result, I'm inclined to just add -fcommon in the compile options. Either unconditionally, or after some autoconf check could be done whether it's really required, or limited to gcc and clang. But I doubt that is worth the efforts and would just stick to the first option.

Take care: gpg is also used on platforms with proprietary compilers which don't support -f options. Thus you need to limit this to gcc.

Okay. Now since is already touching CFLAGS, it seemed like a good place to add that additional option here. All this is guarded by a test for GCC, and since clang mimics that behaviour, it works for them as well.

--- a/
+++ b/
@@ -1411,10 +1411,10 @@ if test "$GCC" = yes; then
     # warning options and the user should have a chance of overriding
     if test "$USE_MAINTAINER_MODE" = "yes"; then
-        CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
+        CFLAGS="$CFLAGS -Wall -fcommon -Wcast-align -Wshadow -Wstrict-prototypes"
         CFLAGS="$CFLAGS -Wformat-nonliteral"
-        CFLAGS="$CFLAGS -Wall"
+        CFLAGS="$CFLAGS -Wall -fcommon"
     # This is handy for debugging so the compiler doesn't rearrange
gniibe added a subscriber: gniibe.

Code for avoiding the COMMON section has been there, because of RISC OS.
I think that it will be easier to enable that for all (but not for RISC OS only).

werner changed the task status from Open to Testing.Sep 22 2022, 10:58 AM
werner removed a project: Restricted Project.