Joel Rosdahl [Sun, 5 Jul 2020 19:00:47 +0000 (21:00 +0200)]
Tweak ci/build script
- Removed redundant “exit 0” command again.
- Removed now obsolete and misleading comments.
- If JOBS is set to the empty string then detect the number of CPUs instead
of running a limitless number of jobs.
Joel Rosdahl [Sun, 5 Jul 2020 18:35:05 +0000 (20:35 +0200)]
Use a known and set TERM variable to stabilize color_diagnostics tests
On some distributions TERM is unset when run via Docker which failed
color_diagnostics tests since ccache doesn’t enable color output if TERM
is unset. Fix this by using a known TERM value.
Joel Rosdahl [Sun, 5 Jul 2020 18:34:54 +0000 (20:34 +0200)]
Skip “Directory is not hashed if using -gz[=zlib]” tests for GCC 6
The GCC 6 (tested with GCC 6.3) preprocessor includes the current
working directory in the preprocessed output if run with -gz, which
means that there won’t be cache hits between directories, thus failing
the “Directory is not hashed if using -gz[=zlib]” tests. Fix this by
skipping the test if the preprocessor behaves that way.
Joel Rosdahl [Wed, 24 Jun 2020 07:26:23 +0000 (09:26 +0200)]
Fix color_diagnostics test failure if CCACHE_DIR is set in shell rc file
If the user sets CCACHE_DIR in a shell startup file then that value will
override the one from the test suite, thus making changes in cache
statistics invisible which triggers failures.
Joel Rosdahl [Tue, 23 Jun 2020 19:57:26 +0000 (21:57 +0200)]
Rename generated Version.cpp to version.cpp
The convention is to use capitalized filenames for source files that
implement classes and namespaces and lowercase filenames for source
files that do not.
Olle Liljenzin [Mon, 22 Jun 2020 19:57:59 +0000 (21:57 +0200)]
Reduce number of memory allocations in hashing (#608)
Add hash_buffer_once method for hashing a given text immediately using a
stack allocated hasher. Also skip copying the hasher in hash_result as
blake3 is not modifying the hasher.
Joel Rosdahl [Sun, 21 Jun 2020 19:29:04 +0000 (21:29 +0200)]
Remove win32 GetFileNameFromHandle compatibility function
The replacement function seems to be buggy, triggering failures in
x_realpath at least when the unit tests are run in Wine. The real
GetFinalPathNameByHandle function is allegedly supported in Windows
Vista and newer, so let’s just use it.
Joel Rosdahl [Thu, 18 Jun 2020 19:46:22 +0000 (21:46 +0200)]
Improve comment of inode cache version and revert to version 1 again
As noted by Olle Liljenzin, changing the hash algorithm does not require
incrementing the version field, so let’s revert the change I made as
part of 2a0dd8ef.
Joel Rosdahl [Thu, 18 Jun 2020 18:26:58 +0000 (20:26 +0200)]
Let “ccache --hash-file” perform raw hashing again
Unintended or not, #577 (213d9883) changed the behavior of “ccache
--hash-file” to use hash_binary_file, which essentially performs
hash(hash(path)) if the i-node cache is enabled, otherwise hash(path).
This means that “ccache --hash-file” behaves differently depending on if
i-node cache is enabled and also that it’s no longer usable for
benchmarking purposes.
Joel Rosdahl [Sun, 14 Jun 2020 19:09:24 +0000 (21:09 +0200)]
Improve INSTALL.md after CMake-ification
I chose to mention “-DCMAKE_BUILD_TYPE=Release” explicitly since some
end users will clone the repository instead of downloading the release
archive and then the default “Debug” build won’t be a great idea.
Joel Rosdahl [Sun, 14 Jun 2020 18:59:13 +0000 (20:59 +0200)]
Don’t update author list when generating documentation
Motivation:
1. The copyright notice in each source file refers to doc/AUTHORS.adoc
for the list of contributors. If we only update AUTHORS.adoc when
generating documention then AUTHORS.adoc will become more and more
out of date until somebody remembers to commit the changes.
2. The list is based on commit authors, but authors may sometimes need
an entry in .mailmap so there’s manual work involved to sanity check
the list. It can also happen that some commits or authors may need to
be excluded.
Therefore I prefer to keep AUTHORS.adoc manually updated at release time
(or occasionally more often) with the help of a script just like before.
Joel Rosdahl [Sun, 14 Jun 2020 18:45:23 +0000 (20:45 +0200)]
Remove cmake-format check and support
Motivation:
1. It’s unsatisfying to have to remember to run “make format” after
editing CMake files. (Clang-Format has more editor integrations, and
most importantly there are integrations for my editor of choice.)
2. The output of cmake-format seems to be a bit unstable between
versions.
3. I don’t like some of cmake-format’s formatting choices. This could be
potentially be improved, though.
Let’s remove the support for now and maybe revisit later.
Olle Liljenzin [Sun, 31 May 2020 10:02:12 +0000 (12:02 +0200)]
Add inode cache for file hashes (#577)
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.
Joel Rosdahl [Fri, 29 May 2020 18:43:19 +0000 (20:43 +0200)]
Only try to hard link object files to/from the cache
The compiler unlinks the destination object file before writing, but it
apparently doesn’t do that for dependency files. This means that
compilation can corrupt a .d file that shares i-node with a cached .d
file when using the hard link mode. Here is a scenario where this can
happen:
1. There is a test.c which includes test.h.
2. When test.c is compiled, the compiler writes test.d which mentions
test.h and ccache hard links test.d into cache entry 1. test.d and
cache entry 1's .d file now share i-nodes.
3. The include of test.h is removed from test.c.
4. When test.c is compiled again the compiler overwrites test.d with new
content without test.h and ccache hard links test.d into cache entry
2. test.d, cache entry 1 and cache entry 2 now share i-nodes, all of
which contain the new content without test.h.
Since we can’t be sure how the compiler behaves for other types of files
(.dwo, .cov, etc.), only try to to hard link object files.
Joel Rosdahl [Wed, 20 May 2020 19:26:35 +0000 (21:26 +0200)]
Handle all Intel “-xCODE” compiler options correctly
“CODE” in the Intel compiler’s “-xCODE” option for specifying processor
features seems to always start with an uppercase letter, and since GCC’s
language specifications always are lowercase we can just treat uppercase
codes as an ordinary compiler argument.
Joel Rosdahl [Tue, 19 May 2020 18:37:19 +0000 (20:37 +0200)]
Improve temp file handling
- Use Util::create_temp_fd instead of legacy create_tmp_fd.
- Use Context::register_pending_tmp_file instead of unlinking
explicitly.
- Simplified output of merged stderr from preprocessor and compiler.
Joel Rosdahl [Mon, 18 May 2020 06:26:14 +0000 (08:26 +0200)]
Refactor signal handling and process exit code
* Added a SignalHandler class which encapsulates parts related to signal
handling.
* Moved data referenced by the exit functions to Context (compiler PID,
pending temporary files and pending debug log files).
* Let the Context destructor do what the exitfn functionality used to
do.
* Removed the now superfluous exitfn functionality.