* Jan Hubicka wrote on Fri, Jun 11, 2010 at 03:26:12PM CEST: > > Ah, so the problem is the missing -flto in the second compilation > > step? I think this is a bug in the compiler for not reporting this > > somehow. Is there are PR open for this? > > Compiler can not report it because it does not see the other object files. > It is really up to user to understand -fwhole-program and mark externally > visible > symbols. Your testcase is quite ugly in a way that it leads to miscopmilation > rather than linktime error, but there is not much we can do about it I guess. > Perhaps we can somehow poison the object names that are brought local with > -fwhole-program > so linking explode, but I am not sure there is way to do so.
The requirement to compile with -flto needs to be documented in the description of the -fwhole-program switch in invoke.texi. The text of the following -flto switch is long enough that the user will not by see that by chance, and it isn't very specific on this either. More generally, the description of -fwhole-program does not make it clear to me whether it is required at compile time or link time only, or both. Likewise, it is unclear whether the combination of -fwhole-program with -combine, -flto, or -fwhopr is to happen at compile time, link time, both, or one switch at compile time and another at link time, or one for some translation units at compile time, and another for others. The description refers to "the current compilation unit" but there may be more than one unit, or none at all if only objects and libraries were specified. I'm willing to improve the documentation if somebody explains the intended semantics to me. :-) Cheers, Ralf