Starting with version 4.5, GCC supports the -flto switch which enables Link Time Optimization (LTO). LTO can inline functions from separate object files.
There's a catch though. Because of the way that -flto
works, it'll only be of use for object files that were compiled using that switch. As I understand it, GCC implements LTO by placing a intermediate form of the source code into the object file - if that intermediate code isn't in the object file, the code in that object file won't be 'inlined'.
See Can the linker inline functions? for some additional details.