Bug 49844 - Building CodeBlocks on Windows using mingw gcc 4.6.1 "-flto -fuse-linker-plugin" results in many linker stage errors
Summary: Building CodeBlocks on Windows using mingw gcc 4.6.1 "-flto -fuse-linker-plug...
Status: WAITING
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-25 16:01 UTC by xunxun
Modified: 2012-05-07 13:59 UTC (History)
3 users (show)

See Also:
Host: i686-pc-mingw32
Target: i686-pc-mingw32
Build: i686-pc-mingw32
Known to work:
Known to fail:
Last reconfirmed: 2012-05-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description xunxun 2011-07-25 16:01:02 UTC
My gcc4.6.1 configure with :
./configure --prefix=/mingw --host=i686-pc-mingw32 --build=i686-pc-mingw32 --target=i686-pc-mingw32 \
     	--with-lto-plugin --with-host-libstdcxx=-lstdc++ --disable-bootstrap --disable-werror --with-arch=i686 --with-tune=generic \
	--enable-languages=c,c++,fortran --enable-libgomp --enable-threads=win32 --enable-lto --with-system-zlib \
	--enable-libstdcxx-debug --enable-version-specific-runtime-libs --enable-fully-dynamic-string \
	--disable-sjlj-exceptions --with-dwarf2 --disable-symvers --enable-checking=release \
	--enable-plugins --enable-cloog-backend=isl --enable-static --disable-shared \
	--disable-nls --disable-win32-registry

My ld version is : 2.21.52.20110708

When I build Code::Blocks, if I add "-flto" to the compiler option, and add "-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -s -flto -fuse-linker-plugin" to the linker option, that will result in many linker stage errors:

--------------------------------------------------------------------------------
g++.exe -shared  -Wl,--out-implib=devel\libwxpropgrid.a -Wl,--dll -Lbase\tinyxml -LE:\MyPack\3rdLib\GUI\wxWidgets-2.8.12\lib\gcc_dll  .objs\sdk\wxpropgrid\src\editors.o .objs\sdk\wxpropgrid\src\extras.o .objs\sdk\wxpropgrid\src\manager.o .objs\sdk\wxpropgrid\src\odcombo.o .objs\sdk\wxpropgrid\src\propgrid.o .objs\sdk\wxpropgrid\src\props.o .objs\sdk\wxpropgrid\src\xh_propgrid.o .objs\sdk\wxpropgrid\src\advprops.o   -o devel\wxpropgrid.dll -mthreads -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -s -flto -fuse-linker-plugin -Wl,--allow-multiple-definition -Wl,--enable-auto-image-base -Wl,--add-stdcall-alias -Wl,--enable-auto-import  -lwxmsw28u
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x1913): undefined reference to `_imp___ZTV17wxStringTokenizer.local.832'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x1aeb): undefined reference to `_imp___ZTV15wxDirDialogBase.local.831'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x2658): undefined reference to `_imp___ZTV18wxDataObjectSimple.local.823'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x308b): undefined reference to `_imp___ZTV17wxStringTokenizer.local.832'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x3251): undefined reference to `_imp___ZTV15wxDirDialogBase.local.831'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x4ef4): undefined reference to `_imp___ZTV18wxBitmapButtonBase.local.822'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x4ff2): undefined reference to `_imp___ZTV18wxBitmapButtonBase.local.822'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x5c8f): undefined reference to `_imp___ZTV12wxRegionBase.local.837'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x5cdf): undefined reference to `_imp___ZTV12wxRegionBase.local.837'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x5d25): undefined reference to `_imp___ZTV11wxBrushBase.local.835'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x5d75): undefined reference to `_imp___ZTV11wxBrushBase.local.835'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x5f33): undefined reference to `_imp___ZTV15wxHashTableBase.local.795'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x5f6f): undefined reference to `_imp___ZTV15wxHashTableBase.local.795'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x6859): undefined reference to `_imp___ZTV17wxMBConvUTF16Base.local.829'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x6887): undefined reference to `_imp___ZTV17wxMBConvUTF16Base.local.829'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x68ab): undefined reference to `_imp___ZTV17wxMBConvUTF32Base.local.828'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x68d9): undefined reference to `_imp___ZTV17wxMBConvUTF32Base.local.828'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x6c8f): undefined reference to `_imp___ZTV18wxDataObjectSimple.local.823'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x6cbd): undefined reference to `_imp___ZTV18wxDataObjectSimple.local.823'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x6f79): undefined reference to `_imp___ZTV12wxObjectList.local.816'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x6fa7): undefined reference to `_imp___ZTV12wxObjectList.local.816'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x6fcb): undefined reference to `_imp___ZTV12wxWindowList.local.807'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x6ff9): undefined reference to `_imp___ZTV12wxWindowList.local.807'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x74d5): undefined reference to `_imp___ZTV16wxStaticLineBase.local.775'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x74f9): undefined reference to `_imp___ZTV16wxStaticLineBase.local.775'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7527): undefined reference to `_imp___ZTV12wxButtonBase.local.804'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7555): undefined reference to `_imp___ZTV12wxButtonBase.local.804'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7579): undefined reference to `_imp___ZTV16wxStaticTextBase.local.801'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x75a7): undefined reference to `_imp___ZTV16wxStaticTextBase.local.801'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x75cb): undefined reference to `_imp___ZTV15wxStaticBoxBase.local.800'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x75f9): undefined reference to `_imp___ZTV15wxStaticBoxBase.local.800'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x761d): undefined reference to `_imp___ZTV16wxSpinButtonBase.local.798'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x764b): undefined reference to `_imp___ZTV16wxSpinButtonBase.local.798'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x766f): undefined reference to `_imp___ZTV20wxDatePickerCtrlBase.local.797'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x769d): undefined reference to `_imp___ZTV20wxDatePickerCtrlBase.local.797'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7d4d): undefined reference to `_imp___ZTV17wxGDIImageRefData.local.791'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7d5b): undefined reference to `_imp___ZTV12wxGDIRefData.local.790'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7d69): undefined reference to `_imp___ZTV15wxObjectRefData.local.787'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7d8b): undefined reference to `_imp___ZTV12wxGDIRefData.local.790'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7d99): undefined reference to `_imp___ZTV15wxObjectRefData.local.787'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7dbb): undefined reference to `_imp___ZTV15wxObjectRefData.local.787'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x7ddd): undefined reference to `_imp___ZTV14wxMemoryDCBase.local.793'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x822a): undefined reference to `_imp___ZTV14wxMemoryDCBase.local.793'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x859a): undefined reference to `_imp___ZTV17wxGDIImageRefData.local.791'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x85a9): undefined reference to `_imp___ZTV12wxGDIRefData.local.790'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x85b8): undefined reference to `_imp___ZTV15wxObjectRefData.local.787'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x85c8): undefined reference to `_imp___ZTV12wxGDIRefData.local.790'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x85d7): undefined reference to `_imp___ZTV15wxObjectRefData.local.787'
F:\Temp\ccOvkJMp.ltrans0.ltrans.o:ccOvkJMp.ltrans0.o:(.text+0x860e): undefined reference to `_imp___ZTV15wxObjectRefData.local.787'
F:\Temp\ccOvkJMp.ltrans1.ltrans.o:ccOvkJMp.ltrans1.o:(.text+0xea7): undefined reference to `_imp___ZTV17wxStringTokenizer.local.832' 

--------------------------------------------------------------------------------

But either .objs\sdk\wxpropgrid\src\*.o or libwxmsw28u.a don't have any symbols like "*****.local.****", the libwxmsw28u.a only have the symbols like "_imp___ZTV17wxStringTokenizer".

I don't know how the "*****.local.****" symbols come out?
It's a gcc lto plugin bug or ld bug?
Comment 1 Richard Biener 2011-07-26 09:25:00 UTC
It sounds like a linker bug.  Please try without fancy linker options like
--as-needed.
Comment 2 xunxun 2011-07-26 09:32:14 UTC
(In reply to comment #1)
> It sounds like a linker bug.  Please try without fancy linker options like
> --as-needed.

I remove "-Wl,-O1 -Wl,--sort-common -Wl,--as-needed", and it also has the problem.

ps: other linker option like "-Wl,--enable-auto-image-base -Wl,--add-stdcall-alias -Wl,--enable-auto-import" is Code::Blocks's default option.
Comment 3 xunxun 2011-07-27 17:22:39 UTC
I found that if I add the option "-flto-partition=none", the problem will disappear.

As is :

---------------------------------------------------------------------------------
g++.exe -shared  -Wl,--out-implib=devel\libwxpropgrid.a -Wl,--dll
-Lbase\tinyxml -LE:\MyPack\3rdLib\GUI\wxWidgets-2.8.12\lib\gcc_dll 
.objs\sdk\wxpropgrid\src\editors.o .objs\sdk\wxpropgrid\src\extras.o
.objs\sdk\wxpropgrid\src\manager.o .objs\sdk\wxpropgrid\src\odcombo.o
.objs\sdk\wxpropgrid\src\propgrid.o .objs\sdk\wxpropgrid\src\props.o
.objs\sdk\wxpropgrid\src\xh_propgrid.o .objs\sdk\wxpropgrid\src\advprops.o   -o
devel\wxpropgrid.dll -mthreads -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -s
-flto -fuse-linker-plugin -Wl,--allow-multiple-definition
-Wl,--enable-auto-image-base -Wl,--add-stdcall-alias -Wl,--enable-auto-import 
-lwxmsw28u -flto-partition=none
Creating library file: devel\libwxpropgrid.a
---------------------------------------------------------------------------------

Why?

Does the "-flto-partition=balanced" have some problems?
Comment 4 Matt Hargett 2011-08-18 19:01:29 UTC
When building scummvm with gcc 4.6.1, I had a bunch of multiple definition linker errors that also went away when adding -flto-partition=none . Here are the errors I had before said workaround:

$ gcc --version
gcc-4.6.real (Ubuntu/Linaro 4.6.1-7ubuntu1) 4.6.1

$ CFLAGS="-Ofast -flto" CXXFLAGS="-Ofast -flto" LDFLAGS="-flto=8 -fuse-linker-plugin -fwhole-program" ./configure

[...]

$ make -j9

[...]

    LINK     scummvm
cup_player_he.o (symbol from plugin): warning: memset used with constant zero length parameter; this could be due to transposed parameters
/tmp/ccMxgdJj.ltrans20.ltrans.o:(.rodata+0x1afa0): multiple definition of `_ZTVN5Scumm9ScummFileE.local.7841'
/tmp/ccMxgdJj.ltrans0.ltrans.o:(.rodata+0xc320): first defined here
/tmp/ccMxgdJj.ltrans20.ltrans.o:(.rodata+0x1b080): multiple definition of `_ZTTN5Scumm9ScummFileE.local.7842'
/tmp/ccMxgdJj.ltrans0.ltrans.o:(.rodata+0xc2a0): first defined here
/tmp/ccMxgdJj.ltrans20.ltrans.o:(.rodata+0x23780): multiple definition of `_ZTVN6Common16MemoryReadStreamE.local.9080'
/tmp/ccMxgdJj.ltrans5.ltrans.o:(.rodata+0x6440): first defined here
/tmp/ccMxgdJj.ltrans20.ltrans.o:(.rodata+0x23840): multiple definition of `_ZTTN6Common16MemoryReadStreamE.local.9093'
/tmp/ccMxgdJj.ltrans5.ltrans.o:(.rodata+0x6400): first defined here
collect2: ld returned 1 exit status
make: *** [scummvm] Error 1



Let me know if you want a tarball of this source tree attached; downloading the latest scummvm source tarball should give the same results.
Comment 5 xunxun 2011-08-18 20:24:00 UTC
(In reply to comment #4)
I also report to binutils bugzilla:
http://sourceware.org/bugzilla/show_bug.cgi?id=13031

But no one reply. :(
Comment 6 xunxun 2011-08-21 15:28:43 UTC
I update to gcc 4.6.2 (20110819) and binutils 2.21.53.20110820, and it also has the problem.
Comment 7 Richard Biener 2012-05-07 12:40:08 UTC
Can you see if GCC 4.7.0 improves the situation?
Comment 8 xunxun 2012-05-07 13:44:47 UTC
GCC4.7 also has the problem now:

-----------------------------------------------------------------------------
g++.exe -shared  -Wl,--out-implib=devel\libwxpropgrid.a -Wl,--dll -Lbase\tinyxml -LF:\MyProject\GUI\wxWidgets\WX_2_8_BRANCH\lib\gcc_dll  .objs\sdk\wxpropgrid\src\editors.o .objs\sdk\wxpropgrid\src\extras.o .objs\sdk\wxpropgrid\src\manager.o .objs\sdk\wxpropgrid\src\odcombo.o .objs\sdk\wxpropgrid\src\propgrid.o .objs\sdk\wxpropgrid\src\props.o .objs\sdk\wxpropgrid\src\xh_propgrid.o .objs\sdk\wxpropgrid\src\advprops.o   -o devel\wxpropgrid.dll -flto -fuse-linker-plugin -Wl,--enable-auto-image-base -Wl,--add-stdcall-alias -Wl,--enable-auto-import -Wl,--no-undefined  -lwxmsw28u 
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x68): undefined reference to `__imp___ZTV18wxDataObjectSimple.local.891'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x94): undefined reference to `__imp___ZTV18wxDataObjectSimple.local.891'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x127): undefined reference to `__imp___ZTV18wxBitmapButtonBase.local.890'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x21b): undefined reference to `__imp___ZTV18wxBitmapButtonBase.local.890'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x332): undefined reference to `__imp___ZTV16wxStaticTextBase.local.886'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x35e): undefined reference to `__imp___ZTV16wxStaticTextBase.local.886'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x466): undefined reference to `__imp___ZTV15wxStaticBoxBase.local.885'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x492): undefined reference to `__imp___ZTV15wxStaticBoxBase.local.885'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x4c2): undefined reference to `__imp___ZTV15wxDirDialogBase.local.896'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x596): undefined reference to `__imp___ZTV15wxDirDialogBase.local.896'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x820): undefined reference to `__imp___ZTV16wxSpinButtonBase.local.883'
F:\Temp\ccUseSDa.ltrans5.ltrans.o:ccUseSDa.ltrans5.o:(.text+0x84c): undefined reference to `__imp___ZTV16wxSpinButtonBase.local.883'
-----------------------------------------------------------------------------

If you need me provide more information, I will do.
Comment 9 xunxun 2012-05-07 13:46:30 UTC
Also add -flto-partition=none to linker option can solve the issue.
Comment 10 Richard Biener 2012-05-07 13:55:27 UTC
These are all references to virtual tables taken local.  Maybe Honza has an idea,
but unfortunately we all have no access to a windows environment to check for
specialities there.
Comment 11 xunxun 2012-05-07 13:59:49 UTC
Also add -flto-partition=none to linker option can solve the issue.(In reply to comment #10)
> These are all references to virtual tables taken local.  Maybe Honza has an
> idea,
> but unfortunately we all have no access to a windows environment to check for
> specialities there.

As the thread http://forums.codeblocks.org/index.php/topic,16210.0.html said,

Linux also has the problem.