Bug 44802 - -flto -fuse-linker-plugin causes undefined references from libc in the link phase
Summary: -flto -fuse-linker-plugin causes undefined references from libc in the link p...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.5.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-03 12:31 UTC by Juhani Viheräkoski
Modified: 2010-07-27 12:42 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
full error message (1.54 KB, application/x-xz)
2010-07-03 12:32 UTC, Juhani Viheräkoski
Details
a testcase (24.82 KB, application/x-xz)
2010-07-03 12:33 UTC, Juhani Viheräkoski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Juhani Viheräkoski 2010-07-03 12:31:19 UTC
This works fine without -fuse-linker-plugin (with all object files extracted from archive). This reduced testcase has some undefined references of its own but still exposes the bug as shown below. Whole output of linking a complete program is attached because of its 30 kB size. Also a preprocessed source file is attached.

gcc -std=gnu99 -fvisibility=hidden -O3 -fomit-frame-pointer -march=pentium4 -flto -fuse-linker-plugin -o xz main.i

--SNAP--
/home/misty/gcc/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../i686-pc-linux-gnu/bin/ld: error: hidden symbol 'fgetc' is not defined locally
/home/misty/gcc/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../i686-pc-linux-gnu/bin/ld: error: hidden symbol 'ferror' is not defined locally
--SNAP--

main.i was produced with:

gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../..  -DLOCALEDIR=\"/home/misty/gcc/share/locale\" -I../../src/common -I../../src/liblzma/api -I../../lib -DLZMA_API_STATIC  -pthread -fvisibility=hidden -Wall -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls -O3 -fomit-frame-pointer -march=pentium4 -flto -fuse-linker-plugin -MT xz-main.o -MD -MP -MF .deps/xz-main.Tpo -E main.c >main.i
Comment 1 Juhani Viheräkoski 2010-07-03 12:32:45 UTC
Created attachment 21076 [details]
full error message
Comment 2 Juhani Viheräkoski 2010-07-03 12:33:23 UTC
Created attachment 21077 [details]
a testcase
Comment 3 Juhani Viheräkoski 2010-07-03 13:35:15 UTC
On trunk the same link command fails too, but in a different way. I was able to produce a reduced testcase and filed a new report as these issues are probably not related.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44804
Comment 4 Juhani Viheräkoski 2010-07-08 02:02:54 UTC
(In reply to comment #3)

Bug mentioned in #3 was fixed on the mainline, so now this issue manifests itself on trunk also. The difficulty is that a complete testcase would be to build xz, the smaller case I added is unfortunately incomplete. As there are some improvements coming to LTO soon according to the mailing lists, I'll just test the complete build regularly to see if it gets fixed and (if it doesn't :) get back to this later.
Comment 5 Jan Hubicka 2010-07-26 21:14:18 UTC
I fixed similar problem on mainline (it was bogus visibility handling for external symbols). Can you re-try?
Comment 6 Juhani Viheräkoski 2010-07-27 12:42:10 UTC
(In reply to comment #5)

I compiled xz with a trunk compiler and this seems to be fixed now. Thanks!