GCC currently defaults to -fcommon.  This is an optional C feature dating
back to early C implementations.  On many targets this means global variable
accesses having an unnecessary codesize and performance penalty in C code
(the same source generates better code when built as C++).  Given there isn't
a lot of software that really requires this (mostly it's accidentally 
forgetting to
use 'extern' in a header), it is about time to change the default.

What do people think? I presume someone with access to distro source code
and a fast build machine could try and see how many packages fail to get an
idea how feasible it is. We could keep defaulting to -fcommon with -std=c89
if necessary.

2017-11-17  Wilco Dijkstra  <wdijk...@arm.com>

        * common.opt (fcommon): Change init to 1.
        * doc/invoke.texi (-fcommon): Update documentation.
--

diff --git a/gcc/common.opt b/gcc/common.opt
index 
59940c64356964f8f9b9d842ad3f1a1c02548bab..575472aee7572601b6276944679c0a55171e39b2
 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1110,7 +1110,7 @@ Common Report Var(flag_combine_stack_adjustments) 
Optimization
 Looks for opportunities to reduce stack adjustments and stack references.
 
 fcommon
-Common Report Var(flag_no_common,0)
+Common Report Var(flag_no_common,0) Init(1)
 Do not put uninitialized globals in the common section.
 
 fcompare-debug
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 
7ea9f765717d1ace59276406777a6055d6ed6b59..b618e648dbd9ab4a16ec856aea7a6660caad3e9a
 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -12494,8 +12494,8 @@ useful for building programs to run under WINE@.
 code that is not binary compatible with code generated without that switch.
 Use it to conform to a non-default application binary interface.
 
-@item -fno-common
-@opindex fno-common
+@item -fcommon
+@opindex fcommon
 @cindex tentative definitions
 In C code, this option controls the placement of global variables 
 defined without an initializer, known as @dfn{tentative definitions} 
@@ -12506,15 +12506,14 @@ Unix C compilers have traditionally allocated storage 
for
 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 is the behavior specified by @option{-fcommon}, and is the default for 
-GCC on most targets.  
+definition.  This is the behavior specified by @option{-fcommon}.
 On the other hand, this behavior is not required by ISO
-C, and on some targets may carry a speed or code size penalty on
+C, and on several targets implies a speed and code size penalty on
 variable references.
 
-The @option{-fno-common} option specifies that the compiler should instead
-place uninitialized global variables in the data section of the object file.
+The @option{-fno-common} option is the default.  It specifies that the
+compiler should instead place uninitialized global variables in the data
+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 defined in more than one compilation unit.

Reply via email to