]> git.ipfire.org Git - thirdparty/ccache.git/log
thirdparty/ccache.git
6 years agoAdd missing headers to release archive list
Joel Rosdahl [Wed, 17 Jul 2019 19:00:11 +0000 (21:00 +0200)] 
Add missing headers to release archive list

6 years agoDon’t build tar.bz2 release archive
Joel Rosdahl [Wed, 17 Jul 2019 18:38:30 +0000 (20:38 +0200)] 
Don’t build tar.bz2 release archive

bz2 seems more or less obsolete since xz compresses better (and
decompresses faster), and gz is more ubiquitous.

6 years agoAdd missing license blurbs to header files
Joel Rosdahl [Wed, 17 Jul 2019 11:59:44 +0000 (13:59 +0200)] 
Add missing license blurbs to header files

6 years agoAdd “and other contributors” to copyright notices
Joel Rosdahl [Wed, 17 Jul 2019 11:45:17 +0000 (13:45 +0200)] 
Add “and other contributors” to copyright notices

6 years agoAdd 64-bit MinGW build
Joel Rosdahl [Wed, 17 Jul 2019 10:59:16 +0000 (12:59 +0200)] 
Add 64-bit MinGW build

6 years agoImprove -x/--show-compression
Joel Rosdahl [Wed, 17 Jul 2019 08:39:30 +0000 (10:39 +0200)] 
Improve -x/--show-compression

- Ignore *.tmp.* files.
- Mention on-disk size (adjusted for disk block size) to make it match
  the cache size reported by “ccache --show-stats”.
- Introduced “space savings” and “of original” percentages.
- Calculate compression ratio only for compressed files.
- Include “incompressible files” size, i.e. total size of .raw files and
  files produced by previous ccache versions.
- Removed file counts since I don’t think that they are of much
  interest.
- Handle unparsable manifest files from previous ccache versions
  gracefully.

6 years agoRemove the kB case from format_*_size* functions
Joel Rosdahl [Wed, 17 Jul 2019 08:28:01 +0000 (10:28 +0200)] 
Remove the kB case from format_*_size* functions

Nobody will ever use or see non-zero kB sizes anyway, and this makes the
zero case for sizes in --show-compression nicer.

6 years agoAdd .editorconfig
Joel Rosdahl [Mon, 15 Jul 2019 20:37:04 +0000 (22:37 +0200)] 
Add .editorconfig

This makes GitHub show tabs as 2 spaces wide, which is what I like (and
also what the code style assumes when counting characters for line
widths).

6 years agoRefactor code for getting manifest/result content size
Joel Rosdahl [Mon, 15 Jul 2019 20:26:41 +0000 (22:26 +0200)] 
Refactor code for getting manifest/result content size

6 years agoDocument -x/--show-compression
Joel Rosdahl [Mon, 15 Jul 2019 20:13:18 +0000 (22:13 +0200)] 
Document -x/--show-compression

6 years agoAdd gitter.im link and badge
Joel Rosdahl [Mon, 15 Jul 2019 20:07:55 +0000 (22:07 +0200)] 
Add gitter.im link and badge

6 years agoNever store stderr output or .d files separately
Joel Rosdahl [Mon, 15 Jul 2019 19:51:10 +0000 (21:51 +0200)] 
Never store stderr output or .d files separately

6 years agoAdd support for file cloning on Mac OS X (APFS)
Joel Rosdahl [Mon, 15 Jul 2019 12:50:28 +0000 (14:50 +0200)] 
Add support for file cloning on Mac OS X (APFS)

6 years agoImplement support for file cloning on Linux (Btrfs/XFS)
Joel Rosdahl [Mon, 15 Jul 2019 12:10:28 +0000 (14:10 +0200)] 
Implement support for file cloning on Linux (Btrfs/XFS)

- Added a new file_clone (CCACHE_FILECLONE) configuration setting. If
  set, ccache uses the FICLONE ioctl if available to clone files to/from
  the cache. If file cloning is not supported by the file system, ccache
  will silently fall back to copying (or hard linking if hard_link is
  enabled).
- Compression will be disabled if file_clone is enabled, just like for
  hard_link.
- file_clone has priority over hard_link.
- Tested on Btrfs and XFS on Linux 5.0.0.

Closes #213.

6 years agoSort envtoconfitems.gperf list
Joel Rosdahl [Mon, 15 Jul 2019 11:23:04 +0000 (13:23 +0200)] 
Sort envtoconfitems.gperf list

6 years agoAdd command to show compression statistics (#440)
Anders Björklund [Mon, 15 Jul 2019 13:28:26 +0000 (15:28 +0200)] 
Add command to show compression statistics (#440)

This will only show information about the files that is knows about
(right magic bytes). So the file count might differ from what is shown
with the regular statistics (which shows all files, including old ones).

The terminology used here is a bit confused, the compression ratio is
supposed to grow upwards. Sometimes known as "space savings" instead,
so list both values (ratio and savings) to make the output more obvious.

6 years agoReimplement the hard link mode
Joel Rosdahl [Fri, 5 Jul 2019 19:43:07 +0000 (21:43 +0200)] 
Reimplement the hard link mode

- Files stored by hard linking are saved as _N.raw files next to their
  .result file, where N is the 0-based index of the entry in the .result
  file.
- The .result file stores expected file sizes for the .raw files and the
  code verifies that they are correct before retrieving the files from
  the cache.
- The manual has been updated to mention the new file size check and
  also some other caveats.

The previous hard link mode implementation was removed in
3999a9ca67e2eabb8457920108b546713f200161 and
a1dbb8a15e034e5a63eb6b4407c9e3ccac469162. The latter commit lists three
points:

1. Hard links are error prone.
2. Compression will make hard links obsolete as a means of saving cache
   space.
3. A future backend storage API will be easier to write.

Point 1 is still true, but since the result file now stores expected
file sizes, many inadvertent modifications of files will be detected.

Point 2 is also still true, but you might want to trade cache size for
speed in cases where increased speed actually is measurable, like with
very large object files.

Point 3 does not quite hold after thinking some more about future APIs.
I think that it will be relatively straight-forward to add operations
like supports_raw_files, get_raw_file and put_raw_file to the API.

6 years agoLet stderr content have an even more special name in result files
Joel Rosdahl [Fri, 5 Jul 2019 19:46:56 +0000 (21:46 +0200)] 
Let stderr content have an even more special name in result files

6 years agoRefactor result_get code into functions per marker type
Joel Rosdahl [Wed, 3 Jul 2019 21:19:59 +0000 (23:19 +0200)] 
Refactor result_get code into functions per marker type

In preparation for reimplementing the hard link mode.

6 years agoAllow NULL checksum parameter for common_header_initialize_for_reading
Joel Rosdahl [Thu, 4 Jul 2019 07:35:05 +0000 (09:35 +0200)] 
Allow NULL checksum parameter for common_header_initialize_for_reading

6 years agoRemove now redundant check for existing result file
Joel Rosdahl [Wed, 3 Jul 2019 18:45:36 +0000 (20:45 +0200)] 
Remove now redundant check for existing result file

6 years agoAvoid logging uninteresting message for deletion of .dwo file
Joel Rosdahl [Wed, 3 Jul 2019 18:44:18 +0000 (20:44 +0200)] 
Avoid logging uninteresting message for deletion of .dwo file

6 years agoSimplify compression_type_from_config
Joel Rosdahl [Wed, 3 Jul 2019 15:26:27 +0000 (17:26 +0200)] 
Simplify compression_type_from_config

6 years agoRefactor common_header_initialize_*
Joel Rosdahl [Wed, 3 Jul 2019 12:36:01 +0000 (14:36 +0200)] 
Refactor common_header_initialize_*

In preparation for adding cache compression statistics and cache
recompression functionality.

6 years agoAvoid letting “-gdwarf*” force “run_second_cpp = true”
Joel Rosdahl [Tue, 2 Jul 2019 12:26:39 +0000 (14:26 +0200)] 
Avoid letting “-gdwarf*” force “run_second_cpp = true”

Fixes #394.

6 years agoImprove error handling and logging of result files copying
Joel Rosdahl [Tue, 2 Jul 2019 12:12:16 +0000 (14:12 +0200)] 
Improve error handling and logging of result files copying

6 years agoProbe whether the compiler produces a .dwo
Joel Rosdahl [Tue, 2 Jul 2019 11:57:11 +0000 (13:57 +0200)] 
Probe whether the compiler produces a .dwo

GCC and Clang behave differently when given e.g. “-gsplit-dwarf -g1”:
GCC produces a .dwo file but Clang doesn’t. Trying to guess how the
different options behave for each compiler is complex and error prone.

Instead, Ccache now probes whether the compiler produced a .dwo and only
stores it if it was produced. On a cache hit, the .dwo is restored if it
exists in the previous result – if it doesn’t exist in the result, it
means that the compilation didn’t produce a .dwo.

Fixes #393.

6 years agoExtract objdump_cmd to test/run where it belongs
Joel Rosdahl [Tue, 2 Jul 2019 11:42:33 +0000 (13:42 +0200)] 
Extract objdump_cmd to test/run where it belongs

6 years agoRemove obsolete conditionals in the split_dwarf test suite
Joel Rosdahl [Tue, 2 Jul 2019 11:21:59 +0000 (13:21 +0200)] 
Remove obsolete conditionals in the split_dwarf test suite

6 years agoAdd --no-compression and --compression-level to misc/performance
Joel Rosdahl [Tue, 2 Jul 2019 08:04:27 +0000 (10:04 +0200)] 
Add --no-compression and --compression-level to misc/performance

6 years agoUse Ubuntu 16.04 for Travis CI
Joel Rosdahl [Tue, 2 Jul 2019 06:25:38 +0000 (08:25 +0200)] 
Use Ubuntu 16.04 for Travis CI

6 years agoQuote CC setting when calling into libzstd’s makefile
Joel Rosdahl [Tue, 2 Jul 2019 06:20:07 +0000 (08:20 +0200)] 
Quote CC setting when calling into libzstd’s makefile

6 years agoExtract code for reading uint64_t in result.c to a macro
Joel Rosdahl [Mon, 1 Jul 2019 18:38:05 +0000 (20:38 +0200)] 
Extract code for reading uint64_t in result.c to a macro

6 years agoExtract common header setup code to functions
Joel Rosdahl [Mon, 1 Jul 2019 14:35:43 +0000 (16:35 +0200)] 
Extract common header setup code to functions

6 years agoAdd checksumming of cached content
Joel Rosdahl [Sun, 30 Jun 2019 12:01:38 +0000 (14:01 +0200)] 
Add checksumming of cached content

Both compressed and uncompressed content are checksummed and verified.
The chosen checksum algorithm is XXH64, which is the same that the zstd
frame format uses (but ccache stores all 64 bits instead of only 32,
because why not?).

6 years agoRequire libzstd and remove zlib support
Joel Rosdahl [Sat, 29 Jun 2019 20:35:50 +0000 (22:35 +0200)] 
Require libzstd and remove zlib support

* zlib has been removed. Good riddance!
* libzstd is now required for building ccache. However, it’s not bundled
  like zlib was.
* To make it easier to build ccache on systems that lack an easily
  installable libzstd, the configure script now offers a
  --with-libzstd-from-internet option, which downloads a zstd source
  release archive, unpacks it in the tree and sets up the Makefile to
  build the library and link ccache (statically) with it.
* Enabled compression by default.
* Made compression level 0 mean “use a default level suitable for the
  current compression algorithm”. For zstd, that’s initially level -1,
  but that could change in the future. The reason for using 0 as a
  special marker is that a future alternative compression algorithm
  could have another reasonable default than zstd. (Let’s hope that
  future algorithms don’t use level 0 for something.)
* Changed default compression level to 0.

Closes #413.

6 years agoEnable build command verbosity in Travis builds
Joel Rosdahl [Sat, 29 Jun 2019 18:39:03 +0000 (20:39 +0200)] 
Enable build command verbosity in Travis builds

This makes it much easier to understand build failures.

6 years agoRestructure Travis configuration
Joel Rosdahl [Sat, 29 Jun 2019 18:39:00 +0000 (20:39 +0200)] 
Restructure Travis configuration

In preparation for switching from zlib to zstd. I find it easier to use
a flat job list instead of a matrix and state settings explicitly for
the different jobs.

6 years agoDon’t enable unit test verbosity in Travis
Joel Rosdahl [Sat, 29 Jun 2019 18:38:56 +0000 (20:38 +0200)] 
Don’t enable unit test verbosity in Travis

It’s way too spammy.

6 years agoRefactor functions for reading/writing common header
Joel Rosdahl [Sat, 29 Jun 2019 18:37:08 +0000 (20:37 +0200)] 
Refactor functions for reading/writing common header

The functions now work on bytes instead of FILEs, allowing for the
caller to optionally peek at read/written bytes.

6 years agoReplace murmurhashneutral2 with xxHash (XXH64)
Joel Rosdahl [Sat, 29 Jun 2019 18:35:48 +0000 (20:35 +0200)] 
Replace murmurhashneutral2 with xxHash (XXH64)

XXH64 is significantly faster than murmurhashneutral2 (on 64-bit
systems, which one can assume ccache almost always is running on these
days). This of course doesn’t matter for keys in hash tables, but it
opens up for using it as a checksumming algorithm for cached data as
well.

6 years agoDon’t try a higher zstd level than supported
Joel Rosdahl [Sat, 29 Jun 2019 18:25:31 +0000 (20:25 +0200)] 
Don’t try a higher zstd level than supported

If the user tries a higher level than supported by libzstd,
initialization will fail. Instead, let’s clamp the level to the highest
supported value.

Regarding negative levels: They are supported from libzstd 1.3.4, but
the query function ZSTD_minCLevel is only supported from 1.4.0 (from
1.3.6 with ZSTD_STATIC_LINKING_ONLY), so let’s not use it for
verification of the level. In libzstd 1.3.3 and older, negative levels
are silently converted to the zstd’s default level (3), so there’s no
major harm done if a user uses a negative level with older libzstd
versions.

6 years agoAllow for negative compression level
Joel Rosdahl [Sat, 29 Jun 2019 18:16:22 +0000 (20:16 +0200)] 
Allow for negative compression level

6 years agoUse the compression API for reading and writing manifests
Joel Rosdahl [Sat, 22 Jun 2019 20:51:42 +0000 (22:51 +0200)] 
Use the compression API for reading and writing manifests

* Manifest and result files now share the same common header (sans the
  magic bytes) and will be compressed using the common compression
  settings.
* Removed the legacy “hash size” and “reserved” fields.

6 years agoTweak code style
Joel Rosdahl [Sat, 22 Jun 2019 20:44:01 +0000 (22:44 +0200)] 
Tweak code style

6 years agoExtract and implement more bytes from/to int macros
Joel Rosdahl [Wed, 19 Jun 2019 19:54:42 +0000 (21:54 +0200)] 
Extract and implement more bytes from/to int macros

6 years agoImprove order of parameters to common_header_*_file
Joel Rosdahl [Wed, 19 Jun 2019 19:47:14 +0000 (21:47 +0200)] 
Improve order of parameters to common_header_*_file

6 years agoExtract header code common to result and manifest files
Joel Rosdahl [Sun, 16 Jun 2019 20:45:04 +0000 (22:45 +0200)] 
Extract header code common to result and manifest files

6 years agoAllow using zstd compresssion instead of zlib (#437)
Anders Björklund [Wed, 26 Jun 2019 19:09:49 +0000 (21:09 +0200)] 
Allow using zstd compresssion instead of zlib (#437)

6 years agoVerify value in “ccache -o key=value”
Joel Rosdahl [Mon, 17 Jun 2019 20:29:12 +0000 (22:29 +0200)] 
Verify value in “ccache -o key=value”

Based on a suggestion by Henri Houder.

6 years agoconst-ify parameters to confitem verifier/formatter
Joel Rosdahl [Mon, 17 Jun 2019 20:28:51 +0000 (22:28 +0200)] 
const-ify parameters to confitem verifier/formatter

6 years agoChange to looser compression_type data type
Joel Rosdahl [Mon, 17 Jun 2019 06:07:33 +0000 (08:07 +0200)] 
Change to looser compression_type data type

This avoids a Clang analyzer warning.

6 years agoRename “filelist” to “result_files”
Joel Rosdahl [Sun, 16 Jun 2019 15:44:07 +0000 (17:44 +0200)] 
Rename “filelist” to “result_files”

6 years agoRefactor compression type/level calculation
Joel Rosdahl [Sun, 16 Jun 2019 15:43:36 +0000 (17:43 +0200)] 
Refactor compression type/level calculation

In preparation for introducing a new manifest format.

6 years agoAdd a content size field to the result file header
Joel Rosdahl [Sun, 16 Jun 2019 14:42:42 +0000 (16:42 +0200)] 
Add a content size field to the result file header

The content size field says how much uncompressed data is stored in the
file. This can be used to relatively quickly determine the compression
rate for the whole cache by only inspecting each file’s header insted of
having to read and decompress all files.

Since the content size needs to be calculated before actually adding the
content to the result file, I’ve reverted back to let the format use a
“number of entries” field instead of an EOF marker (similar to Anders
Björklund’s original work in 0399be2d) since the information about the
number of files now has to be known beforehand.

Another subtle change is that the compression level field now is int8_t
instead of uint8_t to make it possible to record negative levels.

6 years agoDon’t try to parse unimplemented reference entries in result files
Joel Rosdahl [Wed, 12 Jun 2019 16:46:25 +0000 (18:46 +0200)] 
Don’t try to parse unimplemented reference entries in result files

6 years agoRemove now unused x_fstat function
Joel Rosdahl [Mon, 10 Jun 2019 20:55:11 +0000 (22:55 +0200)] 
Remove now unused x_fstat function

6 years agoFix check of destination fd in copy_file
Joel Rosdahl [Mon, 10 Jun 2019 20:53:42 +0000 (22:53 +0200)] 
Fix check of destination fd in copy_file

6 years agoFix possible NULL pointer dereference (#433)
Igor Pylypiv [Mon, 10 Jun 2019 20:52:35 +0000 (13:52 -0700)] 
Fix possible NULL pointer dereference (#433)

cppcheck:
  [src/manifest.c:270] -> [src/manifest.c:269]: (warning)
  Either the condition '!errmsg' is redundant or there is possible null pointer
  dereference: errmsg.

6 years agoImprove naming of things
Joel Rosdahl [Sat, 8 Jun 2019 18:49:39 +0000 (20:49 +0200)] 
Improve naming of things

Some words are being used to mean several things in the code base:

* “object” can mean both “the object file (.o) produced by the compiler”
  and “the result stored in the cache, including e.g. the .o file and .d
  file”.
* “hash” can mean both “the state that the hash_* functions operate on”,
  “the output of a hash function” and “the key used to index results
  and manifests in the cache”.

This commits tries to make the naming more consistent:

* “object” means “the object file (.o) produced by the compiler”
* “result” means “the result stored in the cache, including e.g. the .o
  file and .d file”.
* “struct hash” means “the state that the hash_* functions operate on”.
* “digest” means “the output of a hash function”. However, “hash” is
  still used in documentation and command line output since I think that
  “hash” is easier to understand for most people, especially since
  that’s the term used by Git.
* “name” means “the key used to index results and manifests in the
  cache”.

6 years agoImprove how <MD4, number of hashed bytes> is represented
Joel Rosdahl [Sat, 8 Jun 2019 11:25:49 +0000 (13:25 +0200)] 
Improve how <MD4, number of hashed bytes> is represented

Internally, the tuple <MD4 hash, number of hashed bytes>,which is the
key used for cached results and manifests, was represented as 16 bytes +
1 uint32_t. Externally, i.e. in file names, it was represented as
<MD4>-<size>, with <MD4> being 32 hex digits and <size> being the number
of hashed bytes in human-readable form.

This commits changes the internal representation to 20 bytes, where the
last 4 bytes are the number of hashed bytes in big-endian order. The
external representation has been changed to match this, i.e. to be 40
hex digits. This makes the code slightly less complex and more
consistent. Also, the code that converts the key into string form has
been rewritten to not allocate on the heap but to just write the output
into a buffer owned by the caller.

struct file_hash (16 bytes + 1 uint32_t) has been renamed to struct
digest (20 bytes) in order to emphasize that it represents the output of
a hash algorithm that not necessarily gets file content as its input.

The documentation of the manifest format has been updated to reflect the
logical change of keys, even though the actual serialized content of
manifest files hasn’t changed. While at it, reading of the obsolete
“hash_size” and “reserved” fields has been removed. (Future changes in
the manifest format will be handled by just stepping the version.)

6 years agoAdd binary representation of hash-size (#399)
Anders Björklund [Sat, 8 Jun 2019 19:17:14 +0000 (21:17 +0200)] 
Add binary representation of hash-size (#399)

* Add binary representation of hash-size

Fixed size efficient binary representation data,
instead of the variable size hexadecimal string.

This is suitable for machine use, while the other
is more suitable for human readability as string.

* Promote hex format as a global function

* Add unittest for the format_hex function

Make sure that output is NUL-terminated

6 years agoRemove the hard link mode
Joel Rosdahl [Thu, 6 Jun 2019 18:10:10 +0000 (20:10 +0200)] 
Remove the hard link mode

Rationale:

* The hard link feature is prone to errors: a) changes to files outside
  the cache will corrupt the cache, and b) the mtime field in the file's
  i-node is used for different purposes by ccache and build tools like
  make.
* The upcoming enabling of LZ4 compression by default will make the hard
  link mode obsolete as a means of saving cache space.
* Not supporting hard links will make a future backend storage API
  simpler.

6 years agoMove mtime update into result_get/manifest_get
Joel Rosdahl [Thu, 6 Jun 2019 12:53:40 +0000 (14:53 +0200)] 
Move mtime update into result_get/manifest_get

Housekeeping of cached files belongs to the backend code, not the
frontend.

6 years agoRemove now superfluous test of empty result file
Joel Rosdahl [Thu, 6 Jun 2019 12:51:03 +0000 (14:51 +0200)] 
Remove now superfluous test of empty result file

Empty files are detected as corrupted by result_get.

6 years agoImprove error reporting from read_result
Joel Rosdahl [Thu, 6 Jun 2019 12:46:29 +0000 (14:46 +0200)] 
Improve error reporting from read_result

“ccache --dump-result” now prints the actual error.

6 years agoImprove names of result functions and variables
Joel Rosdahl [Thu, 6 Jun 2019 12:30:06 +0000 (14:30 +0200)] 
Improve names of result functions and variables

6 years agoImprove error handling of (de)compressors
Joel Rosdahl [Thu, 6 Jun 2019 11:44:16 +0000 (13:44 +0200)] 
Improve error handling of (de)compressors

Previously, some kinds of corruption were not detected by the zlib
decompressor since it didn’t check that it had reached the end of the
stream and therefore didn’t verify the Adler-32 checksum.

6 years agoRemove redundant cc_log
Joel Rosdahl [Wed, 5 Jun 2019 20:49:41 +0000 (22:49 +0200)] 
Remove redundant cc_log

6 years agoClean up internal trace code
Joel Rosdahl [Wed, 5 Jun 2019 20:43:50 +0000 (22:43 +0200)] 
Clean up internal trace code

6 years agoRemove obsolete decompression code
Joel Rosdahl [Wed, 5 Jun 2019 20:35:16 +0000 (22:35 +0200)] 
Remove obsolete decompression code

* Remove obsolete decompression functionality from copy_file.
* Removed obsolete move_uncompressed_file.
* Improved return values of copy_file/move_file.

6 years agoRemove obsolete file_is_compressed function
Joel Rosdahl [Wed, 5 Jun 2019 19:53:44 +0000 (21:53 +0200)] 
Remove obsolete file_is_compressed function

6 years agoUncrustify code
Joel Rosdahl [Tue, 4 Jun 2019 20:47:27 +0000 (22:47 +0200)] 
Uncrustify code

6 years agoUse the compression API for results
Joel Rosdahl [Tue, 4 Jun 2019 19:49:52 +0000 (21:49 +0200)] 
Use the compression API for results

It didn’t feel right to use zlib’s gzip format for the embedded content,
especially since other compression libraries don’t support a similar
interface. Therefore, use the standard low-level zlib API instead.

6 years agoAdd compression interface and none/zlib implementations
Joel Rosdahl [Sun, 2 Jun 2019 20:51:42 +0000 (22:51 +0200)] 
Add compression interface and none/zlib implementations

6 years agoRevise disk format for results
Joel Rosdahl [Thu, 30 May 2019 18:37:12 +0000 (20:37 +0200)] 
Revise disk format for results

* Removed unused hash_size and reserved fields. Since there are no
  hashes stored in in the result metadata, hash size is superfluous. The
  reserved bits field is also unnecessary; if we need to change the
  format, we can just step RESULT_VERSION and be done with it.
* Instead of storing file count in the header, store an EOF marker after
  the file entries. The main reason for this is that files then can be
  appended to the result file without having to precalculate how many
  files the result will contain.
* Don’t include trailing NUL in suffix strings since the length is known.
* Instead of potentially compressing the whole file, added an
  uncompressed header telling how/if the rest of the file is
  compressed (which algorithm and level). This makes it possible to more
  efficiently recompress files in a batch job since it’s possible to
  reasonably efficiently check if a cached file should be repacked. The
  reason for not having compression info in each subfile
  header (supporting different compression algorithms/levels per
  subfile) is to make the repacking scenario simpler.
* Prepared for adding support for “reference entries”, which refer to
  other results. There are two potential use cases for reference
  entries: a) deduplication and b) storing partial results with a
  different compression algorithm/level. It’s probably only the
  deduplication use case that is interesting, though. It can be done
  either at cache miss time or later as a batch job. If we really want
  to, we can in the future add similar “raw reference entries” that
  refer to files stored verbatim in the storage, thus re-enabling hard
  link functionality.
* Changed to cCrS as the magic bytes for result files. This is analogous
  to the magic bytes used for manifest files.
* Added documentation of the format.

6 years agoRemove --enabled-aggregated feature toggle
Joel Rosdahl [Thu, 30 May 2019 18:37:06 +0000 (20:37 +0200)] 
Remove --enabled-aggregated feature toggle

6 years agoFix temp file leak in --enabled-aggregated mode
Joel Rosdahl [Sat, 1 Jun 2019 14:46:06 +0000 (16:46 +0200)] 
Fix temp file leak in --enabled-aggregated mode

6 years agoCheck and act on return value from cache_get
Joel Rosdahl [Sat, 1 Jun 2019 14:28:10 +0000 (16:28 +0200)] 
Check and act on return value from cache_get

Otherwise corrupted result files won’t get detected.

6 years agoRemove superfluous dup() call when reading cached result
Joel Rosdahl [Sat, 1 Jun 2019 14:18:56 +0000 (16:18 +0200)] 
Remove superfluous dup() call when reading cached result

6 years agoAdd missing argument to stats_update_size
Joel Rosdahl [Thu, 30 May 2019 18:35:00 +0000 (20:35 +0200)] 
Add missing argument to stats_update_size

This makes --enabled-aggregated work after being rebased to 0b3276d5.

6 years agoAdd aggregated file storing all the results (#408)
Anders Björklund [Tue, 28 May 2019 20:08:32 +0000 (22:08 +0200)] 
Add aggregated file storing all the results (#408)

* Add aggregated file storing all the results

* Add dump result method, for viewing binary

Just show sizes, not contents

* Check the results rather than cache contents

This helps when changing the cache storage

* Rename cache struct to filelist instead

Now that it doesn't really store anything

* Add version and hash size to result header

* Copy files by buffer instead of by byte

* Make aggregated result files optional

This will guard the tests, until ready to integrate

* Fix clang warning about unused macros

* Stray comma in configure broke the Mac build

* Avoid freeing the provided structure

* Avoid getting result from cache twice

* Fix partial read/write after rewrite

* Add test cases for aggregated result

* Fix wrong suffix for the depend file

* Read the .stderr with the rest of result

* Fix test suite only being run for clang

* Respect the compression level for result

6 years agorefactor: Save tmp stderr until done storing (#428)
Anders Björklund [Thu, 30 May 2019 18:55:18 +0000 (20:55 +0200)] 
refactor: Save tmp stderr until done storing (#428)

We might need it for the alternate codepaths

If not using a standard file store, it might
not be possible to move stderr instead of copy.

For those cases, use the temporary file instead.

6 years agoImprove solution to #405
Joel Rosdahl [Sun, 26 May 2019 12:02:02 +0000 (14:02 +0200)] 
Improve solution to #405

Instead of changing the global stats_file value temporarily in
update_manifest, pass which file to update explicitly to
stats_update_size.

6 years agoRemove .xml files in the doc directory on “make distclean”
Joel Rosdahl [Thu, 23 May 2019 18:46:21 +0000 (20:46 +0200)] 
Remove .xml files in the doc directory on “make distclean”

6 years agoMention xsltproc in INSTALL.md
Joel Rosdahl [Tue, 21 May 2019 19:52:27 +0000 (21:52 +0200)] 
Mention xsltproc in INSTALL.md

Related to #425.

6 years agoTweak formatting of manual text and code comments
Joel Rosdahl [Mon, 20 May 2019 19:25:27 +0000 (21:25 +0200)] 
Tweak formatting of manual text and code comments

6 years agoFix PCH detection in depend mode (+test improvements) (#427)
Luboš Luňák [Mon, 20 May 2019 19:18:16 +0000 (21:18 +0200)] 
Fix PCH detection in depend mode (+test improvements) (#427)

* do not refer to Clang's PTH in tests

The PTH feature has been removed (https://reviews.llvm.org/D54547)
and according to the commit it has never really been used. Maybe this
made sense somewhen in the past, but now those .pth files must be PCHs
internally. This commit actually just changes the .pth extensions
to .pch to avoid confusion, technically nothing should change
except for filenames.

* try to share PCH tests between GCC and Clang

Clang is supposed to be a drop-in for GCC, so in general it should
be able to handle everything GCC can. That's not completely true
in practice, there are differences, but it doesn't make sense
to completely duplicate a testcase just because there are some
differences. So start creating a shared common base for the PCH
tests and do separately only tests that act differently.

* more sharing of PCH tests between GCC and Clang

There's e.g. no need to do all kinds of complex tests with both
.gch and .pch with Clang, except for checking that Clang finds
one of them if none is specified explicitly.

* log also when pch usage is detect from pragma pch_preprocess

* try harder to verify in tests that ccache detects PCH changes

Some of the tests did that, e.g. those 'file changed', but e.g. the cached
.gch creation did not. So try to intentionally change the .gch/.h and test
that it leads to a cache miss. Otherwise there might be a hit simply
because ccache failed to detect PCH usage and ignores the .gch completely.

* clean up #include vs -fpch-preprocess in pch tests

As the manpage says, -fpch-preprocess is needed only with the #include
form, otherwise it's pointless.

* do not mention sloppiness in pch tests, only no sloppiness

Since sloppiness is normally required, so no point in stating the obvious.

* test also -include-pch with clang

* hash also pch introduced only using -include

GCC does not output the pch in the .d dependencies file, so without
this there would be false cache hits.

* be consistent about sloppiness in pch tests

create pch -> pch_defines
use pch -> time_macros

* test CCACHE_PCH_EXTSUM more thoroughly and also with -include

* pch test for .gch file being in an extra directory

* doc corrections for how to use PCH with ccache

- ccache will fail to properly detect that -include a.h means using
  a.h.gch if it requires using path from -I (they are not searched)
- -fpch-preprocess does nothing with Clang, it doesn't output
  pragma GCC pch_preprocess and so #include form for PCHs doesn't work

* explain better problems of -MD/-MMD in depend mode

6 years agoHint about not running autogen.sh when building from release archive
Joel Rosdahl [Sat, 11 May 2019 15:24:11 +0000 (17:24 +0200)] 
Hint about not running autogen.sh when building from release archive

Related to #418.

6 years agoTweak issue templates
Joel Rosdahl [Sat, 11 May 2019 15:13:13 +0000 (17:13 +0200)] 
Tweak issue templates

6 years agoImprove CONTRIBUTING.md and pull request template
Joel Rosdahl [Sat, 11 May 2019 15:10:19 +0000 (17:10 +0200)] 
Improve CONTRIBUTING.md and pull request template

6 years agoClean up detection of CI environment
Joel Rosdahl [Sat, 11 May 2019 15:00:21 +0000 (17:00 +0200)] 
Clean up detection of CI environment

“RUN_FROM_BUILD_FARM” was set by the old Samba build farm, so switch to
checking “TRAVIS” instead. Also, keep running in dev mode in Travis.

6 years agoclang's -ftime-trace is too hard (#424)
Luboš Luňák [Sat, 11 May 2019 14:54:00 +0000 (16:54 +0200)] 
clang's -ftime-trace is too hard (#424)

It produces extra .json file with timing information about the compilation.

6 years agoFix make check with "funny" locales (#420)
Luboš Luňák [Sat, 11 May 2019 14:38:33 +0000 (16:38 +0200)] 
Fix make check with "funny" locales (#420)

'ch' in cs_CZ locale is technically just one character, so directory
name 'ccache' fails the test

6 years agoImprove manual text for logging to syslog
Joel Rosdahl [Fri, 10 May 2019 19:47:51 +0000 (21:47 +0200)] 
Improve manual text for logging to syslog

As discussed in #409.

6 years agoImplement optional logging to syslog (#409)
Anders Björklund [Fri, 10 May 2019 19:46:58 +0000 (21:46 +0200)] 
Implement optional logging to syslog (#409)

* Add syslog implementation, for the log_file

The file logger has some issues with large log lines and many jobs,
so provide the "syslog" alternative when doing the ccache logging.

* Add docs on how to filter with rsyslogd(8)

6 years agoImprove performance script
Joel Rosdahl [Fri, 10 May 2019 18:48:07 +0000 (20:48 +0200)] 
Improve performance script

* Measure per-call times instead of totals.
* Use median value instead of mean value.

6 years agoAdd pull request template
Joel Rosdahl [Tue, 7 May 2019 22:06:57 +0000 (00:06 +0200)] 
Add pull request template

6 years agoTweak feature request issue template
Joel Rosdahl [Tue, 7 May 2019 21:56:19 +0000 (23:56 +0200)] 
Tweak feature request issue template

6 years agoHandle unknown manifest version gracefully in --dump-manifest
Joel Rosdahl [Sun, 5 May 2019 19:54:27 +0000 (21:54 +0200)] 
Handle unknown manifest version gracefully in --dump-manifest

Previously “ccache --dump-manifest file” would crash with an assert when
the file did not have the expected version.