Is profile guided optimization possible with shared libraries in gcc?
I recently rolled out a new Toolchain on Linux, with gcc 4.5.0 and binutils 2.20 with gold. Now I was curious about this new thing PGO. While it's clear how it works with executables, I've not been able to find an answer on shared libraries. I found two unanswered posts on the gcc mailing list via google, that's all.
So here's what I tried: As long as I don't flag -fprofile-generate everything is well and my .so is dlopen()'ed by the main program and works flawlessly. When compiled and linked with -fprofile-generate the library gets loaded, everything works, but when I end the main program I get a sigsegv with coredump.
I fed the corefile to gdb and got this:
#0 0x00000000 in ?? ()
No symbol table info available.
#1 0x1f32bc2f in ?? ()
No symbol table info available.
Backtrace stopped: previous f开发者_开发知识库rame inner to this frame (corrupt stack?)
And of course no .cdda files are saved.
Any ideas?
Philipp
I build a shared library with PGO.
What I do is to build a "profile" directory with all the .o files with profile-generate. Then I link those into a shared library. Then I do a profiling run with the library linked to an executable also built with profile-generate.
After that I build a "release" directory with all the .o files built with profile-use, link those into a shared library and I have a shared library built with PGO.
精彩评论