This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug driver/42690] Undefined reference errors with -flto -fuse-linker-plugin
- From: "espindola at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jan 2010 15:28:52 -0000
- Subject: [Bug driver/42690] Undefined reference errors with -flto -fuse-linker-plugin
- References: <bug-42690-16926@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #12 from espindola at gcc dot gnu dot org 2010-01-15 15:28 -------
(In reply to comment #11)
> GCC was configured with --disable-shared option. It seems that the driver does
> not understand that --disable-shared implies static libgcc
>
That is correct. Currently we have
%{static|static-libgcc:-plugin-opt=-pass-through=%(lto_libgcc)} \
%{static:-plugin-opt=-pass-through=-lc} \
That is, --pass-through is only used for libgcc if -static or -static-libgcc is
given. For libgcc we could probably find out if we are using a static one or
not in a more accurate way.
For libc it is harder. The driver doesn't know that libc is static. It just
passes -lc to ld.
It might be possible to change what we test for. I think it would be OK to
always ask the plugin to pass libgcc and libc to the linker a second time *if
they are being used at all*. My understanding is that an unnecessary static
library will be ignored and a shared library will have no effect since it was
already used anyway.
To implement this we should always pass -plugin-opt=-pass-through=%(lto_libgcc)
and -plugin-opt=-pass-through=-lc to the linker unless something like -nostdlib
is used.
What options other than -nostdlib prevent gcc from linking libgcc and libc in
the produced binary?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690