Thomas Otto [Thu, 13 Feb 2020 20:54:19 +0000 (21:54 +0100)]
Added 'make check_format' to makefile rules (#525)
'make format' formats all source files with clang-format, and
'make check_format' only checks and on failure prints a diff,
then exits with the appropriate status.
Because quick interactive formatting is one use case, xargs is
used for parallelism. Proper make-parallelism would require
-k and -j arguments to work.
Joel Rosdahl [Sat, 8 Feb 2020 22:19:18 +0000 (23:19 +0100)]
Improve the failed() and fatal() mechanisms
The failure() and fatal() functions now exit by throwing exceptions that
are caught by the top level functions. This makes it possible to “throw
Failure” in functions that don’t have access to orig_args (or the future
context object).
While at it, renamed top-level functions to better reflect their
purpose.
Thomas Otto [Sat, 8 Feb 2020 16:12:51 +0000 (17:12 +0100)]
Extract setup_config() from initialize() (#534)
Repeated initialize-calls in ccache_main_options() added duplicate exit
functions. These calls had the side effect of passing a config relevant
changes from one command line switch to the next. Instead setup_config()
is now called afterwards.
Joel Rosdahl [Wed, 5 Feb 2020 20:46:29 +0000 (21:46 +0100)]
Improve help text and documentation of command line options
Removed the “=” in “-a, --a-long-option=VALUE” to make it easier to
understand that “-a=VALUE” isn’t supported. Also improved some of the
placeholder names.
Thomas Otto [Sun, 19 Jan 2020 16:49:19 +0000 (17:49 +0100)]
Make cc_process_args() only use local variables
cc_process_args writes into a new ArgsInfo struct and only accesses
local variables (minus guessed_compiler). For now these are mostly
copied into the global variables again after the function call.
Most ccache.cpp global variables moved to legacy_globals.cpp.
Joel Rosdahl [Sat, 25 Jan 2020 10:19:52 +0000 (11:19 +0100)]
Make failure to write a stats file a soft error (#516)
If a stats file update for some reason fails, the exception will bubble
up to ccache_main which just prints the error and exits with an error.
Let’s consider such failures non-fatal and just log them.
Thomas Otto [Sun, 19 Jan 2020 19:47:27 +0000 (20:47 +0100)]
Make failed tests create a testdir.failed symlink (#511)
When the test suite fails 'testdir.failed' now points to the random
'testdir.9876/' directory. This make iterative debugging of failing
tests easier by always using the symlink name or re-issuing 'cd $PWD'
when 'cd'-ed into the 'testdir.failed' directory.
All artifacts can still be removed via 'rm -r testdir.*'.
Joel Rosdahl [Thu, 16 Jan 2020 20:04:09 +0000 (21:04 +0100)]
Send dependency arguments to compiler if run_second_cpp is true
If we run the compiler on the real source code on a cache miss (i.e.,
run_second_cpp is true) we can send the dependency arguments (-MD, etc.)
to the compiler instead of the preprocessor. When doing this there is no
need to add an implicit -MQ option to get the correct object file
location in the dependency file. Do so and also avoid adding an implicit
-MF option since that isn’t needed either. This should re-add support
for EDG-based compilers (see 6d453769 and #460).
If we run the compiler on the preprocessed source code on a cache miss
(i.e., run_second_cpp is false) we still need to let the preprocessor
generate the dependency file (the compiler doesn’t generate a dependency
file when compiling preprocessed source code) and thus we need to add
implicit -MQ and -MF.
This change reverts a fix (97b27781) for the Intel C++ compiler, but if
the Intel compiler still has problems the user can simply avoid setting
run_second_cpp to false.
Joel Rosdahl [Tue, 14 Jan 2020 20:30:29 +0000 (21:30 +0100)]
Avoid passing compilation-only options to the preprocessor redux
25e73c1f (“Include compiler-only arguments in the hash”) attempted to
fix a regression in 5d8585b5 (“Don’t pass -Werror and compilation-only
options to the preprocessor”). It succeeded fixing the regression all
right, but it also essentially reverted the essence of 5d8585b5 (#312)
since compiler-only arguments once again are passed to the preprocessor.
Sigh.
Fix this for real and also write a test that proves it.
Joel Rosdahl [Sat, 4 Jan 2020 18:19:01 +0000 (19:19 +0100)]
Make sure to always log a “Result:” line
Fixes #500.
A side effect of this is that read-only cache misses now will update the
“cache miss” statistics counter, which is consistent with the cache hit
cases (which already now update the counters).
The reason for reverting is that the change introduced a nasty bug: the
dependency file will get an incorrect object file location if 1) build
directory != source directory and 2) -MF is not specified explictly by
the user.
Details: The dependency file is created by the preprocessor pass which
does not have access to the final output file name, so the preprocessor
uses the default object location derived from the source file location
instead.
Note that this partly reverts a compatibility improvement for EDG-based
compilers (see issue #460).
It should be possible to pass the dependency arguments to the compiler
instead of the preprocessor to make -MD/-MMD without -MQ work, but
that’s too risky to be done as a bug fix.
Joel Rosdahl [Sun, 29 Dec 2019 18:21:39 +0000 (19:21 +0100)]
Remove the unify mode
The unify mode has not received enough attention and has at least these
bugs:
1. The direct mode doesn’t work if the unify mode is enabled. This is
because the unify mode doesn’t call into process_preprocessed_file
which stores the paths and hashes of included files needed by the
direct mode.
2. The .incbin directive detection has no effect when using the unify
mode. This is again because the unify mode doesn’t use
process_preprocessed_file which is where the .incbin detection takes
place.
3. The unifier’s tokenizer doesn’t understand C++11 raw string literals.
4. The unifier ignores comments, but comments may have semantic meaning
to modern compilers, e.g. “fall through” comments.
Bugs 3 and 4 are fixable by improving the unifier’s tokenization
algorithm, but since it’s a bit tricky it likely won’t be worth the
effort, especially not as a bug fix.
Bugs 1 and 2 are also fixable by unifying the two code paths, but that’s
a non-trivial effort.
In addition to the bugs, I believe that the usefullness of the unify
mode is low:
* It’s only applicable when not using -g.
* It won't be enabled for C++ unless somebody fixes bug 3.
* It can make line numbers in warning messages and __LINE__ expansions
incorrect.
* Since comments should not be ignored, the unify mode can only make a
difference for some types of whitespace changes, like adding or
removing blank lines or changing a+b to a + b. (a + b is already
normalized to a + b by the preprocessor.)
Therefore I’ll just remove the unify mode to fix the bugs.