summaryrefslogtreecommitdiff
path: root/src/hashutil.cpp
Commit message (Collapse)AuthorAgeFilesLines
* refactor: Improve InodeCache::get signatureJoel Rosdahl2023-03-071-3/+3
|
* refactor: Use util::BitSet for hash_source_code_fileJoel Rosdahl2023-03-071-38/+37
|
* refactor: Use util::BitSet for core::SloppinessJoel Rosdahl2023-03-051-3/+3
|
* fix: Fix edge case where a non-temporal identifier is misidentified (#1227)Erik Flodin2022-11-271-3/+3
| | | | | | | If a non-temporal identifier, that ends with a temporal macro, happens to be at the end of the buffer with the temporal suffix starting on the avx boundary, then it would be incorrectly classified as a temporal macro. This since the helper function lacks the context to see that the data before the match is something that invalidates the match.
* chore: Improve logging of file read failuresJoel Rosdahl2022-11-021-0/+1
|
* refactor: Use FMT macro to format exception messagesJoel Rosdahl2022-08-241-3/+3
| | | | | 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-14/+15
|
* fix: Hash time information on inode cache hitJoel Rosdahl2022-08-031-110/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As mentioned in discussion #1086: If the inode cache is enabled, hash_source_code_file will on an inode cache hit fail to hash time information if there are temporal macros in the code. This is because hash_source_code_string (called from hash_source_code_file via hash_source_code_file_nocache) on an inode cache miss adds time information to the hash in case one of those macros were found. However, on an inode cache hit the return value of hash_source_code_file will be correctly fetched from the cache, but the hash sum will only be updated with (the hash of) the include file and not the time information. The fix is to let the inode cache only cache the effects of hashing the file and checking for macros, not the hashing of time information since that's volatile. After the fix: - The new do_hash_file function performs file hashing and macro checking. The inode cache caches this step. - hash_source_code_file returns a Digest instead of adding data to a Hash. - hash_source_code_file calls do_hash_file and then potentially hashes time information. If there are no temporal macros the returned digest will be identical to the file hash, otherwise the returned digest will be of a hash of file content hash + time information. This also improves hashes that are stored in the direct mode manifest: Previously they were always the hash of the file content hash but now they are just the file content hash in the common case when there is no __DATE__ or __TIMESTAMP__ macro in the file.
* feat: Support masquerading as a compiler via copy or hard linkJoel Rosdahl2022-06-101-1/+1
| | | | | | | | Setting up ccache to masquerade as a compiler has always meant using symbolic links, but there is no technical reason why that has to be the case. This commit adds support for masquerading via a copy or hard link of the ccache executable as well. This is mostly useful on platforms or file systems where symbolic links are not supported.
* chore: Replace nonstd::string_view with std::string_viewJoel Rosdahl2022-05-231-9/+7
|
* fix: Make AVX2 code work also with MSVC (#963)Luboš Luňák2021-11-231-0/+8
|
* Convert Sloppiness enum to type-safe classJoel Rosdahl2021-07-221-3/+2
|
* Move exceptions.hpp to coreJoel Rosdahl2021-07-201-3/+4
|
* Remove redundant _utils suffix for util headersJoel Rosdahl2021-07-191-1/+1
|
* Move starts_with and ends_with to utilJoel Rosdahl2021-07-191-2/+2
|
* Move strip_whitespace to utilJoel Rosdahl2021-07-191-1/+3
|
* Remove system.hpp, including what’s needed insteadJoel Rosdahl2021-07-071-3/+10
| | | | This is the next step after a57f70eda32e99221de56f5499079b4f00dc2bc5.
* Improve handling of SOURCE_DATE_EPOCHJoel Rosdahl2021-02-011-1/+11
| | | | | | | | | | | | | | | | | | PR #755 (be1ed774) made it so that the value of SOURCE_DATE_EPOCH is ignored if time_macros sloppiness is set. A downside of this is naturally that the user has to set sloppiness if SOURCE_DATE_EPOCH is set in the environment. Insight: SOURCE_DATE_EPOCH actually only ever changes the result if the source code contains __DATE__. __TIME__ is not an issue since ccache disables the direct mode if __TIME__is present and the preprocessor mode will then see the actual expansion regardless of any SOURCE_DATE_EPOCH value. Finally, the __TIMESTAMP__ case is not applicable at all since it’s not affected by SOURCE_DATE_EPOCH. Therefore, make sure to only hash SOURCE_DATE_EPOCH if we find __DATE__. The user then does not have to set sloppiness to get direct mode hits for files that don’t contain __DATE__.
* Extract enums into separate headers (#764)Alexander Lanin2021-01-191-1/+1
|
* Detect errors in fmt::format format strings at compile timeJoel Rosdahl2020-10-231-2/+3
| | | | See also 4413d842e23c6fa52ec411951a4ab442f42227de.
* Detect errors in log strings at compile timeJoel Rosdahl2020-10-231-10/+9
| | | | | | | | | | | | | | | | | | | fmtlib can detect format string errors at compile time if (1) applying FMT_STRING to the format string literal and (2) compiling for C++14 or higher. Requirement 1 is implemented by introducing a LOG macro which applies FMT_STRING to the first argument and calls Logging::log (if logging is enabled). Also added are a companion LOG_RAW macro (since C++11 requires at least one argument for the “...” part in variadic macros) and a BULK_LOG macro which calls Logging::bulk_log (if logging is enabled). Requirement 2 is implemented by setting CMAKE_CXX_STANDARD to 14 for one CI build with a known C++14-capable compiler. We can’t set it to 14 by default since we still want the code to be buildable with C++11 compilers. This will catch errors such as the one fixed by PR #691.
* Use BLAKE3 machinery for detecting AVX2 support (#696)Erik Flodin2020-10-221-16/+3
| | | | | | | | | | | * Use BLAKE3 machinery for detecting AVX2 support Instead of relying on the sometimes broken __builtin_cpu_support. See discussion in #689. * Require GCC >= 5.0 to enable AVX2 support On e.g. GCC 4.8.5 the build fails with: error: ‘__m256i’ does not name a type
* Handle interrupted waitpid call properly in hash_command_outputJoel Rosdahl2020-10-051-2/+6
|
* Use ubuntu-18.04 instead of ubuntu-20.04 for Clang-TidyJoel Rosdahl2020-09-281-2/+2
| | | | | | | | | | | | | | | The ubuntu-20.04 VM has intermittent build errors that look like this: sudo apt-get install libzstd-dev clang-tidy [...] The following packages have unmet dependencies: clang-tidy : Depends: clang-tidy-10 (>= 10~) but it is not going to be installed E: Unable to correct problems, you have held broken packages. Clang-Tidy 9 also found “function ... has a definition with different parameter names” warnings that needed to be fixed as part of this. As discussed in #670.
* Extract stats_{read,write} and Statistic enum to Statistics namespaceJoel Rosdahl2020-09-141-1/+0
|
* Rename FatalError class to FatalJoel Rosdahl2020-08-221-2/+2
| | | | | This makes the naming more consistent with the other exception classes (Error and Failure).
* Use nullptr instead of NULLJoel Rosdahl2020-08-061-1/+1
|
* Replace fatal function with throwing FatalError exception explicitlyJoel Rosdahl2020-08-031-2/+2
| | | | | I think that this improves code readability since it’s more clear what the code flow is.
* Convert cc_log calls to Logging::logJoel Rosdahl2020-08-031-9/+8
|
* C++-ify logging routinesJoel Rosdahl2020-08-031-2/+4
| | | | | | | | | | | | | | | - Simplified and C++-ified logging code. - Added Logging::log and Logging::bulk_log functions corresponding to the old cc_log and cc_bulklog functions. The new functions pass their arguments to fmt::format. - Replacements: * init_log → Logging::init * cc_log → Logging::log * cc_bulklog → Logging::bulk_log * cc_log_argv → Logging::log plus Util::format_argv_for_logging * cc_dump_debug_log_buffer -> Logging::dump_log - A legacy cc_log implementation is still available so that logging can be converted gradually to the new functionality.
* Convert FATAL macro to a functionJoel Rosdahl2020-07-311-2/+2
|
* Add Util::localtime, abstracting localtime_rJoel Rosdahl2020-07-301-13/+10
|
* C++-ify hashutil functionsJoel Rosdahl2020-07-301-117/+109
|
* C++-ify is_precompiled_header and move to UtilJoel Rosdahl2020-07-291-3/+2
|
* Remove superfluous hash_from_int functionJoel Rosdahl2020-07-291-5/+0
|
* C++-ify win32argvtosJoel Rosdahl2020-07-291-6/+6
|
* C++-ify execute functionsJoel Rosdahl2020-07-291-2/+1
|
* Convert fatal() function to macro that forwards to fmt::formatJoel Rosdahl2020-07-281-2/+2
|
* Avoid some format/free usageJoel Rosdahl2020-07-171-18/+27
|
* Use Util::read_file instead of legacy read_file functionJoel Rosdahl2020-07-171-5/+6
|
* C++-ify struct hashJoel Rosdahl2020-07-091-35/+27
|
* Build InodeCache.cpp only when inode cache is supportedJoel Rosdahl2020-06-231-1/+4
|
* Fix bug in hash_binary_fileJoel Rosdahl2020-06-181-1/+1
| | | | Introduced in #577 (213d9883).
* Add Digest class, replacing struct digestJoel Rosdahl2020-06-141-8/+8
|
* Add inode cache for file hashes (#577)Olle Liljenzin2020-05-311-11/+99
| | | | | | | | | | | | | The inode cache is a process shared cache that maps from device, inode, size, mtime and ctime to saved hash results. The cache is stored persistently in a single file that is mapped into shared memory by running processes, allowing computed hash values to be reused both within and between builds. The chosen technical solution works for Linux and might work on other POSIX platforms, but is not meant to be supported on non-POSIX platforms such as Windows. Use 'ccache -o inode_cache=true/false' to activate/deactivate the cache.
* Fix capitalization of ClangJoel Rosdahl2020-05-241-1/+1
|
* Remove last usage of legacy args->argv wrapperJoel Rosdahl2020-05-071-1/+1
|
* Remove last usage of legacy args_set functionJoel Rosdahl2020-05-071-1/+1
|
* Adapt hash_command_output() to use split_into_strings()Thomas Otto2020-04-161-8/+2
|
* Adapt find_executable() to use split_into_strings()Thomas Otto2020-04-161-3/+1
|