summaryrefslogtreecommitdiff
path: root/src/Config.cpp
Commit message (Collapse)AuthorAgeFilesLines
* fix: Make output of "ccache -k max_size" parsableJoel Rosdahl2023-04-171-8/+9
|
* chore: Fix typosJoel Rosdahl2023-03-111-2/+2
|
* refactor: Use util::BitSet for core::SloppinessJoel Rosdahl2023-03-051-26/+26
|
* feat: Improve cache size presentation and specificationJoel Rosdahl2023-03-041-5/+9
| | | | | | | | | | | | | | | | | | Aligned how cache size is presented (in "ccache --show-stats", "ccache --show-compression", "ccache --recompress", debug logs, etc.) and specified (in configuration files, "ccache --max-size" and "ccache --trim-max-size"). The size units are now formatted according to the type of size unit prefix used for the max_size/CCACHE_MAXSIZE setting: a decimal size unit prefix (k/M/G/T with or without B for bytes) in max_size means using decimal size unit prefix for presented sizes, and similar for binary size unit prefixes (Ki/Mi/Gi/Ti with or without B for bytes). If no unit is specified, GiB is assumed, . For example, "ccache -M 10" means 10 GiB. Also aligned how cache sizes are calculated. Now all sizes are computed as "apparent size", i.e., rounded up to the disk block size. This means that the cache size in "--show-stats" and the sizes presented in "--show-compression" and "--recompress" now match.
* refactor: Move Util::parse_size to utilJoel Rosdahl2023-03-041-1/+1
|
* refactor: Move Util::format_{human,parsable}_* to utilJoel Rosdahl2023-03-041-1/+1
|
* feat: Improve error message when failing to parse command line configJoel Rosdahl2023-03-041-1/+6
|
* chore: Remove now superfluous "this->" in lambdaJoel Rosdahl2023-03-041-1/+1
| | | | It was needed for compatibility with older compilers.
* feat: Add support for setting per-compilation config on command lineJoel Rosdahl2023-02-201-4/+40
| | | | Closes #1035.
* feat: Improve automatic cache cleanup mechanismJoel Rosdahl2023-01-171-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The cache cleanup mechanism has worked essentially the same ever since ccache was initially created in 2002: - The total number and size of all files in one of the 16 subdirectories (AKA level 1) are kept in the stats file in said subdirectory. - On a cache miss, the new compilation result file is written (based on the first digits of the hash) to a subdirectory of one of those 16 subdirectories, and the stats file is updated accordingly. - Automatic cleanup is triggered if the size of the level 1 subdirectory becomes larger than max_size / 16. - ccache then lists all files in the subdirectory recursively, stats them to check their size and mtime, sorts the file list on mtime and deletes the 20% oldest files. Some problems with the approach described above: - (A) If several concurrent ccache invocations result in a cache miss and write their results to the same subdirectory then all of them will start cleaning up the same subdirectory simultaneously, doing unnecessary work. - (B) The ccache invocation that resulted in a cache miss will perform cleanup and then exit, which means that an arbitrary ccache process that happens to trigger cleanup will take a long time to finish. - (C) Listing all files in a subdirectory of a large cache can be quite slow. - (D) stat-ing all files in a subdirectory of a large cache can be quite slow. - (E) Deleting many files can be quite slow. - (F) Since a cleanup by default removes 20% of the files in a subdirectory, the actual cache size will (once the cache limit is reached) on average hover around 90% of the configured maximum size, which can be confusing. This commit solves or improves on all of the listed problems: - Before starting automatic cleanup, a global "auto cleanup" lock is acquired (non-blocking) so that at most one process is performing cleanup at a time. This solves the potential "cache cleanup stampede" described in (A). - Automatic cleanup is now performed in just one of the 256 level 2 directories. This means that a single cleanup on average will be 16 times faster than before. This improves on (B), (C), (D) and (E) since the cleanup made by a single compilation will not have to access a large part of the cache. On the other hand, cleanups will be triggered 16 times more often, but the cleanup duty will be more evenly spread out during a build. - The total cache size is calculated and compared with the configured maximum size before starting automatic cleanup. This, in combination with performing cleanup on level 2, means that the actual cache size will stay very close to the maximum size instead of about 90%. This solves (F). The limit_multiple configuration option has been removed since it is no longer used. Closes #417.
* fix: Use $XDG_RUNTIME_DIR/ccache-tmp as the default temporary directoryJoel Rosdahl2022-11-131-3/+4
| | | | See discussion in #1221.
* fix: Do not create /run directory on systems that don't have it (#1221)Oleg Sidorkin2022-11-131-3/+5
|
* fix: Fix parsing of sloppiness with trailing delimiterJoel Rosdahl2022-11-031-7/+4
|
* feat: Support depend mode for MSVC (#992)Orgad Shaneh2022-10-121-0/+10
| | | | | | | | | Based on -showIncludes, which prints included files on stdout with a certain text prefix. Otherwise pretty similar to depend mode handling for GCC. This makes MSVC building way faster. Co-authored-by: Luboš Luňák <l.lunak@centrum.cz>
* Revert "feat: Support auto depend mode for MSVC without /showIncludes (#1158)"Joel Rosdahl2022-10-051-10/+0
| | | | | | This reverts commit 8b65880b5ad817156b58c58b5133aafc99b0a264. See <https://github.com/ccache/ccache/pull/1158#issuecomment-1268748557>.
* feat: Support auto depend mode for MSVC without /showIncludes (#1158)Orgad Shaneh2022-10-051-0/+10
| | | Co-authored-by: Luboš Luňák <l.lunak@centrum.cz>
* feat: Add sloppiness for -frandom-seed (#1168)Raihaan Shouhell2022-10-041-0/+5
|
* feat: Implement "remote only" modeJoel Rosdahl2022-09-281-0/+10
| | | | Closes #1010.
* chore: Rename primary/secondary storage to local/remote storageJoel Rosdahl2022-09-271-57/+71
| | | | | | | | | | | | | | | | | There is a feature request to be able not to use a local cache at all, only a network cache. With such a feature, the names "primary storage" and "secondary storage" make less sense since ccache would be operating in "secondary only" mode, but then that storage would of course become the primary (and only). Let's rename "primary storage" to "local storage" and "secondary storage" to "remote storage" – operating in "remote only" mode then makes sense. One of the original motivations to call networked storage "secondary" is that the file storage can be used for local file systems as well, making such storage "not quite remote", but in practice I guess the file storage backend used primarily for network file systems.
* chore: Rename primary/secondary config to config/system configJoel Rosdahl2022-09-271-35/+34
|
* chore: Simplify cache entry reading and writingJoel Rosdahl2022-09-211-1/+1
| | | | | | | | | | | | | | | | Cache entries are now fully read into memory before (de)compressing, checksumming and parsing, instead of streaming data like before. While this increases memory usage when working with large object files, it also simplifies the code a lot. Another motivation for this change is that cache entry data is not streamed from secondary storage anyway, and it makes sense to keep the architecture simple and similar for primary and secondary storage code paths. The cache entry format has modified so that the checksum covers the potentially compressed payload (plus the header), not the uncompressed payload (plus the header) like before. The checksum is now also stored in an uncompressed epilogue. Since the cache entry format has been changed, the input hash has been changed as well.
* chore: Tweak formattingJoel Rosdahl2022-08-241-5/+4
|
* refactor: Use FMT macro to format exception messagesJoel Rosdahl2022-08-241-17/+18
| | | | | Using the FMT macro explicitly makes invalid format message constructions compile-time errors instead of run-time errors.
* refactor: Use util::{read_fd,read_file,write_file} functionsJoel Rosdahl2022-08-151-4/+5
|
* feat: Move Windows config and cache to LOCALAPPDATA (#1124)Rafael Kitover2022-08-011-15/+53
|
* feat: Add support for Intel compiler on Windows (#1100)Daniel Richtmann2022-06-291-0/+3
|
* refactor: Use structured binding declarationsJoel Rosdahl2022-06-191-9/+9
|
* refactor: Use std::clampJoel Rosdahl2022-06-191-1/+1
|
* fix: Clean up temporary dir if it's left the defaultJoel Rosdahl2022-06-181-2/+2
| | | | | | | | | Cleanup of the temporary directory is done if it is $CCACHE_DIR/tmp, which used to be the default until [1] where the default was changed to /run/user/$UID/ccache-tmp. Improve this so that cleanup happens if the temporary directory is equal to the default regardless of the default. [1]: 213d9883a0c3944749f8512eeb784d8572ad8d91
* chore: Replace nonstd::optional with std::optionalJoel Rosdahl2022-05-231-9/+6
|
* chore: Prepare for binary patching SYSCONFDIRJoel Rosdahl2022-05-141-1/+4
|
* refactor: Improve absolute path normalization functionsJoel Rosdahl2022-04-301-1/+1
| | | | | | | | | | | | | | | | | | The Util::normalize_absolute_path function only works on the syntactic level, i.e. the result may not actually resolve to the same filesystem entry (nor to any file system entry for that matter). It was meant to be used for paths that don’t necessarily exist yet, such as a future directory in which to write debug files. It may fail in edge cases with symlinks in the path in combination with .. segments. If the caller wants to ensure that the resulting path actually makes sense, it needs to check if the resulting path points to the same file entry as the original. To improve on this, Util::normalize_absolute_path has now been renamed to Util::normalize_abstract_absolute_path and there is a new Util::normalize_concrete_absolute_path function which returns the original path if the normalized result doesn't resolve to the same file system entry as the original path.
* fix: Only use /run/user/<UID>/ccache-tmp if writableJoel Rosdahl2022-04-031-1/+1
| | | | | | | | | | | | | The fix for #984 addressed a problem when /run/user/0 already exists and ccache is run with fakeroot. However, it didn’t handle the case when /run/user/0/ccache-tmp already exists, which will happen for instance if the real root user has run ccache at least once. Fix this by using access(2) to verify that the ccache-tmp directory is writable. Note: Can’t just check the mode bits of the directory since they appear OK since fakeroot fakes the UID. Fixes #1044.
* fix: Improve handling of .gcno filesJoel Rosdahl2022-04-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | When support for caching a compilation with coverage (producing a .gcno file), the commit[1] made sure to avoid rewriting the input path to relative with the motivation “also make sure to use the source file path, since this is in the notes”. However, this seems to be unnecessary since a relative input file path will be written as is to the .gcno, not the absolute path. This is the case for at least GCC 4.7+ and Clang 3.6+. Fix this by potentially converting the input path to relative even when generating coverage. When investigating the above issue, I noticed that GCC 9+ includes the current working directory (CWD) in the .gcno file. This means that we have include the CWD in the hash when compiling with -ftest-coverage/--coverage in order to replicate what the compiler would produce. Since this makes it impossible get cache hits when compiling in different directories, a new gcno_cwd sloppiness has been added for opting out of hashing the CWD, with the tradeoff of potentially getting an incorrect directory in the .gcno file. [1]: 02d3f078bd2495b8db2264ae0b2c692b4c5ba1bd Fixes #1032.
* refactor: Sort sloppiness parsing/generationJoel Rosdahl2022-04-011-28/+28
|
* fix: Fix clang-cl display name (#1003)Orgad Shaneh2022-02-031-1/+2
|
* style: Improve names related to clang-clJoel Rosdahl2022-02-031-2/+2
|
* feat: Add support for clang-cl (#993)Orgad Shaneh2022-02-031-0/+3
| | | Co-authored-by: Luboš Luňák <l.lunak@centrum.cz>
* feat: Make it possible to configure compiler type msvcJoel Rosdahl2022-01-231-0/+2
|
* refactor: Rename compiler type cl to msvcJoel Rosdahl2022-01-231-1/+1
|
* fix: Unconstify variable to allow automatic moveJoel Rosdahl2022-01-101-1/+1
| | | | As suggested by Clang-Tidy.
* fix: Check writability of /run/user/<UID>/ccache-tmp before usingJoel Rosdahl2022-01-061-6/+9
| | | | Closes #984.
* fix: Handle stdout from distcc-pump when used as a prefixJoel Rosdahl2021-12-121-3/+0
| | | | | | | | The compiler guessing doesn’t work if pump is used as a prefix/CCACHE_PREFIX, so let’s just not depend on such guesswork. Also, since the distcc-pump wrapper isn’t really a compiler type, it actually makes sense not to treat it as such.
* feat: Visual C/C++ compiler support (#506)Cristian Adam2021-11-151-0/+1
|
* feat: Add namespace supportJoel Rosdahl2021-11-081-0/+10
| | | | | | | | | | | If a namespace configured, the namespace string will be added to the hashed data for each compilation. This will make the associated cache entries logically separate from cache entries with other namespaces, but they will still share the same storage space. Cache entries can also be selectively removed from the primary cache with the command line option --evict-namespace, potentially in combination with --evict-older-than. Closes #870.
* refactor: Improve compatibility definition of DLLIMPORTJoel Rosdahl2021-09-071-6/+0
|
* fix: Always store configuration origin value (#928)Gregor Jasny2021-09-071-1/+4
|
* Fix build errors with clang on Windows (#924)Orgad Shaneh2021-09-011-0/+2
|
* feat: Add reshare config optionJoel Rosdahl2021-08-101-0/+10
| | | | | | Setting reshare (CCACHE_RESHARE) to true make ccache send results to secondary storage even for primary storage cache hits. The default is false.
* refactor: Use util::parse_doubleJoel Rosdahl2021-08-041-17/+2
|