Joel Rosdahl [Sun, 16 Feb 2020 12:06:24 +0000 (13:06 +0100)]
Improve functions related to CWD
The different functions related to current working directory (CWD) have
become messy during the years:
- gnu_getcwd is a simple wrapper around getcwd(3), thus returning the
actual canonical path.
- get_cwd returns $PWD, falling back to getcwd(3) if $PWD is not sane.
- get_current_working_dir (local function in ccache.cpp) memoizes
x_realpath(get_cwd()) (i.e., getcwd(3) in essence...) in the global
current_working_dir variable. Unit tests may manipulate
current_working_dir.
Improve this by:
- Replacing gnu_getcwd with Util::get_actual_cwd.
- Replacing get_cwd with Util::get_apparent_cwd.
- Removing get_current_working_dir and placing both actual and apparent
CWD in the context object.
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.