Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In many contexts, one should rarely pass -O2/-O3. A project that is built thousands of times during development may only be run on intensive workloads (where -O2 performance is actually a necessity) a handful of times by comparison. A dev build can usually be -O0, which can dramatically improve compilation time.



It depends. O0 turns off a few trimming optimizations and could potentially causes more information (code or DWARF) to be included in the objects, which may eventually slow down the compilation. In our large code base, we found that -O1 works best in terms of compilation speed.


Yeah, -O1 is usually a good choice. I get the occasional <value optimized out> while debugging, well I add another logging statement and rerun.


There doesn't seem to be a significant difference between -O0 and -O2/-O3 compile times.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: