Gregor Jasny [Tue, 29 Jun 2021 09:42:50 +0000 (11:42 +0200)]
Fix Apple Clang detection
Apple Clang, when called via `gcc` emits a `Configured with` line
on stderr which confuses the compiler detection. We just ignore
stderr for the `--version` query now.
Joel Rosdahl [Sun, 27 Jun 2021 18:34:06 +0000 (20:34 +0200)]
Include $PWD in hash for -fprofile-generate with relative directory
For a relative profile directory D, GCC stores $PWD/D as part of the
profile filename in an object file generated with -fprofile-generate, so
we need to include the same information in the hash.
Joel Rosdahl [Wed, 23 Jun 2021 14:27:51 +0000 (16:27 +0200)]
Implement configurations, API and framework for secondary storage
This introduces the possibility to add one or several secondary storage
backends to query after the primary cache storage. Note that cache
statistics counters will still be kept in the primary cache directory --
secondary storage backends only store cache results and manifests.
The API should now be ready enough to implement secondary storage
backends.
The framework is also ready enough for usage, but lacks two major things
that are still to be implemented:
1. Improved statistics handling. Up until now, ccache always increments
exactly one statistics counter for each invocation (e.g. “hit”,
“miss” or “some error”). Since I want to have separate statistics for
primary and secondary storage, this model no longer works since an
invocation can result in both a “primary miss” and a “secondary hit”.
2. Improved PrimaryStorage interface. The SecondaryStorage interface
works with memory data, but PrimaryStorage, Result and Manifest still
work with files at the API level. This means that if an invocation is
a primary storage miss but a secondary storage hit, the data from
secondary storage has to be written to a temporary file only to be
read back into memory again by the Result/Manifest deserialization
code.
Michael Kruse [Sun, 20 Jun 2021 19:20:40 +0000 (14:20 -0500)]
Use single command line arg for /FI (#869)
CMake seems to interpret /FI and its argument as two separate options.
For instance, CMake de-duplicates arguments, leading any to non-first
/FI flag to be removed. This might be the reason why the option is not
honored with Visual Studio 16.10.2 / CMake 3.20.3.
Fix by combining /FI and its argument into a single command line option.
Michael Kruse [Sun, 20 Jun 2021 19:19:52 +0000 (14:19 -0500)]
Add sloppy include_file_mtime to ivfsoverlay test (#868)
Add CCACHE_SLOPPINESS=include_file_mtime to ivfsoverlay test. This is
possibly due to me using my self-compiled clang since it does not fail
with the version of Clang that comes with Ubuntu 20.04.
Joel Rosdahl [Fri, 18 Jun 2021 18:47:17 +0000 (20:47 +0200)]
Require C++14-compatible compiler to build ccache
Ccache 4.0 introduced a requirement on a C++11-compatible compiler. The
language version was primarily chosen to support CentOS 7.
The time has now come to bump to C++14, to among other things get access
to generic lambda expressions and improved constexpr functions. Another
side effect is to get usable support for std::regex due to requiring a
newer GCC than 4.8 which lacks such support.
r-burns [Thu, 17 Jun 2021 18:16:52 +0000 (11:16 -0700)]
Explicitly select C++ when using -fcxx-modules (#861)
Typically, clang is able to auto-detect C++ files and switch to C++
mode, even when `argv[0]` is simply `clang` (without the `++`).
However, Nixpkgs provides `clang` as a wrapper script over the
underlying compiler binary, and only enables C++ standard library
include paths when it thinks it's being invoked as a C++ compiler:
So for the benefit of less clever compiler toolchains which
can't always see that these invocations are using C++ mode,
we explicitly specify `-x c++` so they do the right thing.
Joel Rosdahl [Tue, 15 Jun 2021 19:02:29 +0000 (21:02 +0200)]
Document the plan of changing naming conventions for namespaces
Namespaces are from now on planned to be in snake_case instead of
UpperCamelCase. This is of course entirely due to cosmetical reasons,
but I feel that it maps better to the upcoming changes in directory
structure where I don’t want camel-case directory names.
Joel Rosdahl [Sun, 30 May 2021 18:40:35 +0000 (20:40 +0200)]
Include config.h via command line instead of via system.h
This makes the definitions in config.h available to all source code,
including third_party_lib. It’s also a first step towards not having to
include system.hpp and its libc headers from all files.
Joel Rosdahl [Sun, 30 May 2021 18:20:07 +0000 (20:20 +0200)]
Improve defines for third_party_lib
- Don’t filter out useful warnings like warning about implicit function
declarations.
- Apply definitions in config.h to third party source code instead of
passing feature defines as a special case.
Josh Triplett [Mon, 3 May 2021 17:00:19 +0000 (10:00 -0700)]
Support `-specs file.specs` and `--specs file.specs` (#843)
* Support `-specs file.specs` and `--specs file.specs`
ccache currently supports specs files supplied via `-specs=file.specs`
and `--specs=file.specs`, but using a space instead of an `=` will cause
ccache to error out on the subsequent .specs file with
"unsupported source language".
Add support for `-specs file.specs` and `--specs file.specs`.
Petr Štetiar [Mon, 3 May 2021 16:44:53 +0000 (18:44 +0200)]
CMake: make build of documentation optional (#842)
So we don't need to support corner cases as for example one fixed in
commit f6202db308e3 ("doc/MANUAL.adoc: Don't use non-ASCII quotes
(#761)") when the documentation is actually not needed at all as ccache
is used as a build tool only.
Canonicalize header path earlier to improve performance (#838)
The ctx.included_files.find(path) check was done before removing the "./" prefix
from the path, leading to decreased performance for such headers since the check
would always fail for such paths.
Joel Rosdahl [Tue, 13 Apr 2021 06:45:09 +0000 (08:45 +0200)]
Improve statistics for “-P -E”
“-P” is currently considered too hard, so when it’s used in conjunction
with “-E” the “unsupported compiler option” statistics counter is
increased since “-P” is found before “-E” on the command line.
Improve this by not passing “-P” to the preprocessor so that’s it’s in
effect supported. “-P -E” will then instead bail out on “-E”, increasing
“called for preprocessing” instead.
Joel Rosdahl [Mon, 5 Apr 2021 11:19:19 +0000 (13:19 +0200)]
Use Clang-Format executable from muttleyxd/clang-tools-static-binaries
misc/format-files now executes misc/clang-format, which works like this:
1. If environment variable CLANG_FORMAT is set, execute $CLANG_FORMAT.
2. Otherwise, if <ccache-top-dir>/misc/.clang-format-exe exists, execute
that program.
3. Otherwise, download a statically linked clang-format executable,
verify its integrity, place it in
<ccache-top-dir>/misc/.clang-format-exe and execute it.
This makes it possible for us to lock Clang-Format to version 10 and
remove most “// clang-format off/on” comments.
Stat: treat pending deletes as missing files on Windows
Win32 functions like `CreateFile` return `ERROR_ACCESS_DENIED` when a
file is in the process of being deleted, which gets mapped to an errno
of `EACCES`. For the purposes of `Stat::stat` and `Stat::lstat`, it's
more useful to treat this as a missing file and mapping this to an errno
of `ENOENT`.
Explicitly specify versions of clang, clang++ and clang-tidy so we don't
run with mismatched versions.
GitHub seems to have recently bumped the version of clang installed in
its Ubuntu 18.04 runners to version 9, and aliased it to
`/usr/bin/clang` / `/usr/bin/clang++`. But running `apt-get install
clang-tidy` would install an older version of clang-tidy from LLVM _6.0_
at `/usr/bin/clang-tidy`.
Joel Rosdahl [Sat, 27 Mar 2021 13:28:13 +0000 (14:28 +0100)]
Probe for working faster linker
As noted by Nicholas Hutchinson in #794, the availability of a linker
program is not enough to conclude that it works for some older compilers
and platforms like macOS and Windows.
Improve this by probing if it works to pass “-fuse-ld=$LINKER”.
It looks like https://zstd.net isn't working anymore, however, http://zstd.net
works and simply redirects to https://facebook.github.io/zstd/ which is served
through https.
Aleksander Salwa [Sat, 20 Mar 2021 18:55:54 +0000 (19:55 +0100)]
win32: Fix handling of long command lines (#816)
What is broken: handling of "execute" with long command parameters (see win32execute).
In more details:
* parameter lpCommandLine was formatted incorrectly (it has to contain app name too)
* temporary file with parameters to the compiler was formatted incorrectly (it
should NOT contain app name; if it contains backslashes, then these
backslashes need to be escaped as double-backslashes)
* wrong location (directory) of temporary files in win32execute
* premature deletion of temporary files in win32execute
Implement a better Stat::stat(), Stat::lstat() for Windows (#819)
`stat()` as implemented in msvcrt.dll (used by mingw-w64) has a number
of flaws:
- `st_ino` is always 0
- other file attributes are queried from the parent directory instead of
the file itself, and so can be incorrect/stale, e.g. if a file is
modified via another hard link.
The implementation in the UCRT is slightly better -- it prefers to query
attributes from the file itself if possible, but it still doesn't
populate `st_ino` and can silently fall back to querying from the parent
directory and giving stale results.
I don't believe the msvcrt.dll source is available (you have to infer
its behaviour from e.g. Process Monitor) but the ucrtbase.dll source
code is available in the Windows 10 SDK.
Write an implementation of `stat`/`lstat` that sidesteps these issues by
using Win32 APIs to query file information. A few implementation notes:
- We do not fall back to querying the parent directory (as the UCRT
`stat()` implementation and [Python's `stat()`][1] do) if we can't get
a handle to the actual file. If we don't have `FILE_READ_ATTRIBUTES`
permissions, we fail with `EACCES` instead of returning
incomplete/stale results fetched from the parent directory.
- Windows-specific `Stat::file_attributes()` / `Stat::reparse_tag()`
added to provide the Win32 file attributes and file reparse tag.
- `lstat()` sets the `S_IFLNK` bit in `st_mode` for symlinks. On
Windows, there are other symlink-like things ("name surrogate reparse
points") such as directory junctions and mountpoints. To identify
these, the caller can check the reparse tag to identify a directory
junction/mountpoint.
- We use Python's mapping of Win32 error codes to C errno.
Joel Rosdahl [Sat, 13 Mar 2021 12:26:03 +0000 (13:26 +0100)]
Only reject -f(no-)color-diagnostics for known GCC compiler
61ce8c44 made it so that ccache rejects -f(no-)color-diagnostics early
for non-Clang compilers. This was needed to avoid false cache hits for
the GCC case, but it had the side effect of rejecting
-fcolor-diagnostics for unknown compilers as well, such as for a
compiler named c++ that in reality is clang++ (which actually accepts
-f(no-)color-diagnostics).
Fix this by simply doing the special case for GCC instead of non-Clang.
This is OK since the speculative handling of color diagnostics options
is only done for GCC and Clang, not for other compiler types.