如何在 Ubuntu 14.04 上安装 ccache 版本 3.2?

如何在 Ubuntu 14.04 上安装 ccache 版本 3.2?

当前最新版本缓存是 3.1.9,但是那个没有对 clang 提供适当的支持

我应该如何安装 ccache 3.2.x?

注意:如果可能的话,我更喜欢使用包管理,这样我以后就可以根据需要删除该包。

我在 /usr/bin/ccache 中有一个旧版本 3.1.9,其符号链接位于 /usr/lib/ccache。这些路径需要继续工作。

答案1

下载最新ccache版本缓存网站以获得更好的性能。

下载后,请按照以下步骤操作:

  1. 使用命令提取文件tar

    tar -xvf ccache-3.2.4.tar.bz2
    
  2. 进入ccache-3.2.4文件夹并运行以下命令:

    ./configure
    ./make
    sudo make install
    
  3. 在编辑器中打开~/.bashrc文件并在其末尾插入以下行:

    export CCACHE_DIR=/home/user_name/.ccache
    export CCACHE_TEMPDIR=/home/user_name/.ccache
    

    注意:填写user_name您的用户名。

  4. 保存.bashrc并按如下方式获取它:

    source ~/.bashrc
    
  5. 要检查 ccache 是否正常工作,请输入:ccache -s查看统计信息

答案2

从源头安装似乎有以下缺点:

  • 您无法稍后使用包管理器将其删除(可以使用 checkinstall 在一定程度上规避此问题)
  • 如果不指定 ./configure 的路径,它就不会转到上一个版本所在的位置
  • 最重要的一点:/usr/lib/ccache 中的链接将不会被创建

至少对我来说,最有效的解决方案是使用较新版本的 ubuntu Wily 中的更新包。这样做:

  1. 从以下位置下载软件包http://packages.ubuntu.com/wily/amd64/ccache/download(假设你使用的是 amd64 架构)
  2. 安装:sudo dpkg -i ccache_3.2.3-1_amd64.deb

一切都将按照我想要的方式运行:

$ ccache -V
ccache version 3.2.3

Copyright (C) 2002-2007 Andrew Tridgell
Copyright (C) 2009-2015 Joel Rosdahl

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
$ ls -trla /usr/lib/ccache
total 16
drwxr-xr-x 86 root root 12288 Jan 27 17:55 ..
lrwxrwxrwx  1 root root    16 Jan 27 17:55 x86_64-linux-gnu-gcc-4.8 -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 x86_64-linux-gnu-gcc -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 x86_64-linux-gnu-g++-4.8 -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 x86_64-linux-gnu-g++ -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 gcc-4.8 -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 gcc -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 g++-4.8 -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 g++ -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 cc -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 c99-gcc -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 c89-gcc -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 c++ -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 arm-none-eabi-gcc-4.8.2 -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 arm-none-eabi-gcc -> ../../bin/ccache
lrwxrwxrwx  1 root root    16 Jan 27 17:55 arm-none-eabi-g++ -> ../../bin/ccache
drwxr-xr-x  2 root root  4096 Jan 27 17:55 .
$ which ccache
/usr/bin/ccache
$ apt-cache policy ccache
ccache:
  Installed: 3.2.3-1
  Candidate: 3.2.3-1
  Version table:
 *** 3.2.3-1 0
        100 /var/lib/dpkg/status
     3.1.9-1 0
        500 http://fi.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
$

相关内容