This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix visibility of constructors/destructors with -fwhole-program
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: John David Anglin <dave at hiauly1 dot hia dot nrc dot ca>
- Cc: gcc-patches at gcc dot gnu dot org, rguenth at gcc dot gnu dot org
- Date: Sat, 27 Mar 2010 18:32:11 +0100
- Subject: Re: [PATCH] Fix visibility of constructors/destructors with -fwhole-program
- References: <20100327142544.59A9F4FA3@hiauly1.hia.nrc.ca>
> > This patch fixes PR middle-end/41674. With -fwhole-program, the
> > constructor _GLOBAL__I_65535_0_main has its public flag turned off
> > by function_and_variable_visibility and thereby made local. However,
> > these symbols need to be global for collect2 to arrange to call them.
> >
> > Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.
>
> Here is take 2. The first version was deemed overkill and Richard suggested
> using DECL_PRESERVE_P.
>
> Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11 with no regressions.
>
> Ok for trunk?
Hmm, I see it was applied already, but this imply that attribute used on functions
now imply externally_visible, while on variables it does not.
I am not sure what would be best behaviour of used WRT whole-program. I guess
the symbol should be still brought static, but the mangling (i.e. .1234) should
not be applied so asm statements from other source files (within same LTO unit)
can refer to it.
I guess it is resonable to want something like the following work:
t1.c:
__attribute__ ((used)) int q;
__attribute__ ((used))
void
t()
{
}
t2.c:
main()
{
int q;
asm("call t; movl $q,%0":"=r"(q));
return q;
}
and expect this to link properly -fwhole-program or not and I guess also to
make -fwhole-program privatize both q and t unless externally_visible is given.
At present (before this patch) we seem to get 't' right (i.e. it is static and
with original name), but we do not output q. If this seems like intended
behaviour, I guess I can fix this as well as make this hppa fix to attach
externally visible attribute (or simply force externally visible flag on the
cgraph node that should have same effect)
Honza