代码之家  ›  专栏  ›  技术社区  ›  Anonymous

如何有选择地使用ccache?

  •  18
  • Anonymous  · 技术社区  · 16 年前

    我必须编译一个应用程序C++的多个版本,我认为使用CACHACE来加快进程。

    ccache howtos有一些示例,建议创建名为gcc、g++等的符号链接,并确保它们出现在原始gcc二进制文件之前的PATH中,因此使用ccache。

    对于单个源代码文件的编译,我可以手动调用ccache而不是gcc就可以了,但是我必须处理一个复杂的应用程序,它使用自动构建系统来处理多个源代码文件。

    4 回复  |  直到 16 年前
        1
  •  25
  •   mimoralea    13 年前

    要绕过ccache:

    export CCACHE_DISABLE=1
    

    更多信息:

    man ccache
    

            If you set the environment variable CCACHE_DISABLE then ccache will just call the real
           compiler, bypassing the cache completely.
    

    ...

        2
  •  3
  •   James    16 年前

    什么操作系统?Linux系统?大多数ccache的打包版本已经将这些符号链接放入一个目录中,例如在我的Fedora机器上,它们位于/usr/lib64/ccache中。

    所以你可以这么做

    PATH=/usr/lib64/ccache:${PATH} make
    

    大多数软件包还在/etc/profile.d/中安装一个文件,通过将其添加到上面的路径中,可以自动启用ccache。

    如果你的系统是这样的话,就设置 CCACHE_DISABLE=1 (参见 man ccache 更多信息)在您的环境中禁用ccache-ccache仍然会运行,但只会调用真正的编译器。

        3
  •  2
  •   Joel Rosdahl    14 年前

    创建符号链接的另一种方法是显式地使用 ccache gcc 作为C编译器和 ccache g++ 作为C++编译器。例如,如果Makefile使用变量 CC 和 CXX 要指定编译器,可以使用 make CC="ccache gcc" CXX="ccache g++" 或者在配置时设置( ./configure CC="ccache gcc" CXX="ccache g++" ).

        4
  •  2
  •   Pius Raeder    8 年前

    我偶然发现了很多次。对我来说,最好的解决办法是:

    export CCACHE_RECACHE=1;
    

    Corrupt object files
       It should be noted that ccache is susceptible to general storage problems. If a bad object file sneaks into
       the cache for some reason, it will of course stay bad. Some possible reasons for erroneous object files are
       bad hardware (disk drive, disk controller, memory, etc), buggy drivers or file systems, a bad prefix_command
       or compiler wrapper. If this happens, the easiest way of fixing it is this:
    
        1. Build so that the bad object file ends up in the build tree.
    
        2. Remove the bad object file from the build tree.
    
        3. Rebuild with CCACHE_RECACHE set.