> 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. Honza