Skip to main content

No project description provided

Project description

cltcache -- A python3 clang-tidy cache

A simple cache which can cache clang-tidy static code analysis results to speed up the build process in large messy codebases. cltcache is like ccache but for clang-tidy static code analysis results.

Usage

Install using pip

pip3 install cltcache

Prefix all of your clang-tidy calls with cltcache in your build system or configuration.

set(CMAKE_C_CLANG_TIDY "cltcache" "${CLANG_TIDY_PROGRAM}")
set(CMAKE_CXX_CLANG_TIDY "cltcache" "${CLANG_TIDY_PROGRAM}")
cmake -DCLANG_TIDY_PROGRAM="cltcache /usr/bin/clang-tidy" ..

Finally you have to manually manage your cache which is stored in ~/.cltcache. If you are using cltcache in CI you need to distribute the cache between builders. If you are using cltcache locally you will need to manually manage your cltcache because it will grow indefinately. Here is a useful command which should remove all cache entries older than 60 days:

find ~/.cltcache -mtime +60 | xargs rm

For reasonable clang-tidy usage, the cache should be so small, that you will not need to clean it until you upgrade your computer. Check the disk usage of the cache using this command:

du -hd0 ~/.cltcache

Why?

Static code analysis of C++ code can consume more time and power than compilation while producing a lot smaller output files, especially when no warnings and errors were generated. The output is also basically never consumed by a customer, which means it is not as important to ensure that the integrity of the cache is intact. For these reasons static code analysis should be is a much better match for caching than compilation is. Because clang-tidy is probably used in tons of CI-pipelines around the world, it should be possible to save tons of energy by caching the results.

How?

The cache key is generated by computing a sha256-hash of the gcc preprocessor results, the enabled clang-tidy checks and the clang-tidy version string.

graph LR;
    clang-tidy_args-->g++_preprocessor;
    clang-tidy_args-->clang-tidy_version;
    clang-tidy_args-->clang-tidy_enabled_checks;
    g++_preprocessor-->preprocessor_sha256;
    clang-tidy_version-->version_sha256;
    clang-tidy_enabled_checks-->enabled_checks_sha256;
    preprocessor_sha256-->sha256;
    version_sha256-->sha256;
    enabled_checks_sha256-->sha256;
    sha256-->cache_key;

Caveats

Integrity

cltcache assumes that identical preprocessor output, clang-tidy version and enabled checks will produce identical results, which is not a guarantee. One such case is if a result-filtered header is moved to a path where its warnings and errors are no longer filtered. If you are concerned about this, you should probably reconsider your priorities. Relying upon clang-tidy to the point where the its integrity is more important than the environment is rarely a sustainable strategy.

Ouptut order

The order of stdout and stderr is not preserved. The stdout of clang-tidy is printed first and the stderr is printed last.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cltcache-1.0.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

cltcache-1.0.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file cltcache-1.0.0.tar.gz.

File metadata

  • Download URL: cltcache-1.0.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.9

File hashes

Hashes for cltcache-1.0.0.tar.gz
Algorithm Hash digest
SHA256 da15aeadba4fe1fb1d6e0035375100e873ba8970b54c79a9610a733b13274875
MD5 85738710a881e29d5c2b804ae1df2d7a
BLAKE2b-256 dfbc302a06f74784dbbbe76a9edbe221d50c51ba91c784916c2183411a75ae79

See more details on using hashes here.

File details

Details for the file cltcache-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cltcache-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.9

File hashes

Hashes for cltcache-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f851a1ab9cbdd8788d1d1b288d76ff9c4e73e1b68eaecc5f9fb58c81316773c
MD5 dbcc30f572d74d8efc25d33b14a40a60
BLAKE2b-256 86c161be685af6a4c3129d8ff2f1bd506af14ac0864dcf3c8e0e23c66dbdb417

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page