]> git.ipfire.org Git - thirdparty/ccache.git/log
thirdparty/ccache.git
5 years agoFix four minor cppcheck warnings 544/head
Erik Johansson [Sun, 23 Feb 2020 20:56:59 +0000 (21:56 +0100)] 
Fix four minor cppcheck warnings

- uninitvar:src/ccache.cpp:3422: Uninitialized variable: ctx
- redundantInitialization:src/legacy_util.cpp:1067: Redundant initialization
  for 'q'. The initialized value is overwritten before it is read.
- constVariable:src/stats.cpp:429: Variable 'ctx' can be declared with const
- variableScope:src/Util.cpp:404: The scope of the variable 'right' can be
  reduced.

5 years agoPass std::string instead of .c_str()
Erik Johansson [Sun, 23 Feb 2020 20:54:42 +0000 (21:54 +0100)] 
Pass std::string instead of .c_str()

to function taking std::string.

5 years agoRemove unused function stats_get_pending
Erik Johansson [Sun, 23 Feb 2020 20:53:03 +0000 (21:53 +0100)] 
Remove unused function stats_get_pending

5 years agoMake cppcheck, format and check_format work in out-of-tree build
Erik Johansson [Sun, 23 Feb 2020 20:52:02 +0000 (21:52 +0100)] 
Make cppcheck, format and check_format work in out-of-tree build

5 years agoRemove leftover debug settings in test suites
Joel Rosdahl [Sun, 23 Feb 2020 20:37:41 +0000 (21:37 +0100)] 
Remove leftover debug settings in test suites

5 years agoDon’t use realpath(3) for normalization when computing relative paths
Joel Rosdahl [Thu, 20 Feb 2020 20:24:15 +0000 (21:24 +0100)] 
Don’t use realpath(3) for normalization when computing relative paths

The current working directory (CWD) can come from two sources: Either
the return value of getcwd(3) (“actual CWD” below) or the environment
variable $PWD (“apparent CWD” below). The former is returned by e.g.
$(CURDIR) in Makefiles and by “pwd -P” and is always in normalized form
(no “.” or “..” parts or extra slashes). The latter is returned by “echo
$PWD” or “pwd” and can potentially be in unnormalized form on some
systems.

The actual CWD and apparent CWD may also differ if there are symlinks in
the path. Absolute paths to files given to ccache can therefore be based
on either of these CWD forms. When computing relative paths under the
base directory the CWD needs be in normalized form for the algorithm to
be reasonably simple.

2df269a3 solved a bug with an unnormalized apparent CWD by using
realpath(3) for normalization. Using realpath also makes the algorithm
correct in the presence of symlinks. It however also means that all
symlinks (both in CWD and in command line arguments) are dereferenced.
The downside of this is that if either of the symlink targets contain
specific names (such as build ID, date, username or similar) then the
relative paths will also contain those specific path names, leading to
cache misses.

Solve this by:

- Performing normalization without using realpath, i.e. without
  expanding symlinks.
- Computing a relative path based on normalized CWD and normalized path.
- Checking whether the relative path resolves to the same i-node as the
  original path. If it does, use it, otherwise just use the original
  path (and take a potential cache miss).
- Doing the above calculation both for the actual and the apparent CWD
  and choose the best one.

This solves the problem that PR #491 intended to address in a better
way.

5 years agoImprove basedir calculation on Windows
Joel Rosdahl [Sun, 23 Feb 2020 19:45:07 +0000 (20:45 +0100)] 
Improve basedir calculation on Windows

Now basedir with backslashes or forward slashes should work.

5 years agoLet Util::get_apparent_cwd return a normalized CWD
Joel Rosdahl [Thu, 20 Feb 2020 20:23:13 +0000 (21:23 +0100)] 
Let Util::get_apparent_cwd return a normalized CWD

5 years agoAdd Stat::same_inode_as method
Joel Rosdahl [Thu, 20 Feb 2020 20:20:07 +0000 (21:20 +0100)] 
Add Stat::same_inode_as method

5 years agoAdd default Stat constructor
Joel Rosdahl [Thu, 20 Feb 2020 20:05:56 +0000 (21:05 +0100)] 
Add default Stat constructor

5 years agoC++-ify make_relative_path
Joel Rosdahl [Wed, 19 Feb 2020 20:25:49 +0000 (21:25 +0100)] 
C++-ify make_relative_path

5 years agoC++-ify get_relative_path
Joel Rosdahl [Wed, 19 Feb 2020 19:33:46 +0000 (20:33 +0100)] 
C++-ify get_relative_path

5 years agoC++-ify common_dir_prefix_length
Joel Rosdahl [Wed, 19 Feb 2020 18:18:01 +0000 (19:18 +0100)] 
C++-ify common_dir_prefix_length

5 years agoImplement Util::normalize_absolute_path
Joel Rosdahl [Wed, 19 Feb 2020 10:00:24 +0000 (11:00 +0100)] 
Implement Util::normalize_absolute_path

Normalization here means syntactically removing redundant slashes and
resolving "." and ".." parts. The algorithm does however *not* follow
symlinks, so the result may not actually resolve to `path`.

5 years agoMake Util::is_absolute_path work with MSYS/Cygwin/POSIX win32 paths
Joel Rosdahl [Sun, 23 Feb 2020 18:00:59 +0000 (19:00 +0100)] 
Make Util::is_absolute_path work with MSYS/Cygwin/POSIX win32 paths

5 years agoC++-ify is_absolute_path
Joel Rosdahl [Sun, 23 Feb 2020 08:43:41 +0000 (09:43 +0100)] 
C++-ify is_absolute_path

5 years agoSort test cases
Joel Rosdahl [Mon, 17 Feb 2020 20:55:09 +0000 (21:55 +0100)] 
Sort test cases

5 years agoMove basedir tests to the basedir test suite
Joel Rosdahl [Mon, 17 Feb 2020 19:46:05 +0000 (20:46 +0100)] 
Move basedir tests to the basedir test suite

5 years agoAdd pch test suite probe for seemingly broken compiler support
Joel Rosdahl [Sat, 22 Feb 2020 21:18:48 +0000 (22:18 +0100)] 
Add pch test suite probe for seemingly broken compiler support

This fixes a problem mentioned by Orion Poplawski in a comment to PR #217.

5 years agoConst-ify Context& parameters where possible
Joel Rosdahl [Sat, 22 Feb 2020 12:34:18 +0000 (13:34 +0100)] 
Const-ify Context& parameters where possible

5 years agoSimplify setting of ctx.args_info.profile_dir default value
Joel Rosdahl [Sat, 22 Feb 2020 12:33:37 +0000 (13:33 +0100)] 
Simplify setting of ctx.args_info.profile_dir default value

5 years agoConvert stats_update(x) + failed() to failed(x) in hash_*command*()
Joel Rosdahl [Sat, 22 Feb 2020 12:14:21 +0000 (13:14 +0100)] 
Convert stats_update(x) + failed() to failed(x) in hash_*command*()

5 years agoUse find_executable_in_path to find executable in hash_command_output
Joel Rosdahl [Sat, 22 Feb 2020 12:46:30 +0000 (13:46 +0100)] 
Use find_executable_in_path to find executable in hash_command_output

This makes the Windows version behave similar to the non-Windows
version: just search in $PATH, not potentially in the path specified by
the “path” configuration setting.

5 years agoMake failure to run compiler_check command a soft error
Joel Rosdahl [Sat, 22 Feb 2020 12:12:16 +0000 (13:12 +0100)] 
Make failure to run compiler_check command a soft error

No need to make a failure when running the compiler check fatal since
other misconfigured settings can have a similar effect without resulting
in fatal errors.

5 years agoRename cc_process_args to process_args
Joel Rosdahl [Sat, 22 Feb 2020 11:55:22 +0000 (12:55 +0100)] 
Rename cc_process_args to process_args

5 years agoConvert stats_update(x) + failed() to failed(x) in cc_process_args
Joel Rosdahl [Sat, 22 Feb 2020 11:53:15 +0000 (12:53 +0100)] 
Convert stats_update(x) + failed() to failed(x) in cc_process_args

5 years agoConvert most stats_update(x) + failed() to failed(x)
Joel Rosdahl [Sat, 22 Feb 2020 10:03:32 +0000 (11:03 +0100)] 
Convert most stats_update(x) + failed() to failed(x)

5 years agoDon’t increment STATS_COMPILER on fatal error
Joel Rosdahl [Sat, 22 Feb 2020 16:37:22 +0000 (17:37 +0100)] 
Don’t increment STATS_COMPILER on fatal error

Statistics counters are otherwise never incremented on fatal errors.

5 years agoMake it possible to run failed() and not execute the real compiler
Joel Rosdahl [Sat, 22 Feb 2020 16:12:48 +0000 (17:12 +0100)] 
Make it possible to run failed() and not execute the real compiler

This removes one of the last x_exit calls deeper into the main ccache
code paths.

5 years agoRemove leftover cc_reset declaration
Joel Rosdahl [Sat, 22 Feb 2020 11:56:11 +0000 (12:56 +0100)] 
Remove leftover cc_reset declaration

5 years agoMerge pull request #543 from totph/ctx5
Joel Rosdahl [Sat, 22 Feb 2020 20:47:33 +0000 (21:47 +0100)] 
Merge pull request #543 from totph/ctx5

Final Globals -> Context moves

5 years agoTurn lock_staleness_limit into a constant 543/head
Thomas Otto [Sun, 26 Jan 2020 20:34:34 +0000 (21:34 +0100)] 
Turn lock_staleness_limit into a constant

Remove now-empty legacy_globals.cpp/hpp.

5 years agoContext: move counters
Thomas Otto [Mon, 27 Jan 2020 19:22:31 +0000 (20:22 +0100)] 
Context: move counters

5 years agoContext: move ignore_headers_len, remove cc_reset()
Thomas Otto [Mon, 27 Jan 2020 18:57:23 +0000 (19:57 +0100)] 
Context: move ignore_headers_len, remove cc_reset()

5 years agoContext: move included_pch_file and convert to std::string
Thomas Otto [Sun, 26 Jan 2020 20:16:58 +0000 (21:16 +0100)] 
Context: move included_pch_file and convert to std::string

5 years agoContext: move guessed_compiler
Thomas Otto [Sun, 26 Jan 2020 20:14:34 +0000 (21:14 +0100)] 
Context: move guessed_compiler

5 years agoConvert guessed_compiler into an enum class
Thomas Otto [Sun, 26 Jan 2020 20:09:14 +0000 (21:09 +0100)] 
Convert guessed_compiler into an enum class

5 years agoContext: move manifest_stats_file and convert to std::string
Thomas Otto [Sun, 26 Jan 2020 20:03:55 +0000 (21:03 +0100)] 
Context: move manifest_stats_file and convert to std::string

5 years agoContext: move cpp_stderr and convert to std::string
Thomas Otto [Sat, 25 Jan 2020 10:02:07 +0000 (11:02 +0100)] 
Context: move cpp_stderr and convert to std::string

5 years agoContext: move i_tmpfile and converted to std::string
Thomas Otto [Sat, 25 Jan 2020 10:00:35 +0000 (11:00 +0100)] 
Context: move i_tmpfile and converted to std::string

5 years agoContext: move has_absolute_include_headers
Thomas Otto [Sat, 25 Jan 2020 09:55:49 +0000 (10:55 +0100)] 
Context: move has_absolute_include_headers

5 years agoContext: move g_included_files
Thomas Otto [Sat, 25 Jan 2020 09:54:50 +0000 (10:54 +0100)] 
Context: move g_included_files

5 years agoContext: move time_of_compilation, adapt manifest
Thomas Otto [Sat, 25 Jan 2020 09:49:49 +0000 (10:49 +0100)] 
Context: move time_of_compilation, adapt manifest

5 years agoContext: move manifest_path and converted to std::string
Thomas Otto [Sat, 25 Jan 2020 09:46:54 +0000 (10:46 +0100)] 
Context: move manifest_path and converted to std::string

5 years agoContext: move (cached_)result_name/result_path
Thomas Otto [Sat, 25 Jan 2020 09:44:12 +0000 (10:44 +0100)] 
Context: move (cached_)result_name/result_path

Also convert result_path to std::string.

5 years agoContext: move arch_args
Thomas Otto [Sat, 25 Jan 2020 09:40:47 +0000 (10:40 +0100)] 
Context: move arch_args

5 years agoContext: move output_is_precompiled_header
Thomas Otto [Fri, 24 Jan 2020 19:16:47 +0000 (20:16 +0100)] 
Context: move output_is_precompiled_header

5 years agoPartially revert const-ification of context parameters
Thomas Otto [Mon, 17 Feb 2020 20:08:26 +0000 (21:08 +0100)] 
Partially revert const-ification of context parameters

5 years agoImprove functions related to CWD
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.

5 years agoSimplify (non-)freeing of orig_args on failure
Joel Rosdahl [Sun, 16 Feb 2020 20:11:18 +0000 (21:11 +0100)] 
Simplify (non-)freeing of orig_args on failure

5 years agoSimplify string creation from string_view
Joel Rosdahl [Sun, 16 Feb 2020 19:44:42 +0000 (20:44 +0100)] 
Simplify string creation from string_view

5 years agoRemove now redundant resetting of config
Joel Rosdahl [Sun, 16 Feb 2020 18:40:58 +0000 (19:40 +0100)] 
Remove now redundant resetting of config

Since the configuation no longer is global there is no need to reset the
unmodified Config object passed by cct_test_begin to cc_reset.

5 years agoConst-ify context parameters where appropriate
Joel Rosdahl [Sun, 16 Feb 2020 18:14:53 +0000 (19:14 +0100)] 
Const-ify context parameters where appropriate

5 years agoMerge pull request #542 from totph/ctx4
Joel Rosdahl [Sun, 16 Feb 2020 20:12:51 +0000 (21:12 +0100)] 
Merge pull request #542 from totph/ctx4

Context: g_config, stats_file and orig_args moved

5 years agoContext: move orig_args 542/head
Thomas Otto [Sat, 25 Jan 2020 09:38:06 +0000 (10:38 +0100)] 
Context: move orig_args

5 years agoContext: convert stats_file to an std::string
Thomas Otto [Sat, 25 Jan 2020 09:24:35 +0000 (10:24 +0100)] 
Context: convert stats_file to an std::string

Also adapted downstream stats functions.

5 years agoContext: move stats_file
Thomas Otto [Sat, 25 Jan 2020 09:24:35 +0000 (10:24 +0100)] 
Context: move stats_file

5 years agoContext: move g_config
Thomas Otto [Sun, 26 Jan 2020 20:34:40 +0000 (21:34 +0100)] 
Context: move g_config

5 years agoImplement Util::read_link, replacing legacy x_readlink
Joel Rosdahl [Tue, 11 Feb 2020 20:56:02 +0000 (21:56 +0100)] 
Implement Util::read_link, replacing legacy x_readlink

5 years agoImplement Util::real_path, replacing legacy x_realpath
Joel Rosdahl [Tue, 11 Feb 2020 20:34:43 +0000 (21:34 +0100)] 
Implement Util::real_path, replacing legacy x_realpath

5 years agoMerge pull request #541 from totph/ctx3
Joel Rosdahl [Sat, 15 Feb 2020 15:14:35 +0000 (16:14 +0100)] 
Merge pull request #541 from totph/ctx3

Context: move 9 more globals

5 years agoContext: move using_precompiled_header 541/head
Thomas Otto [Fri, 24 Jan 2020 19:23:14 +0000 (20:23 +0100)] 
Context: move using_precompiled_header

5 years agoContext: move profile_use/profile_generate
Thomas Otto [Fri, 24 Jan 2020 19:20:45 +0000 (20:20 +0100)] 
Context: move profile_use/profile_generate

5 years agoContext: move direct_i_file
Thomas Otto [Fri, 24 Jan 2020 19:13:41 +0000 (20:13 +0100)] 
Context: move direct_i_file

5 years agoContext: move profile_dir
Thomas Otto [Fri, 24 Jan 2020 19:11:24 +0000 (20:11 +0100)] 
Context: move profile_dir

5 years agoContext: move profile_arcs
Thomas Otto [Fri, 24 Jan 2020 19:01:03 +0000 (20:01 +0100)] 
Context: move profile_arcs

5 years agoContext: move seen_split_dwarf
Thomas Otto [Fri, 24 Jan 2020 18:59:21 +0000 (19:59 +0100)] 
Context: move seen_split_dwarf

5 years agoContext: move generating_diagnostics
Thomas Otto [Fri, 24 Jan 2020 18:54:21 +0000 (19:54 +0100)] 
Context: move generating_diagnostics

5 years agoContext: move generating_stackusage
Thomas Otto [Fri, 24 Jan 2020 18:49:32 +0000 (19:49 +0100)] 
Context: move generating_stackusage

5 years agoContext: move generating_coverage
Thomas Otto [Fri, 24 Jan 2020 18:45:36 +0000 (19:45 +0100)] 
Context: move generating_coverage

5 years agoRename clang-format.sh to run-clang-format
Joel Rosdahl [Thu, 13 Feb 2020 20:56:54 +0000 (21:56 +0100)] 
Rename clang-format.sh to run-clang-format

This avoids exposing implementation details.

5 years agoBuild static Windows executables
Joel Rosdahl [Thu, 13 Feb 2020 20:45:33 +0000 (21:45 +0100)] 
Build static Windows executables

This makes it possible to run e.g. the unittest binary in Wine.

5 years agoSimplify result_name_from_depfile signature
Joel Rosdahl [Thu, 13 Feb 2020 20:32:07 +0000 (21:32 +0100)] 
Simplify result_name_from_depfile signature

5 years agoSimplify Util::{base,dir}_name
Joel Rosdahl [Wed, 12 Feb 2020 21:06:08 +0000 (22:06 +0100)] 
Simplify Util::{base,dir}_name

This also fixes a bug in the Windows versions.

5 years agoAdded 'make check_format' to makefile rules (#525)
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.

5 years agoMerge pull request #538 from totph/ctx2
Joel Rosdahl [Thu, 13 Feb 2020 20:26:14 +0000 (21:26 +0100)] 
Merge pull request #538 from totph/ctx2

Context: move 7 more globals

5 years agoContext: move generating_dependencies 538/head
Thomas Otto [Fri, 24 Jan 2020 18:40:14 +0000 (19:40 +0100)] 
Context: move generating_dependencies

5 years agoContext: move actual_language
Thomas Otto [Fri, 24 Jan 2020 18:33:43 +0000 (19:33 +0100)] 
Context: move actual_language

5 years agoContext: move output_dwo
Thomas Otto [Fri, 24 Jan 2020 18:26:32 +0000 (19:26 +0100)] 
Context: move output_dwo

5 years agoContext: move output_dia
Thomas Otto [Fri, 24 Jan 2020 18:23:17 +0000 (19:23 +0100)] 
Context: move output_dia

5 years agoContext: move output_cu
Thomas Otto [Fri, 24 Jan 2020 18:19:25 +0000 (19:19 +0100)] 
Context: move output_cu

5 years agoContext: move output_cov
Thomas Otto [Fri, 24 Jan 2020 18:17:54 +0000 (19:17 +0100)] 
Context: move output_cov

5 years agoContext: move output_dep
Thomas Otto [Fri, 24 Jan 2020 18:14:00 +0000 (19:14 +0100)] 
Context: move output_dep

5 years agoTest out-of-tree build in Travis-CI
Joel Rosdahl [Thu, 13 Feb 2020 17:58:18 +0000 (18:58 +0100)] 
Test out-of-tree build in Travis-CI

5 years agoFix out of tree build (#540)
Loïc Yhuel [Thu, 13 Feb 2020 17:53:32 +0000 (18:53 +0100)] 
Fix out of tree build (#540)

The CPPFLAGS contain "-I.", but not "-I$(srcdir)", which means "src/ScopeGuard.hpp" was only
found when building from the source root.

5 years agoSimplify code
Joel Rosdahl [Mon, 10 Feb 2020 20:25:38 +0000 (21:25 +0100)] 
Simplify code

5 years agoMake clang-format comments stable across clang-format versions
Joel Rosdahl [Mon, 10 Feb 2020 20:16:31 +0000 (21:16 +0100)] 
Make clang-format comments stable across clang-format versions

Now at least clang-format 6, 7, 8 and 9 format all code the same.

5 years agoFix formatting
Joel Rosdahl [Mon, 10 Feb 2020 20:14:53 +0000 (21:14 +0100)] 
Fix formatting

5 years agoContext: move output_obj, adapt dump_debug_log_buffer_exitfn
Thomas Otto [Fri, 24 Jan 2020 17:54:04 +0000 (18:54 +0100)] 
Context: move output_obj, adapt dump_debug_log_buffer_exitfn

5 years agoContext: add ArgsInfo and move input_file
Thomas Otto [Fri, 24 Jan 2020 17:40:21 +0000 (18:40 +0100)] 
Context: add ArgsInfo and move input_file

5 years agoContext struct added, returned by initialize()
Thomas Otto [Sun, 19 Jan 2020 17:53:41 +0000 (18:53 +0100)] 
Context struct added, returned by initialize()

The goal is to eventually move almost all global state into Context.

5 years agoUse Config for init_log()
Thomas Otto [Wed, 5 Feb 2020 21:03:24 +0000 (22:03 +0100)] 
Use Config for init_log()

5 years agoRemove superfluous “>” in README
Joel Rosdahl [Sun, 9 Feb 2020 20:48:06 +0000 (21:48 +0100)] 
Remove superfluous “>” in README

5 years agoMention “Supported platforms, compilers and languages” page in README
Joel Rosdahl [Sun, 9 Feb 2020 20:47:07 +0000 (21:47 +0100)] 
Mention “Supported platforms, compilers and languages” page in README

5 years agoImprove the failed() and fatal() mechanisms
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.

5 years agoRemove declaration of unimplemented warn function
Joel Rosdahl [Sat, 8 Feb 2020 18:51:47 +0000 (19:51 +0100)] 
Remove declaration of unimplemented warn function

5 years agoRestore sortedness of Util functions
Joel Rosdahl [Sat, 8 Feb 2020 17:35:37 +0000 (18:35 +0100)] 
Restore sortedness of Util functions

5 years agoUse correct spelling of the verb “set up”
Joel Rosdahl [Sat, 8 Feb 2020 16:14:55 +0000 (17:14 +0100)] 
Use correct spelling of the verb “set up”

5 years agoExtract setup_config() from initialize() (#534)
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.

5 years agoMove logging into separate file (#532)
Thomas Otto [Sat, 8 Feb 2020 16:04:28 +0000 (17:04 +0100)] 
Move logging into separate file (#532)