http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46944
Summary: gcc should accept -fuse-linker-plugin only if linker handles -plugin Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassig...@gcc.gnu.org ReportedBy: r...@gcc.gnu.org CC: da...@gcc.gnu.org, ccout...@google.com Host: *-*-solaris2.* Target: *-*-solaris2.* Build: *-*-solaris2.* While the new gcc.dg/pr43157.c testcase didn't contain /* { dg-require-linker-plugin "" } */ it failed on Solaris 11/x86 using the Sun linker like this, but only with -m64: FAIL: gcc.dg/pr43157.c (test for excess errors) Excess errors: ld: fatal: file /usr/lib/amd64/crt1.o: wrong ELF class: ELFCLASS64 ld: fatal: file processing errors. No output written to pr43157.exe The problem is that ld is ultimately invoked as /usr/ccs/bin/ld -plugin liblto_plugin.so ... -o pr43157.exe /usr/lib/amd64/crt1.o ... Since the compiler (and thus liblto_plugin.so) are 32-bit objects, crt1.o and all other input objects are 64-bit, yielding the error message above. While Sun ld doesn't understand -plugin proper, it does accept -p auditlib, as described in the manpage: -p auditlib Identifies an audit library, auditlib. This audit library is used to audit the object being created at runtime. A shared object identified as requiring audit- ing with the -p option, has this requirement inherited by any object that specifies the shared object as a dependency. See the -P option. See Runtime Linker Audit- ing Interface in Linker and Libraries Guide. So, the invocation above is parsed as -p lugin liblto_plugin.so, i.e. try to load an auditlib named lugin and pass liblto_plugin.so as regular input file. I think it's obvious that the gcc configury should verify that the linker used really understands -plugin and not only happens to have some other option that something completely different. Only if this has been verified should -plugin be passed to the linker when -fuse-linker-plugin is given, otherwise the option should be rejected with a proper error message.