简体   繁体   English

缓存make / g ++的头文件

[英]Cache header files for make/g++

I am working on a large C++ code base and I want to speed up its compilation times. 我正在使用大型C ++代码库,但我想加快其编译时间。 One thing I know is that all of my library includes are on a network drive which slows down things a lot. 我知道的一件事是,我的所有库都包含在网络驱动器上,这会大大降低速度。 If I can get make or something else to automatically cache them, either in /tmp, or to a ramdisk, I expect that to improve the compile times for me quite a bit. 如果我可以在/ tmp或ramdisk中获得make或其他可以自动缓存它们的东西,我希望可以大大缩短编译时间。 Is there a way to do that? 有没有办法做到这一点? Of course I can copy them manually and set up a sync job but then every developer will have to do that on every box they ever compile so I am looking for an automated solution. 当然,我可以手动复制它们并设置同步作业,但是每个开发人员都必须在他们编译的每个框上执行此操作,因此我正在寻找一种自动化解决方案。

Thanks! 谢谢!

Of course. 当然。 There are lots and lots of ways. 有很多方法。 You can just have a make rule that copies things then have people run make copylocal or whatever. 您只需制定一条make规则,即先复制内容,然后让人们运行make copylocal或其他命令。 This is fast but people have to remember to do it, and if the libraries change a lot this could be annoying. 这很快,但是人们必须记住要这样做,而且如果库发生很大变化,这可能会很烦人。 You can make a rule that copies things then put it as a prerequisite to some other target so it's done on every build, first. 您可以制定一条规则来复制内容,然后将其作为其他目标的先决条件,以便首先在每个构建中完成。 This will take longer: will the copy step plus using local copies take longer total time than just using the remote copies? 这将花费更长的时间:复制步骤加上使用本地副本会比仅使用远程副本花费更长的时间吗? Who knows? 谁知道?

You could also use a tool like ccache to locally cache the results of the compilation, rather than copying the library headers. 您还可以使用ccache之类的工具在本地缓存编译结果 ,而不是复制库头。 This will give you a lot more savings for a typical small incremental build and it's easily integrated into the build system, but it will slightly slow down "rebuild the world" steps to cache the objects. 对于典型的小型增量构建,这将为您节省更多,并且可以轻松地集成到构建系统中,但是会稍微减慢“重建世界”步骤来缓存对象。

Etc. Your question is too open-ended to be easily answerable. 等等。您的问题过于开放,难以回答。

Avoid using network file systems for code. 避免将网络文件系统用于代码。 Use a version control system like git . 使用git之类的版本控制系统

You might also consider using ccache . 您可能还考虑使用ccache

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM