Joel Rosdahl [Wed, 8 May 2024 18:45:13 +0000 (20:45 +0200)]
fix: Force run_second_cpp=true when generating profiling information
If run_second_cpp=false the coverage report will refer to the temporary
preprocessed file instead of the source file. Fix this by forcing
run_second_cpp=true if profiling information is being generated.
Joel Rosdahl [Sun, 28 Apr 2024 19:50:58 +0000 (21:50 +0200)]
chore: Remove unnecessary depend_extra_args
The ordinary compiler_args list can be used for executing the compiler
in the depend mode since dependency arguments are present there after 07b55f13e119a2a35d166a73929643911ea69d52.
Joel Rosdahl [Sat, 27 Apr 2024 13:22:40 +0000 (15:22 +0200)]
feat: Support -Xpreprocessor -fopenmp in direct mode
All uses of -Xpreprocessor disable the direct mode as a safety measure
since the command line could include things like
-Xpreprocessor -MF -Xpreprocessor file.d
which ccache needs to understand as
-MF file.d
Ideally, ccache should handle this in a generic way. Meanwhile, let's
allow it in the a special case of "-Xpreprocessor -fopenmp" since that's
required on macOS to enable OpenMP.
Joel Rosdahl [Thu, 25 Apr 2024 19:32:16 +0000 (21:32 +0200)]
refactor: Improve dependency file parsing
- Use Depfile::tokenize to parse the dep file in rewrite_source_paths
instead of an even more ad-hoc parser.
- Add Depfile::untokenize to go from tokens back to text representation.
Joel Rosdahl [Sat, 27 Apr 2024 08:30:18 +0000 (10:30 +0200)]
build: Improve handling of dependencies (#1429)
- Introduced a new CMake variable called `DEPS` with the following
semantics:
- `AUTO` (the default): Use dependencies from the local system if
available. Otherwise: Use bundled dependencies if available. Otherwise:
Download dependencies from the internet (dependencies will then be
linked statically).
- `DOWNLOAD`: Use bundled dependencies if available. Otherwise: Download
recommended versions from the internet (dependencies will then be linked
statically).
- `LOCAL`: Use dependencies from the local system if available.
Otherwise: Use bundled dependencies if available.
The old `HIREDIS_FROM_INTERNET`, `ZSTD_FROM_INTERNET` and `OFFLINE`
variables have been removed in favor of `DEPS`.
- Streamlined the CMake code for hiredis and zstd.
- Removed bundled `getopt_long` implementation.
It seems likely that getopt_long is available on all platforms where
ccache is built nowadays, except Windows. Therefore, remove the bundled
getopt_long implementation for now.
If it turns out that somebody wants to compile ccache on a system that
lacks getopt_long we can add support specifying a system or downloaded
version.
- Implemented our own AVX2 runtime detection instead of using a blake3's
ditto. This opens up for using blake3 from the system.
- Added support for using blake3, httplib, nonstd/span and tl/expected
from the system instead of bundled versions.
- Removed bundled doctest, fmt and xxhash dependencies. Instead,
download them if missing.
Joel Rosdahl [Sun, 17 Mar 2024 08:52:50 +0000 (09:52 +0100)]
build: Remove bundled getopt_long implementation
It seems likely that getopt_long is available on all platforms where
ccache is built nowadays, except Windows. Therefore, remove the bundled
getopt_long implementation for now.
If it turns out that somebody wants to compile ccache on a system that
lacks getopt_long we can add support specifying a system or downloaded
version.
Joel Rosdahl [Sun, 25 Feb 2024 09:35:07 +0000 (10:35 +0100)]
build: Improve handling of hiredis and zstd dependencies
Introduced a new CMake variable called DEPS with the following
semantics:
- AUTO (the default): Use dependencies from the local system if
available. Otherwise: Use bundled dependencies if available.
Otherwise: Download dependencies from the internet (dependencies will
then be linked statically).
- DOWNLOAD: Use bundled dependencies if available. Otherwise: Download
recommended versions from the internet (dependencies will then be
linked statically).
- LOCAL: Use dependencies from the local system if available. Otherwise:
Use bundled dependencies if available.
The old {HIREDIS,ZSTD}_FROM_INTERNET and OFFLINE variables have been
removed in favor of DEPS.
Also streamlined the CMake code for hiredis and zstd.
Joel Rosdahl [Tue, 9 Apr 2024 17:47:44 +0000 (19:47 +0200)]
feat: Clear manifest on recache
If there are bad entries in the manifest it doesn't help to run with
recache if the new entry (resulting from the recached compilation)
already exists as an older entry in the manifest.
Improve this by not populating the manifest in recache mode.
Kreijstal [Sat, 23 Mar 2024 15:07:49 +0000 (16:07 +0100)]
fix: Adapt util::LockFile to MSYS2 (#1416)
MSYS2 will not let you create a symlink to a nonexistent file, only to
an already existing file. To overcome this issue we use files, and write
content on it.
For Cygwin/MSYS2, the patch leverages POSIX `open` with the flags
`O_WRONLY | O_CREAT | O_EXCL`, effectively creating an exclusive lock
file. As suggested by @jrosdahl , thank you so much for the suggestion.
This still does not pass the test suite, but makes ccache usable.
Joel Rosdahl [Sat, 16 Mar 2024 13:42:00 +0000 (14:42 +0100)]
fix: Reduce the risk of false positive direct mode hits
To reduce the risk of getting a false positive hit when a directory
early in the include path now exists, record whether include directories
and similar input paths exist. Note that this is not 100% waterproof
since it only detects newly appearing directories and not newly
appearing header files.
Joel Rosdahl [Wed, 21 Feb 2024 21:03:43 +0000 (22:03 +0100)]
chore: Improve source tree structure
In preparation for adding support for using dependencies from the system
in addition to bundled or downloaded dependencies, restructure the
source tree so that:
- Third party headers are included without a third_party/ prefix, e.g.
#include <xxhash.h> instead of #include <third_party/xxhash.h>.
- Ccache headers are included with a ccache/ prefix, e.g. #include
<ccache/util/string.hpp> instead of #include <util/string.hpp>.
This keeps ccache and other headers separated but in another way than
before.
Joel Rosdahl [Wed, 21 Feb 2024 20:20:58 +0000 (21:20 +0100)]
chore: Remove internal tracing framework
The internal tracing calls enabled by ENABLE_TRACING work fine, but I
have found that I never use them or add tracepoints to new code, so in
reality they mostly contribute with dead weight. In an effort to reduce
the amount of dependencies, I have therefore decided to remove the trace
calls, including the bundled minitrace sources.
Joel Rosdahl [Wed, 21 Feb 2024 19:25:03 +0000 (20:25 +0100)]
fix: Allow nonexistent include files in preprocessor mode
After 43c3a44aadcb nonexistent include files found in the preprocessed
output would increment "Could not read or parse input file" and fall
back to just running the compiler. This made ccache not attempt
preprocessor mode for generated code with #line header referencing files
that can't be found, e.g. in an out-of-source build scenario.
Fix this by just disabling direct mode, restoring the pre-43c3a44aadcb
behavior in such cases.
Thomas Ferrand [Sun, 11 Feb 2024 15:11:47 +0000 (16:11 +0100)]
feat: Port the inode cache to Windows (#1388)
This PR ports the existing InodeCache to make it work under Windows.
This speeds up ccache a lot, both in the hit and miss cases, when a lot
of headers files are included in several compilation units. In our case
this makes the difference between ccache being worth using or not.
The logic of the InodeCache itself is unchanged. I introduced a
MemoryMap helper class that does the platform specific calls to
mmap/MapViewOfFile. Despite its generic name, I've implemented what was
needed for the InodeCache, it only supports mapping a file (no anonymous
mmap) in a shared fashion with read/write access.
Due to differences in behavior between unix and Windows regarding
unlinking a file that is opened, I am not convinced that it will work
correctly in every situation (for example if a process hold a bucket
lock for more than 5 seconds, the cache is dropped and recreated, under
Windows that won't work as the unlink will fail). That being said it
seems to work well enough when nothing unexpected happens.
I made a small change to the unit test because under Windows, we can't
open() a directory so instead I try to open a temp file in that
directory. After that change the unit tests pass unmodified.
For the bash based test, only the symbolic link test fails. This is
quite strange, when I try to run the test, the call to `ln -fs test1.c
test2.c` fails, but when run manually the same command succeeds. I tried
to run the test manually and it fails anyway but I haven't done anything
to fix it, this looks like more an issue from the DirEntry side than the
InodeCache side. Because of that I've left the bash based test disabled
for Windows, maybe we want to change that to only disable the symbolic
link test?
Joel Rosdahl [Sat, 10 Feb 2024 08:54:19 +0000 (09:54 +0100)]
fix: Fix reading of files larger than 2^31 bytes
For some kernels read(2) makes a short read for counts larger than 2^31,
even for files on 64-bit architectures. Other kernels seem to not like
large counts at all, returning a failure.
Fix this by limiting the read buffer to a smaller value. This also
removes a short read optimization which should have been removed in cff3bf417420ea88fe53e7267ae2a356898ae326.
Joel Rosdahl [Wed, 7 Feb 2024 20:09:02 +0000 (21:09 +0100)]
chore: Further improve /Tc and /Tp handling
- Remember if /Tc or /Tp was used and prepend it to the source file sent
to the preprocessor and compiler.
- Mark non-concatenated versions of /Tc and /Tp as too hard for now.
Joel Rosdahl [Mon, 5 Feb 2024 18:51:49 +0000 (19:51 +0100)]
fix: Fix MSVC crash when using /Zi /Fddebug.pdb
With /Zi, MSVC starts a long-lived mspdbsrv.exe background process. The
implementation of #1274 kills all processes created by ccache including
mspdbsrv.exe, which can make cl.exe crash with this error message: