This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [RFC][PATCH] Change default to -fcommon
- From: Michael Matz <matz at suse dot de>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Sandra Loosemore <sandra at codesourcery dot com>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, "ebotcazou at adacore dot com" <ebotcazou at adacore dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Mon, 20 Nov 2017 18:34:13 +0100 (CET)
- Subject: Re: [RFC][PATCH] Change default to -fcommon
- Authentication-results: sourceware.org; auth=none
- References: <DB6PR0801MB20537CD32063175699A3E50F832F0@DB6PR0801MB2053.eurprd08.prod.outlook.com> <839cf67b-dee2-7ee7-e59e-3315cbc6cece@codesourcery.com>,<CAFiYyc1nHMX73evvnCcF1x0SeP7=p72VOinfw3oyaak-d2TanA@mail.gmail.com> <DB6PR0801MB2053E05E8489867CFC86DF2E83220@DB6PR0801MB2053.eurprd08.prod.outlook.com>
Hi,
On Mon, 20 Nov 2017, Wilco Dijkstra wrote:
> > 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.
>
> Fortran doesn't use flag_no_common, so COMMON globals are not affected.
>
> There is one use in Ada which looks like an optimization for specific targets:
>
> /* Ada doesn't feature Fortran-like COMMON variables so we shouldn't
> try to fiddle with DECL_COMMON. However, on platforms that don't
> support global BSS sections, uninitialized global variables would
> go in DATA instead, thus increasing the size of the executable. */
> if (!flag_no_common
> && TREE_CODE (var_decl) == VAR_DECL
> && TREE_PUBLIC (var_decl)
> && !have_global_bss_p ())
> DECL_COMMON (var_decl) = 1;
>
> I don't understand how this works - if there is no bss support in the
> linker, wouldn't common variables would still end up in the data
> section?
bss _sections_ != bss-like segments in the executable. Targets might not
have a bss section that could be named in the asm file, or no way to
switch to it without disrupting surrounding code, but they might have
common symbols, which ultimately might or might not be collected in some
bss-like segment. In that case you want to use them instead of symbols in
.data.
What's your rationale for changing this? In your initial mail you said:
"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++)."
I have a hard time imaging that, so can you give details? FWIW I've
personally always considered using common symbols nicer.
Ciao,
Michael.