[RFC][PATCH] Change default to -fcommon
Richard Biener
richard.guenther@gmail.com
Mon Nov 20 10:25:00 GMT 2017
On Sun, Nov 19, 2017 at 2:48 AM, Sandra Loosemore
<sandra@codesourcery.com> wrote:
> On 11/17/2017 12:12 PM, Wilco Dijkstra wrote:
>>
>> 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 <wdijkstr@arm.com>
>>
>> * common.opt (fcommon): Change init to 1.
>> * doc/invoke.texi (-fcommon): Update documentation.
>
>
> The doc parts of this patch are OK.
>
> Personally, I think the change is a good idea, but I don't know how much
> breakage it would cause. One data point I can contribute is that when we
> looked at this several years ago, we found that all competing compilers on
> bare-metal targets implemented the -fno-common behavior. So another possible
> compromise is keeping -fcommon on Unix-like targets where it is the
> traditional behavior, and switching to -fno-common elsewhere where it's not.
> I don't see much benefit in tying the default to -std= since it's not
> behavior specified in the C standard at all.
A target specific default might be a good idea if we decide to revert.
Note I proposed this change a few times already, but the fear was always
we'll break too much legacy code.
Note you have to make sure GFortran still works! So I think the patch should
be changed to make the default behavior be frontend dependent or have a
fortran/ adjustment that fixes things up for the fortran dialects that need it.
CCing fortran@
Richard.
> -Sandra
More information about the Gcc-patches
mailing list