]> git.ipfire.org Git - thirdparty/ccache.git/log
thirdparty/ccache.git
4 years agoClean up slightly after ea433578
Joel Rosdahl [Sat, 20 Mar 2021 19:07:43 +0000 (20:07 +0100)] 
Clean up slightly after ea433578

4 years agoChanged zstd url back to http (#830)
Abubakar Nur Khalil [Fri, 26 Mar 2021 07:33:01 +0000 (08:33 +0100)] 
Changed zstd url back to http (#830)

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.

This change essentially reverts a single change from commit
a0f32f161f1b8b9c5d287ca8abe88e3fd1e940a2 where the zstd URL was changed from
http to https.

4 years agoUpdate doctest license info
Joel Rosdahl [Mon, 22 Mar 2021 17:37:28 +0000 (18:37 +0100)] 
Update doctest license info

4 years agoUpgrade to doctest 2.4.6
Joel Rosdahl [Mon, 22 Mar 2021 17:36:03 +0000 (18:36 +0100)] 
Upgrade to doctest 2.4.6

Closes #825.

4 years agodoc: Fix references to the extra_files_to_hash configuration option
Joel Rosdahl [Sun, 21 Mar 2021 20:22:47 +0000 (21:22 +0100)] 
doc: Fix references to the extra_files_to_hash configuration option

4 years agowin32: Fix handling of long command lines (#816)
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

4 years agoImplement a better Stat::stat(), Stat::lstat() for Windows (#819)
Nicholas Hutchinson [Thu, 18 Mar 2021 20:31:04 +0000 (20:31 +0000)] 
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.

[1]: https://github.com/python/cpython/blob/6086ae7fd4aeb4089282189673f9bd0cc33abf9b/Modules/posixmodule.c#L1884

4 years agoBail out on too hard Clang option -gen-cdb-fragment-path
Joel Rosdahl [Thu, 18 Mar 2021 19:29:24 +0000 (20:29 +0100)] 
Bail out on too hard Clang option -gen-cdb-fragment-path

4 years agoOnly reject -f(no-)color-diagnostics for known GCC compiler
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.

Fixes #806.

4 years agoClean up slightly after #814
Joel Rosdahl [Sun, 7 Mar 2021 13:15:28 +0000 (14:15 +0100)] 
Clean up slightly after #814

4 years agoUpgrade to doctest 2.4.5
Joel Rosdahl [Sat, 6 Mar 2021 18:16:28 +0000 (19:16 +0100)] 
Upgrade to doctest 2.4.5

4 years agoUpgrade to zstd 1.4.9
Joel Rosdahl [Sat, 6 Mar 2021 18:11:26 +0000 (19:11 +0100)] 
Upgrade to zstd 1.4.9

4 years agotest: Print line number of failing assert (#814)
Thomas Otto [Sun, 7 Mar 2021 13:14:39 +0000 (14:14 +0100)] 
test: Print line number of failing assert (#814)

4 years agobuild: Don't enable ccache when building with MSVC (#813)
Nicholas Hutchinson [Sun, 7 Mar 2021 13:09:47 +0000 (13:09 +0000)] 
build: Don't enable ccache when building with MSVC (#813)

4 years agoFix "Debug option" test (#807)
pawelkrysiak [Sat, 6 Mar 2021 18:10:34 +0000 (19:10 +0100)] 
Fix "Debug option" test (#807)

4 years agodoc: Fix formatting of debug_dir documentation
Joel Rosdahl [Sat, 6 Mar 2021 18:06:50 +0000 (19:06 +0100)] 
doc: Fix formatting of debug_dir documentation

4 years agoEnforce cpp2 mode on macOS if -g is given
Joel Rosdahl [Fri, 5 Mar 2021 19:37:51 +0000 (20:37 +0100)] 
Enforce cpp2 mode on macOS if -g is given

Newer Clang versions on macOS apparently produce different debug
information when compiling preprocessed code.

As mentioned in issue #807.

4 years agoci: Fix build on Ubuntu 18.04
Joel Rosdahl [Fri, 5 Mar 2021 06:13:53 +0000 (07:13 +0100)] 
ci: Fix build on Ubuntu 18.04

For some reason libzstd1-dev now has broken dependencies in GitLab’s
Ubuntu 18.04 environment. Fix this by installing libzstd-dev instead.

4 years agodoc: Fix formatting of debug_dir documentation
Joel Rosdahl [Thu, 4 Mar 2021 20:52:35 +0000 (21:52 +0100)] 
doc: Fix formatting of debug_dir documentation

4 years agoWrite debug log file in most argument processing error scenarios
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:

    ccache gcc -dumpspecs
    ccache gcc -c nonexistent.c
    ccache gcc -c foo.c bar.c

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.

As mentioned in issue #806.

4 years agoFix Util::read_file truncating files if size_hint is an underestimate (#808)
Nicholas Hutchinson [Wed, 24 Feb 2021 19:32:20 +0000 (19:32 +0000)] 
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.

Fixes #803.

4 years agoSupport building ccache with xlclang++ on AIX 7.2 (#805)
Jon Petrissans [Wed, 24 Feb 2021 19:13:19 +0000 (21:13 +0200)] 
Support building ccache with xlclang++ on AIX 7.2 (#805)

- Update of config.h.in to build with xlclang++ on AIX 7.2
- Little fixes in code chunks never built on usual platforms

4 years agoHandle -frecord-gcc-switches correctly
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.

Fixes #804.

4 years agodoc: Fix markup of compiler type “other”
Joel Rosdahl [Mon, 22 Feb 2021 17:53:16 +0000 (18:53 +0100)] 
doc: Fix markup of compiler type “other”

4 years agoSupport -fcolor-diagnostics passed to cc1 with -Xclang (#802)
Evangelos Foutras [Tue, 23 Feb 2021 19:41:15 +0000 (21:41 +0200)] 
Support -fcolor-diagnostics passed to cc1 with -Xclang (#802)

Before this change `clang++ -Xclang -fcolor-diagnostics -c foo.cc`
would result in diagnostics without color if stderr was not a TTY.

Fixes #801.

4 years agoStdAtomic.cmake: Probe atomic increment as well (#800)
Sergei Trofimovich [Wed, 17 Feb 2021 19:49:06 +0000 (19:49 +0000)] 
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>
4 years agoTweak passing of magic bytes to please GitHub CodeQL
Joel Rosdahl [Wed, 17 Feb 2021 19:27:50 +0000 (20:27 +0100)] 
Tweak passing of magic bytes to please GitHub CodeQL

4 years agoConvert trivial switch statement to if statement
Joel Rosdahl [Sun, 14 Feb 2021 19:34:14 +0000 (20:34 +0100)] 
Convert trivial switch statement to if statement

4 years agoOnly dup2 stderr into $UNCACHED_ERR_FD for preprocessor/compiler
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:

    https://www.mail-archive.com/ccache@lists.samba.org/msg01516.html

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.

4 years agoUse existing CMake “message()” level
Joel Rosdahl [Tue, 2 Feb 2021 07:59:49 +0000 (08:59 +0100)] 
Use existing CMake “message()” level

4 years agoAdd missing word in news item
Joel Rosdahl [Tue, 2 Feb 2021 06:28:35 +0000 (07:28 +0100)] 
Add missing word in news item

4 years agoPrepare for v4.2 v4.2
Joel Rosdahl [Tue, 2 Feb 2021 06:14:37 +0000 (07:14 +0100)] 
Prepare for v4.2

4 years agoUpdate news
Joel Rosdahl [Tue, 2 Feb 2021 06:14:25 +0000 (07:14 +0100)] 
Update news

4 years agoUse full path to env program
Joel Rosdahl [Mon, 1 Feb 2021 21:00:25 +0000 (22:00 +0100)] 
Use full path to env program

Minor improvement of 68d8481c.

4 years agoUpdate NEWS
Joel Rosdahl [Sat, 30 Jan 2021 18:58:15 +0000 (19:58 +0100)] 
Update NEWS

4 years agoImprove handling of SOURCE_DATE_EPOCH
Joel Rosdahl [Sat, 30 Jan 2021 18:35:54 +0000 (19:35 +0100)] 
Improve handling of SOURCE_DATE_EPOCH

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__.

4 years agoSort test suites
Joel Rosdahl [Sat, 30 Jan 2021 18:45:34 +0000 (19:45 +0100)] 
Sort test suites

4 years agoImprove comments in UseCcache.cmake
Joel Rosdahl [Sat, 30 Jan 2021 18:22:27 +0000 (19:22 +0100)] 
Improve comments in UseCcache.cmake

4 years agoImprove speed of compiler launcher command in UseCcache.cmake
Joel Rosdahl [Sat, 30 Jan 2021 18:17:33 +0000 (19:17 +0100)] 
Improve speed of compiler launcher command in UseCcache.cmake

I noticed that the overhead of “cmake -E env” is around 9 ms on my
system. This means that ccache direct mode hits on average have become
twice as slow when building ccache itself on my system.

Improve this by using the standard “env” program if available. Its
overhead is around 1 ms.

4 years agoUse snake case for CMake variable names
Joel Rosdahl [Sat, 30 Jan 2021 18:15:08 +0000 (19:15 +0100)] 
Use snake case for CMake variable names

4 years agoImprove emoji for questions/discussions in GitHub issue type list
Joel Rosdahl [Sat, 30 Jan 2021 13:36:46 +0000 (14:36 +0100)] 
Improve emoji for questions/discussions in GitHub issue type list

4 years agoUpdate authors
Joel Rosdahl [Sat, 30 Jan 2021 12:52:30 +0000 (13:52 +0100)] 
Update authors

4 years agoAdd Ka Ho Ng to .mailmap
Joel Rosdahl [Sat, 30 Jan 2021 12:51:24 +0000 (13:51 +0100)] 
Add Ka Ho Ng to .mailmap

4 years agoDisable inode cache on OSes without pthread_mutexattr_setpshared() (#791)
Stuart Henderson [Mon, 25 Jan 2021 18:41:54 +0000 (18:41 +0000)] 
Disable inode cache on OSes without pthread_mutexattr_setpshared() (#791)

The inode cache requires pthread_mutexattr_setpshared() and build fails on OSes
with sys/mman.h that do not have this function.

4 years agoCI: Skip homebrew update/cleanup on macOS (#790)
Nicholas Hutchinson [Mon, 25 Jan 2021 18:37:54 +0000 (18:37 +0000)] 
CI: Skip homebrew update/cleanup on macOS (#790)

The auto cleanup step that runs after `brew install` can can often add a
few minutes to each macOS CI run.

4 years agotests: Improve COFF object file comparison (#789)
Nicholas Hutchinson [Mon, 25 Jan 2021 18:37:07 +0000 (18:37 +0000)] 
tests: Improve COFF object file comparison (#789)

Make `is_equal_object_files` more lenient when comparing COFF object
files.

COFF object files contain the original source file name, which was
breaking the cpp1 test. They often contain a timestamp used by the
incremental linker, unless this is explicitly disabled via `/Brepro`
(MSVC) or `-mno-incremental-linker-compatible` (clang).

4 years agoFix fast linker selection for old GCC versions (#788)
Alexander Lanin [Mon, 25 Jan 2021 06:51:10 +0000 (07:51 +0100)] 
Fix fast linker selection for old GCC versions (#788)

4 years agoBlake3 build (#781)
Erik Flodin [Tue, 19 Jan 2021 20:33:25 +0000 (21:33 +0100)] 
Blake3 build (#781)

* Build the blake3 asm files to determine if they are supported

Building the files doesn't take long and gives a better result than just
checking that the assembler accepts a flag.

See also #768.

* Remove no longer used cmake function

* Update BLAKE3 to 3a8204f5f (0.3.7 + minor fixes) and include all MSVC asm files

* Try to improve blake3 on MSVC by using asm version

4 years agoTest suite fixes and improvements for Windows (#780)
Nicholas Hutchinson [Tue, 19 Jan 2021 20:27:00 +0000 (20:27 +0000)] 
Test suite fixes and improvements for Windows (#780)

* Tests: properly handle compiler arguments from CC environment variable

* Tests: don't pass test names directly to printf

In some cases test names would be interpreted as invalid arguments to
`printf` instead of a string to be printed, and this resulted in
confusing output on test failure.

* Tests: enable symlink support on Windows

git-bash's `ln -s` defaults to making a copy instead of making a symlink
for compatibility, but it is possible to ask for native Windows symlink
support instead.

Creating symlinks on Windows requires suitable permissions, or that
"Developer Mode" is enabled. (This is true for the Github Actions
Windows runners.)

* Tests: performance fixes for Windows

On Windows, git-bash's emulation of fork/exec is exteremely slow -- on
my machine it's typically around 30ms to spawn /usr/bin/true from a bash
script compared to 2ms on my macOS machine.

This is really noticeable when running ccache tests. This patch fixes
some of the hot code (i.e. code invoked for every test case) to avoid
spawning external commands or creating as many subshells.

* Tests: get more tests passing on Windows

- account for \r\n line endings in --version test
- skip tests that can never succeed on Windows

4 years agoRefer people to discussions for support
Joel Rosdahl [Tue, 19 Jan 2021 18:54:54 +0000 (19:54 +0100)] 
Refer people to discussions for support

4 years agoAdd emojis to issue types
Joel Rosdahl [Tue, 19 Jan 2021 18:53:22 +0000 (19:53 +0100)] 
Add emojis to issue types

4 years agorefactor: Drop out parameter from get_level_1_files (#779)
Alexander Lanin [Tue, 19 Jan 2021 18:18:52 +0000 (19:18 +0100)] 
refactor: Drop out parameter from get_level_1_files (#779)

4 years agoExtract enums into separate headers (#764)
Alexander Lanin [Tue, 19 Jan 2021 07:38:06 +0000 (08:38 +0100)] 
Extract enums into separate headers (#764)

4 years agoFaster compile times (#759)
Alexander Lanin [Sun, 17 Jan 2021 16:17:11 +0000 (17:17 +0100)] 
Faster compile times (#759)

4 years agoDon’t cache result if a preprocessed header file is too new
Joel Rosdahl [Sun, 17 Jan 2021 12:07:01 +0000 (13:07 +0100)] 
Don’t cache result if a preprocessed header file is too new

Unless sloppiness is set to ignore mtime/ctime, ccache classifies a
newly created header file as “too new” and then skips it in
do_remember_include_file and returns false, which makes
remember_include_file disable the direct mode. This works as intended
for normal header files whose content is included in the preprocessed
output. However, for a preprocessed header file this doesn’t work well
since its content then isn’t included in the hash, which can lead to
false positive cache hits.

Fix this by not caching the result if a preprocessed header file is too
new, i.e. increment the “can’t use preprocessed header” statistics
counter and fall back to just running the compiler.

Closes #774.

4 years agoExtract helper function include_file_too_new
Joel Rosdahl [Sun, 17 Jan 2021 10:07:04 +0000 (11:07 +0100)] 
Extract helper function include_file_too_new

4 years agoMove variable closer to usage in do_remember_include_file
Joel Rosdahl [Sun, 17 Jan 2021 09:27:50 +0000 (10:27 +0100)] 
Move variable closer to usage in do_remember_include_file

4 years agoSupport source code language “cuda”, used by Clang
Joel Rosdahl [Sat, 16 Jan 2021 19:09:03 +0000 (20:09 +0100)] 
Support source code language “cuda”, used by Clang

See also 2728c68bba9f8b4bb5c8812cd1b50402b81ebfd9.

Closes #772.

4 years agoAdd supported_source_extension function
Joel Rosdahl [Sat, 16 Jan 2021 19:05:35 +0000 (20:05 +0100)] 
Add supported_source_extension function

4 years agoRemove trailing spaces
Joel Rosdahl [Sat, 16 Jan 2021 19:05:14 +0000 (20:05 +0100)] 
Remove trailing spaces

4 years agoRemove superfluous file_language member from ArgumentProcessingState
Joel Rosdahl [Sat, 16 Jan 2021 18:09:10 +0000 (19:09 +0100)] 
Remove superfluous file_language member from ArgumentProcessingState

4 years agodoc: Mention that ccache requires the “-c” option
Joel Rosdahl [Sat, 16 Jan 2021 18:08:09 +0000 (19:08 +0100)] 
doc: Mention that ccache requires the “-c” option

4 years agodoc/MANUAL.adoc: Don't use non-ASCII quotes (#761)
Sergei Trofimovich [Mon, 11 Jan 2021 20:17:47 +0000 (20:17 +0000)] 
doc/MANUAL.adoc: Don't use non-ASCII quotes (#761)

Some locales like "LANG=fr_FR.iso885915@euro make" can't
handle UTF-8 single- and double-quotes:

$ LANG=fr_FR.iso885915@euro make
...
asciidoc: FAILED: MANUAL.adoc: line 529: unexpected error:
...
  File "/usr/lib/python3.8/encodings/iso8859_15.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u201c'
  in position 54: character maps to <undefined>

To avoid it the patch uses ASCII equivalents of symbols.

The patch is generated as:

$ sed \
    -e 's/\xE2\x80\x99/'\''/g' \
    -e 's/\xE2\x80\x9C/'\`\`'/g' \
    -e 's/\xE2\x80\x9D/'\'\''/g' \
    -i doc/MANUAL.adoc

Reported-by: Christophe PEREZ
Bug: https://bugs.gentoo.org/762814
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agoFix YAML syntax in codeql-analysis.yaml after #746
Joel Rosdahl [Sun, 10 Jan 2021 21:09:23 +0000 (22:09 +0100)] 
Fix YAML syntax in codeql-analysis.yaml after #746

4 years agoAdd CodeQL (#746)
Alexander Lanin [Sun, 10 Jan 2021 21:07:09 +0000 (22:07 +0100)] 
Add CodeQL (#746)

4 years agoFix Lockfile on Windows when parent directories do not exist (#769)
Nicholas Hutchinson [Sun, 10 Jan 2021 21:05:00 +0000 (21:05 +0000)] 
Fix Lockfile on Windows when parent directories do not exist (#769)

Fix flipped condition test that meant the file lock wouldn't be acquired
if parent directories needed to be created.

4 years agoUse static_cast
Joel Rosdahl [Sun, 10 Jan 2021 20:51:15 +0000 (21:51 +0100)] 
Use static_cast

4 years agoCI: Fix testdir upload file name in case of failed tests (#763)
Alexander Lanin [Sun, 10 Jan 2021 20:44:51 +0000 (21:44 +0100)] 
CI: Fix testdir upload file name in case of failed tests (#763)

4 years agoAlways use 64bit to print time_t (#762)
Khem Raj [Sun, 10 Jan 2021 20:43:47 +0000 (12:43 -0800)] 
Always use 64bit to print time_t (#762)

some 32bit architectures e.g. RISCV32 use 64bit time_t from beginning
which does not fit into long int size on LP32 systems

Signed-off-by: Khem Raj <raj.khem@gmail.com>
4 years agoTweak documentation and code related to SOURCE_DATE_EPOCH
Joel Rosdahl [Sat, 9 Jan 2021 18:52:08 +0000 (19:52 +0100)] 
Tweak documentation and code related to SOURCE_DATE_EPOCH

4 years agoIgnore SOURCE_DATE_EPOCH under time_macros sloppiness (#755)
Azat Khuzhin [Sat, 9 Jan 2021 18:44:30 +0000 (21:44 +0300)] 
Ignore SOURCE_DATE_EPOCH under time_macros sloppiness (#755)

SOURCE_DATE_EPOCH will be passed from debhelpers, by extracting last
entry from d/changelog (or current time if there is entries)
And this will not allow to use cache.

4 years agoFix scanning of headers with Clang-Tidy (#758)
Alexander Lanin [Wed, 6 Jan 2021 20:50:41 +0000 (21:50 +0100)] 
Fix scanning of headers with Clang-Tidy (#758)

By adding . as an include directory, CMake actually took it literally and files
are included from e.g. src/./AtomicFile.h. However in .clang-tidy headers with
an additional slash (headers from subdirectory third_party) are excluded from
reports.

This commit:

- gets rid of include via .
- fixes some warnings
- disables the rest

4 years agoSuppress Clang-Tidy warning about including signal.h
Joel Rosdahl [Wed, 6 Jan 2021 20:29:37 +0000 (21:29 +0100)] 
Suppress Clang-Tidy warning about including signal.h

sigaddset and similar functions are specified by POSIX to be in signal.h
and the C++ csignal header only contains a subset of the signal.h
declarations.

Related to PR #758.

4 years agoImprove header inclusion for SignalHandler
Joel Rosdahl [Wed, 6 Jan 2021 19:23:40 +0000 (20:23 +0100)] 
Improve header inclusion for SignalHandler

4 years agoUpgrade to optional-lite 3.4.0
Joel Rosdahl [Wed, 6 Jan 2021 19:13:38 +0000 (20:13 +0100)] 
Upgrade to optional-lite 3.4.0

4 years agoUpgrade to fmt 7.1.3
Joel Rosdahl [Wed, 6 Jan 2021 19:05:47 +0000 (20:05 +0100)] 
Upgrade to fmt 7.1.3

4 years agoUpgrade to doctest 2.4.4
Joel Rosdahl [Wed, 6 Jan 2021 19:01:34 +0000 (20:01 +0100)] 
Upgrade to doctest 2.4.4

Version 2.4.4 includes the fix in PR #743 for issue #731.

4 years agoUpgrade to zstd 1.4.8
Joel Rosdahl [Wed, 6 Jan 2021 18:59:27 +0000 (19:59 +0100)] 
Upgrade to zstd 1.4.8

4 years agoAdapt to the ccache code style
Joel Rosdahl [Thu, 31 Dec 2020 18:57:26 +0000 (19:57 +0100)] 
Adapt to the ccache code style

4 years agoTweak build.yaml
Joel Rosdahl [Wed, 6 Jan 2021 18:54:53 +0000 (19:54 +0100)] 
Tweak build.yaml

4 years agoCI: Add VS2019 build jobs (#757)
Nicholas Hutchinson [Wed, 6 Jan 2021 18:53:16 +0000 (18:53 +0000)] 
CI: Add VS2019 build jobs (#757)

Add VS2019 build jobs that use clang for the test suite. There are many
test failures on Windows, but these are ignored for now.

Tweak CMake build scripts:
- Fix CI build type handling for MSVC (recognise `/NDEBUG` and not just
  `-DNDEBUG`)
- Fix incorrect warnings-as-errors flag for MSVC
- Suppress an additional conversion warning on MSVC

4 years agoAdd debug_dir setting for specifying a directory for debug files
Joel Rosdahl [Mon, 4 Jan 2021 13:30:32 +0000 (14:30 +0100)] 
Add debug_dir setting for specifying a directory for debug files

This makes it possible to store debug files outside a transient build
directory. As a bonus, it also allows for getting debug files when the
object file is /dev/null.

4 years agoRemove redundant initialization of std::string variables
Joel Rosdahl [Mon, 4 Jan 2021 12:55:13 +0000 (13:55 +0100)] 
Remove redundant initialization of std::string variables

4 years agoMake Util::make_relative_path able to find matches for canonical path (#760)
Joel Rosdahl [Wed, 6 Jan 2021 18:23:03 +0000 (19:23 +0100)] 
Make Util::make_relative_path able to find matches for canonical path (#760)

Scenario:

- /tmp is a symlink to /private/tmp.
- Both apparent and actual CWD is /private/tmp/dir.
- A path (e.g. the object file) on the command line is /tmp/dir/file.o.
- Base directory is set up to match /tmp/dir/file.o.

Ccache then rewrites /tmp/dir/file.o into ../../private/tmp/dir/file.o,
which is correct but not optimal since ./file.o would be a better
relative path. Especially on macOS where, for unknown reasons, the
kernel sometimes disallows opening a file like
../../private/tmp/dir/file.o for writing.

Improve this by letting Util::make_relative_path try to match
real_path(path) against the CWDs and choose the best match.

Closes #724.

4 years agoAdd hint on how to link statically with libzstd
Joel Rosdahl [Wed, 6 Jan 2021 17:49:10 +0000 (18:49 +0100)] 
Add hint on how to link statically with libzstd

As mentioned in #750.

4 years agoConfigure nonstd::string_view to don’t fall back to std::string_view
Joel Rosdahl [Sun, 3 Jan 2021 14:43:50 +0000 (15:43 +0100)] 
Configure nonstd::string_view to don’t fall back to std::string_view

This makes the code base use nonstd::string regardless of the C++ target
version, which avoids some compatibilty issues.

This decision can be revisited in the future when C++17 is the lower
bar.

Closes #749.

4 years agoDon’t capture “this” implicitly
Joel Rosdahl [Sun, 3 Jan 2021 14:33:24 +0000 (15:33 +0100)] 
Don’t capture “this” implicitly

This avoids an “implicit capture of 'this' via '[=]' is deprecated”
warning when building for C++20 and does no harm for earlier versions.

4 years agoFix retrieval of object file when destination is /dev/null
Joel Rosdahl [Sun, 3 Jan 2021 12:39:57 +0000 (13:39 +0100)] 
Fix retrieval of object file when destination is /dev/null

ResultRetriever::on_entry_data assumes that a destination file has been
opened if the entry type is not stderr_output, but that’s incorrect
since on_entry_start doesn’t open a destination file if it’s /dev/null.
An assertion is triggered:

    ccache: ResultRetriever.cpp:129: virtual void
    ResultRetriever::on_entry_data(const uint8_t *, size_t): failed
    assertion: (m_dest_file_type == FileType::stderr_output &&
    !m_dest_fd) || (m_dest_file_type != FileType::stderr_output &&
    m_dest_fd)

Fix this by letting on_entry_data handle the “destination file not
opened” case and correcting the assert.

Fixes #752.

4 years agoImprove log messages and comments related to retrieving results
Joel Rosdahl [Sun, 3 Jan 2021 12:31:15 +0000 (13:31 +0100)] 
Improve log messages and comments related to retrieving results

4 years agoImprove log message when manifest entry already exists
Joel Rosdahl [Sun, 3 Jan 2021 12:04:58 +0000 (13:04 +0100)] 
Improve log message when manifest entry already exists

4 years agoCapitalize log message with inode cache statistics
Joel Rosdahl [Sun, 3 Jan 2021 11:55:00 +0000 (12:55 +0100)] 
Capitalize log message with inode cache statistics

4 years agoDeduce split dwarf filename from object file with zero or multiple dots
Joel Rosdahl [Sun, 3 Jan 2021 10:44:06 +0000 (11:44 +0100)] 
Deduce split dwarf filename from object file with zero or multiple dots

(cherry picked from commit 5bcba58358ef2e88e1cc910583830c6830f6c712)

4 years agoOnly accept -f(no-)color-diagnostics for Clang
Joel Rosdahl [Wed, 30 Dec 2020 20:22:26 +0000 (21:22 +0100)] 
Only accept -f(no-)color-diagnostics for Clang

If a non-Clang compiler gets -f(no-)color-diagnostics then bail out and
just execute the compiler. The reason is that we don't include
-f(no-)color-diagnostics in the hash so there can be a false cache hit
in the following scenario:

  1. ccache gcc -c example.c                      # adds a cache entry
  2. ccache gcc -c example.c -fcolor-diagnostics  # unexpectedly succeeds

Closes: #740.
4 years agoRemove obsolete (and now incorrect) fallback replacement of realpath(3)
Joel Rosdahl [Tue, 29 Dec 2020 18:33:54 +0000 (19:33 +0100)] 
Remove obsolete (and now incorrect) fallback replacement of realpath(3)

The fallback replacement of realpath(3) (from 8e918ccc) uses readlink(3)
under the assumption that we’re only interested about symlinks, but
that’s no longer the case: we’re using it for normalization purposes as
well. Let’s just remove it. If it turns out that there still are
non-Windows systems that don’t have realpath(3) and that we care about
we’ll figure out something else.

4 years agoFix Util::dir_name for Windows paths
Joel Rosdahl [Tue, 29 Dec 2020 18:06:17 +0000 (19:06 +0100)] 
Fix Util::dir_name for Windows paths

Util::dir_name does not understand “C:\”-style Windows path so add such
knowledge.

4 years agoAdd simple unit test of Util::make_relative_path
Joel Rosdahl [Mon, 28 Dec 2020 19:46:06 +0000 (20:46 +0100)] 
Add simple unit test of Util::make_relative_path

4 years agoFix running tests on macOS (#756)
Nicholas Hutchinson [Mon, 28 Dec 2020 14:25:12 +0000 (14:25 +0000)] 
Fix running tests on macOS (#756)

Bash tests were not actually being run on the macOS CI agents because
the version of sed installed there does not understand the `-r` flag:

    sed: illegal option -- r
    usage: sed script [-Ealn] [-i extension] [file ...]
           sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]

- use `sed -E` instead of `sed -r` as the latter isn't supported by BSD sed.

- export `SDKROOT` in `test/run`. Otherwise it appears at least some
  some Apple toolchains (e.g. Xcode 10.3) will pick the _latest_ SDK
  installed on the host (e.g.
  `/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk`)
  instead of using the SDK bundled with the toolchain (e.g.
  `/Applications/Xcode_10.3.app/.../MacOSX10.14.sdk`).

  The 10.15 SDK is not compatible with Xcode 10.3:

    ld: unsupported tapi file type '!tapi-tbd' in YAML file
    '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libSystem.tbd'
    for architecture x86_64
    clang: error: linker command failed with exit code 1

4 years agoImprove TemporaryFile implementation for Windows (#736)
Nicholas Hutchinson [Mon, 28 Dec 2020 14:22:40 +0000 (14:22 +0000)] 
Improve TemporaryFile implementation for Windows (#736)

On Windows, multiple ccache process could race each other to create,
rename and delete temporary files, because they would attempt to
generate the same sequence of temporary file names
(`tmp.cpp_stdout.iG2Kb7`, `tmp.cpp_stdout.P1kAlM`,
`tmp.cpp_stdout.FzP5tM`, ...).

This is because ccache used mingw-w64's [implementation of mkstemp][1],
which uses `rand()` to generate temporary file names, and ccache was
never seeding the thread-local PRNG used by `rand()`.

Replace ccache's use of `mkstemp()` on Windows with an implementation
based on OpenBSD. This allows us to sidestep mingw-w64's problematic
implementation, and allows us to build using MSVC again. (MSVC's C
standard library does not provide `mkstemp()`.)

Example errors:

- Some ccache process is in the process of deleting a temporary file:

      ccache: error: Failed to create temporary file for C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.FzP5tM: Access is denied.

- Some ccache process has destination file open, so it can't be overwritten:

      ccache: error: failed to rename C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.iG2Kb7 to C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.iG2Kb7.ii: Access is denied.

- Source file has been deleted by some other ccache process:

      ccache: error: failed to rename C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.P1kAlM to C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.P1kAlM.ii: The system cannot find the file specified.

[1]: https://github.com/mirror/mingw-w64/blob/v8.0.0/mingw-w64-crt/misc/mkstemp.c

4 years agoTweak markdown formatting
Joel Rosdahl [Sun, 27 Dec 2020 15:22:39 +0000 (16:22 +0100)] 
Tweak markdown formatting

4 years agoRephrase hint about C-style code left in the code base
Joel Rosdahl [Sun, 27 Dec 2020 15:22:22 +0000 (16:22 +0100)] 
Rephrase hint about C-style code left in the code base