有没有办法加速 C++ Solaris Sun Studio 12 中的编译时间?
由于我是在一个服务器机器(总共 32 或 64 个核心)上编译 C++ 代码,有没有办法调整编译器选项来加快编译时间?例如告诉编译器使用多线程编译独立的.cpp 文件。
Since I am compiling my C++ code on a very server box (32 or 64 cores in total), is there a way of tweaking compiler options to speed up the compilation times? E.g. to tell compiler to compile independent .cpp files using multiple threads.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Sun Studio 在 make 的
dmake
版本中包含并行构建支持。请参见 dmake 手册 了解详细信息。
Sun Studio includes parallel build support in the included
dmake
version of make.See the dmake manual for details.
这取决于您使用的工具链。
如果您使用的是 GNU Make,则将
-j 32
添加到您的 make 调用中,以告诉 Make 并行启动 32 个作业(例如)。只要确保您没有耗尽 RAM 并因此破坏交换文件即可。This depends on what toolchain you're using.
If you're using GNU Make, then add
-j 32
to your make invocation to tell Make to start 32 jobs (for example) in parallel. Just make sure that you're not exhausting RAM and thrashing your swap file as a result.使用像 Boost JAM 这样的东西,它可以为你做这种多线程处理——根据我的经验,它比多线程 make 效率更高。
Use something like Boost JAM which does this sort of multithreading for you - and from my experience much more efficiently than multi-threaded make.
Sun 的 C++ 编译器还有一个
-xjobs
选项,使编译器在内部分叉多个线程。为了提高效率,您可能必须将所有 .cc 文件传递给 CC 的单次调用。Sun's C++ compiler also has an
-xjobs
option that makes the compiler fork multiple threads internally. For this to be efficient you would probably have to pass all .cc files to a single invocation of CC.