← 返回

Enabling CCACHE for Building Long-time-compiling Package

1. What is CCACHE

CCACHE helps avoid repeated recompilation for the same C and C++ object files by fetching result from the cache directory.

2. Packages for OS

  • name
    dev-util/ccache
  • Installation
    emerge -avt dev-util/ccache

3. Configuration for CCACHE

  • FILE /etc/portage/env/ccache.conf; /etc/ccache.conf is fine, but not recommended.

    FEATURES="ccache"
    CCACHE_DIR="/var/cache/ccache"
    
  • FILE /var/cache/ccache/ccache.conf

# Maximum cache size to maintain
max_size = 100.0G

# Allow others to run 'ebuild' and share the cache.
umask = 002

hash_dir = false
compiler_check = %compiler% -dumpversion

# I expect 1.5M files. 300 files per directory.
cache_dir_levels = 3

log_file = syslog

# Enabling compression and setting compression level for ccache.
compression = true
compression_level = 1

Whole Configuration

4. Enabling CCACHE for package specified

  • FILE /etc/portage/package.env/firefox

    www-client/firefox ccache.conf
    

5. Commands

  • Refresh cache

    CACHE_RECACHE=yes emerge -av1 --oneshot cat/pkg
    
  • Shows cache statistics

    CACHE_DIR=/var/cache/ccache/ ccache -s
    
Cacheable calls:   2224 / 2480 (89.68%)
  Hits:                       0 / 2224 ( 0.00%)
    Direct:                  0
    Preprocessed:       0
  Misses:              2224 / 2224 (100.0%)
Uncacheable calls: 256 / 2480 (10.32%)
Local storage:
  Cache size (GB):   0.1 /  5.0 ( 2.32%)
  Hits:                       0 / 2224 ( 0.00%)
  Misses:               2224 / 2224 (100.0%)
  • Drops all caches

    CACHE_DIR=/var/cache/ccache/ ccache -C
    

Related Links

CCACHE /etc/portage/package.env

Comments

Loading comments...

Leave a comment