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.
Joel Rosdahl [Thu, 4 Mar 2021 20:34:07 +0000 (21:34 +0100)]
Write debug log file in most argument processing error scenarios
When the debug mode is enabled, ccache writes the log to
<objectfile>.ccache-log, but that can only be done if the object file
location has been determined. If an unsupported compiler option is
detected, ccache exits early and may not yet have determined the output
object filename.
Fix this by parsing all compiler options, then determining the object
file location and only then return an error from the process_args
function with. This will in practice make the debug mode work for most
invocations. There are still edge cases where it won’t work or will be
potentially confusing, for instance these:
Naturally, no debug log file will be written in the first case. In the
second case no debug log file will be written either since ccache
doesn’t consider a nonexistent file to be an input file. In the third
case the debug log file will be written foo.o.ccache-log but not
bar.o.ccache-log.
Fix Util::read_file truncating files if size_hint is an underestimate (#808)
If the size_hint passed to read_file was an underestimate, or the
platform's `stat()` implementation gives an inaccurate file size (e.g.
MinGW) then `Util::read_file()` would only issue a single `read()` call
instead of reading the entire file.
Joel Rosdahl [Tue, 23 Feb 2021 20:11:58 +0000 (21:11 +0100)]
Handle -frecord-gcc-switches correctly
-frecord-gcc-switches records the full command line in the object file,
so include the original command line in the hash as suggested by
Lawrence Chan.
StdAtomic.cmake: Probe atomic increment as well (#800)
On sparc there are 8-byte atomic loads and stores available in ISA
but not atomic increments. As a result linking fails as:
```
ld: src/libccache_lib.a(InodeCache.cpp.o):
undefined reference to symbol '__atomic_fetch_add_8@@LIBATOMIC_1.0'
ld: sparc-unknown-linux-gnu/8.2.0/libatomic.so.1:
error adding symbols: DSO missing from command line
```
The fix is to add increment into libatomic test.
tested on `sparc-unknown-linux-gnu` target.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Joel Rosdahl [Sun, 7 Feb 2021 12:32:26 +0000 (13:32 +0100)]
Only dup2 stderr into $UNCACHED_ERR_FD for preprocessor/compiler
Ccache dup2s the stderr FD and publishes the resulting FD number in
$UNCACHED_ERR_FD for usage by e.g. distcc. This is done any executed
child process.
As noted by Sam Varshavchik on the ccache mailing list, this leads to an
unfortunate and complex problem in combination with GNU Make, LTO
linking and the Linux PTY driver:
Since UNCACHED_ERR_FD is only relevant when running the preprocessor or
compiler, let’s only dup2 stderr when executing those, i.e. not when
falling back to just running the wrapped command such as the linker.