Skip to content

fix issue with GCC 10 (duplicate global variable declarations)

Hans-Nikolai Viessmann requested to merge hans/sac2c:hans-fix-gcc-common into develop

With GCC 10, we get errors with multiple 'first' declarations of global variables. This is not something new, rather GCC in previous versions assumed these multiple declarations to be 'common'. In version 10+ this is not the case, with GCC running with -fno-common on by default.

See https://gcc.gnu.org/gcc-10/porting_to.html.

These declarations are coming from runtime/mt_h/schedule.h, where we define the SAC_MT_DEFINE() macro. This macro is expanded in the generated header file (header.h) and included in all function compilations units (e.g. fun1.c) and in globals.c. When we link the object files together, we get this conflict.

As it happens, there is no need for the SAC_MT_DEFINE() macro. In previous work to overhaul the MT backend, all of the global variable definitions were removed. The variables now exist within structs for the beehive.

With this, the fix is to remove the SAC_MT_DEFINE() definition and expansion call.

Edited by Hans-Nikolai Viessmann

Merge request reports