http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45375
--- Comment #75 from Markus Trippelsdorf <markus at trippelsdorf dot de> 2011-04-08 06:52:34 UTC --- (In reply to comment #74) > Interesting. -O3 makes no difference for me. I will look into your dumps if I > can spot something useful. > ... > If GCC fail to link even such a simple program as elfhack is, something pretty > fundamental must go wrong. Perhaps it is linker bug. I had problems with > older > versions of gold. The failure only happens with -flto. And the reason is that: c++ -o host_elf.o -c -fno-rtti -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-variadic-macros -Werror=return-type -Wno-long-long -march=native -fpermissive -flto=4 -fuse-linker-plugin -fno-strict-aliasing -fshort-wchar -pthread -pipe -fexceptions -DNDEBUG -DTRIMMED -Os -I/var/tmp/mozilla-central/build/unix/elfhack -I. -I../../../dist/include -I../../../dist/include/nsprpub -I/usr/include/nspr -I/usr/include/nss -I/usr/include/nspr /var/tmp/mozilla-central/build/unix/elfhack/elf.cpp apparently only compiles correctly in the -Os case. All other optimization switches (-O(0..3) or without -O) lead to the eventual link failure above. And it happens with both gnu-ld and gold (2.21.51.20110402).