public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "lat at cern dot ch" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/50687] Missing symbols with -flto -fvisibility=hidden on 4.6.x but not on 4.7.0 Date: Tue, 11 Oct 2011 09:25:00 -0000 [thread overview] Message-ID: <bug-50687-4-e5fgEjbI7l@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-50687-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50687 Lassi Tuura <lat at cern dot ch> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lat at cern dot ch --- Comment #1 from Lassi Tuura <lat at cern dot ch> 2011-10-11 09:25:24 UTC --- FWIW, I don't think this is a bug in the compiler. With -fvisibility=hidden a promise is made that bar::foo() is internal to the shared library, and if the compiler generates virtual function table for bar, it needs foo too. At least on a system I tested, RHEL5-derived system with GCC 4.6.1 and binutils 2.21.1 gold as the linker, the reason there's no unreferenced symbols without -flto is simply that no code what so ever is getting generated for 'bar'. In fact no code at all is emitted for test.cc. I assume the compiler just decides the class is irrelevant to the compilation unit, which seems entirely reasonable choice to me -- otherwise it'd be generating code for loads of types from headers which are never used in a particular compilation unit. With 4.6.x LTO presumably this pruning doesn't happen, or isn't complete enough, and/or isn't garbage collected at link phase as unreferenced, so the bar::foo reference remains and becomes unsatisfied symbol - which seems reasonable to me. Perhaps it's a quality issue that unreferenced types cause code to be generated, but IMHO is not a bug in the compiler. If I change the code so it forces a reference generated for bar, so the bar virtual function table gets generated, triggering getFoo() to be compiled, I get the same undefined symbol without LTO with GCC 4.6.1 too. I didn't try with GCC trunk, so can't comment on why the reference isn't seen there.
next prev parent reply other threads:[~2011-10-11 9:25 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-10-10 16:01 [Bug lto/50687] New: " giulio.eulisse at cern dot ch 2011-10-11 9:25 ` lat at cern dot ch [this message] 2011-10-11 9:57 ` [Bug lto/50687] " giulio.eulisse at cern dot ch 2011-10-11 9:58 ` paolo.carlini at oracle dot com 2011-10-11 12:01 ` lat at cern dot ch
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-50687-4-e5fgEjbI7l@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).