3 ms·
While I'm not sure that was a consideration here, sometimes C compilers produce better machine code when they got access to more function definitions. Eg. Sqlit
by plq 4y ago
While I'm not sure that was a consideration here, sometimes C compilers produce better machine code when they got access to more function definitions. Eg. Sqlite recommends that embedders use the single ~10mb sqlite.c file[1] for both ease of use and performance reasons.
[1]: https://www.sqlite.org/amalgamation.html https://www.sqlite.org/amalgamation.html
- colordrops 4y agoSeems like something the compiler should take care of.
- fjfbsufhdvfy 4y agoIt can when you use LTO, but that tends to be very slow for large programs.
- plq 4y agoIt is slow. Our (C++) project's MSVC release build ends with a glorious 2-minute run of link.exe with lto (/LTCG /O2) and aggressive inlining (/Ob3) enabled. Limiting unit size in C++ helps with faster edit/compile/run cycles as well, which doesn't seem to be concern for C codebases in 21st century.
- anarazel 4y agoYou hit most of the same issues (and some additional ones) when compiling the same code within one translation unit...