gcc - Is C compiler able to optimize across object file? -


i'm considering between header-only vs. header&source design. i'm not sure if header&source allows compiler optimize across object files , across linkage ? such inlining optimization ?

header files , source files typically compiled single translation unit (since headers included in source files). so, won't issue (unless have peculiar environment headers compiled separately).

gcc support optimizations across different translation units. see link time optimization.

see -flto option's documentation details:

-flto[=n]

this option runs standard link-time optimizer. when invoked source code, generates gimple (one of gcc's internal representations) , writes special elf sections in object file. when object files linked together, function bodies read these elf sections , instantiated if had been part of same translation unit. use link-time optimizer, -flto , optimization options should specified @ compile time , during final link. recommended compile files participating in same link same options , specify options @ link time.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -