Bug 13031 - 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: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-26 10:53 UTC by xunxun
Modified: 2011-08-21 15:29 UTC (History)
1 user (show)

See Also:
Host: i686-pc-mingw32
Target: i686-pc-mingw32
Build: i686-pc-mingw32
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description xunxun 2011-07-26 10:53:04 UTC
Hi, all

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?

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.

see gcc bugzilla:  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49844

-- 
Best Regards,
PcX
Comment 1 xunxun 2011-07-27 17:28:18 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 2 xunxun 2011-08-21 15:29:11 UTC
I update to gcc 4.6.2 (20110819) and binutils 2.21.53.20110820, and it also has the problem.