<div dir="ltr">As I understand it, clang currently has the -flto flag which activates some degree of whole program optimization. However, this requires clang to be presented with all the source files at the same time. This is easy enough to arrange in a greenfield project, but may be trickier with an existing program.<div><br></div><div>On Unix, C and C++ programs are usually compiled with makefiles (whether handwritten or auto generated), and these typically call the compiler on one source file at a time and then call the system linker only after compilation has proceeded to machine code object files. Thus, even with clang as a drop-in replacement for GCC, there is the challenge of obtaining exact compilation instructions from the makefile and then modifying these to allow clang to see all the files at once, no later than bitcode stage.</div><div><br></div><div>On Windows, it's common to have a Visual Studio project file that msbuild can use. This sometimes does call the compiler on multiple files at the same time; then there's the question of how to get clang-cl invoked with suitable options.</div><div><br></div><div>At least that's my thinking on this aspect of the problem so far; there are doubtless things I'm missing. What's currently being done in this area?</div></div>