How to speed up g++ compile time (when using a lot of templates)

后端 未结 10 1187
悲&欢浪女
悲&欢浪女 2020-12-22 18:46

This question is perhaps somehow odd, but how can I speed up g++ compile time? My C++ code heavily uses boost and templates. I already moved as much as possible out of the h

10条回答
  •  伪装坚强ぢ
    2020-12-22 19:33

    If you're doing a lot of recompilation, ccache might help. It doesn't actually speed up the compilation, but it will give you a cached result if you happen to do a useless recompilation for some reason. It might give an impression of tackling the wrong problem, but sometimes the rebuilding rules are so complicated that you actually do end up with the same compilation step during a new build.

    Additional idea: if your code compiles with clang, use it instead. It's usually faster than gcc.

提交回复
热议问题