Bug 12314 - No LTO, LD silently links to non-IR code
Summary: No LTO, LD silently links to non-IR code
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-13 19:32 UTC by Dmitry Gorbachev
Modified: 2012-12-07 20:07 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Example (263 bytes, text/plain)
2010-12-13 19:32 UTC, Dmitry Gorbachev
Details
A patch (612 bytes, patch)
2010-12-13 20:51 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Gorbachev 2010-12-13 19:32:04 UTC
Created attachment 5155 [details]
Example

I think that it would be good to give a warning in such situation...
Comment 1 H.J. Lu 2010-12-13 20:51:43 UTC
Created attachment 5156 [details]
A patch
Comment 2 H.J. Lu 2010-12-13 20:53:31 UTC
Fixed by commit 0ca9456fe1b8f0cf0793ca5e64317e658b18799c on
hjl/lto-mixed branch.
Comment 3 H.J. Lu 2011-01-23 19:12:29 UTC
I checked in a different fix with commit baf9b44566e088687f28f9fe476122876c1d2f4d.
Now you will get

/usr/gcc-4.6/bin/gcc -B./ -O -flto   -c -o bar.o bar.c
ar cr libbar.a bar.o
/usr/gcc-4.6/bin/gcc -B./ -O -flto -fuse-linker-plugin -o prog1 -L. main.c -lbar foo.c
/tmp/cc9q7ek9.ltrans0.ltrans.o: In function `main':
cc9q7ek9.ltrans0.o:(.text+0x5): undefined reference to `bar'
collect2: ld returned 1 exit status
make: *** [prog1] Error 1
Comment 4 H.J. Lu 2012-12-07 20:07:16 UTC
Works in 2.23 and tracked by "LTO 12a"/"LTO 12b" tests in ld-plugin.