Project

General

Profile

Actions

Bug #286

closed

"-fcommon" support in gcc version 10 - coreinfo "multiple definition of" build failure

Added by James Feeney about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
11/03/2020
Due date:
% Done:

0%

Estimated time:
Affected versions:
Needs backport to:
Affected hardware:
Affected OS:

Description

Copied from: https://github.com/seemoo-lab/owl/issues/32

"Starting from the upcoming GCC release 10, the default of -fcommon option will change to -fno-common - this leads to build error"

Copied from man 1 gcc:


-fcommon

In C code, this option controls the placement of global variables defined without an initializer, known as tentative definitions in the C standard. Tentative definitions are distinct from declarations of a variable with the "extern" keyword, which do not allocate storage.

The default is -fno-common, which specifies that the compiler places uninitialized global variables in the BSS section of the object file. This inhibits the merging of tentative definitions by the linker so you get a multiple-definition error if the same variable is accidentally defined in more than one compilation unit.

The -fcommon places uninitialized global variables in a common block. This allows the linker to resolve all tentative definitions of the same variable in different compilation units to the same object, or to a non-tentative definition. This behavior is inconsistent with C++, and on many targets implies a speed and code size penalty on global variable references. It is mainly useful to enable legacy code to link without errors.


So then, make -C payloads/coreinfo ends with:

/usr/bin/ld: /var/src/coreboot/coreboot/payloads/coreinfo/build/libpayload/bin/../lib/libpayload.a(exception.libc.o):/var/src/coreboot/coreboot/payloads/libpayload/include/x86/arch/exception.h:64: multiple definition of `__packed';
/var/src/coreboot/coreboot/payloads/coreinfo/build/libpayload/bin/../lib/libpayload.a(main.libc.o):/var/src/coreboot/coreboot/payloads/libpayload/include/x86/arch/exception.h:64: first defined here
...

Trying to simplistically prepend CFLAGS=' -fcommon ' make -C payloads/coreinfo just changes the build flow, giving:
cc1: fatal error: /var/src/coreboot/coreboot/payloads/coreinfo/build/libpayload/include/kconfig.h: No such file or directory

Trying to judiciously add a CFLAGS += -fcommon to the payloads/coreinfo/Makefile is beyond me. It changes nothing and produces the same original "multiple definition of" error.

Somebody who knows more about this, please comment.

Actions

Also available in: Atom PDF