Page MenuHome GnuPG

scute: -fcommon needed when building with gcc-10
Closed, ResolvedPublic

Description

Hello,

trying to build scute 1.7 using gcc-10 (as in Debian testing) results in linker errors like:

/usr/bin/ld: .libs/scute_la-readconf.o:./src/options.h:28: multiple definition of `_scute_opt'; .libs/scute_la-debug.o:./src/options.h:28: first defined here

This is a pattern seen fairly often since gcc-10 changed the default from -fcommon to -fno-common (see external link).

A quick workaround was adding -fcommon to CFLAGS somewhere as done in T5215. It was nicer though the change the definitions in the source code.

Revisions and Commits

Event Timeline

gouttegd triaged this task as Normal priority.
gouttegd changed the task status from Open to Testing.Mar 30 2021, 11:48 PM

It should be fixed with 49ad2b0e05e3fcb8c8c2e23bb1c6063b390dee02, though I don’t have a gcc-10 to check. It does work with gcc-9.3 with -fno-common.

FWIW, in GnuPG we use

EXTERN_UNLESS_MAIN_MODULE
struct
 {  [...]

in the specific header or wherever we want to declare something as extern,

#ifndef EXTERN_UNLESS_MAIN_MODULE
# if !defined (INCLUDED_BY_MAIN_MODULE)
#  define EXTERN_UNLESS_MAIN_MODULE extern
# else
#  define EXTERN_UNLESS_MAIN_MODULE 
# endif
#endif

in a top header. And INCLUDED_BY_MAIN_MODULE is the defined in the main modules (e.g. gpg.c). This scheme goes back to the time we added support for RISC OS, which Norcraft compiler had no support for common blocks. Makes life easier in a larger project but this overhead it is not needed for Scute.

Looks good to me: "make && make check" passes.