Yes gcc 4.9.0.
Thread model: win32
gcc version 4.9.0 (i686-win32-sjlj-rev0, Built by MinGW-W64 project)

2014-04-26



Best regards,
lh_mouse




发件人:TOCK Chiu <stanley82...@gmail.com>
发送时间:2014-04-26 21:20
主题:Re: [Mingw-w64-public] Do I need -flto when building a static lib?
收件人:"mingw-w64-public"<mingw-w64-public@lists.sourceforge.net>
抄送:

Are you using GCC 4.9.0?


Since GCC 4.9.0, LTO-enabled object file doesn't contain normal object code but 
GIMPLE bytecode by default.
If you want to link to a static library, you have to pass -fuse-linker-plugin 
to let it extract LTO segments, and AFAIK it's enabled by default when -flto is 
passed.
But I don't know why, the linker plugin of MinGW seems not working, it always 
tell me some symbols are undefined. 
So instead, you may pass -ffat-lto-objects to make it generate object files 
with normal object code, but you won't benefit from LTO.




2014-04-26 18:39 GMT+08:00 lh_mouse <lh_mo...@126.com>:

Hello there, do I need -flto when building a static lib?
Here is an example:

E:\Desktop>gcc foo.c -c -flto
E:\Desktop>ar rcs libfoo.a foo.o
E:\Desktop>gcc main.c -L. -lfoo -flto
C:\Users\LH_Mouse\AppData\Local\Temp\ccc30oDd.ltrans0.ltrans.o:ccc30oDd.ltrans0.o:(.text+0x1e):
 undefined reference to `foo'
collect2.exe: error: ld returned 1 exit status

Without those -flto options these commands worked just well.
Looking forward to you reply.

--------------
Best regards,
lh_mouse
2014-04-26
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to