Joel Rosdahl [Sun, 20 Jul 2025 13:41:44 +0000 (15:41 +0200)]
fix: Keep original order of compiler arguments
Now when CCACHE_NOCPP2 (run_second_cpp = false) has been removed (see fd9de83446aeaf1eb1b33a2d900ea1ff757c4509) we can simplify compiler
argument juggling: instead of partitioning arguments into different
lists and reassemble them later, we can build up the preprocessor and
compiler command lines while we go, thus keeping the original order of
arguments.
Joel Rosdahl [Sat, 19 Jul 2025 18:43:32 +0000 (20:43 +0200)]
chore: Remove ability to avoid 2nd call to preprocessor (run_second_cpp)
ccache before version 1.6 (2002) always sent precompiled source to the
compiler as an optimization to avoid running the preprocessor a second
time. ccache 1.6 (2002) introduced CCACHE_CPP2 to optionally disable
this optimization. This seemed to work well until mid 2010s when
compilers started to behave differently when compiling preprocessed and
non-preprocessed source code. Thus, ccache 3.3 (2016) flipped the
default to make the optimization opt-in via CCACHE_NOCPP2 (or
"run_second_cpp = false").
Fast forward to 2025:
- As far as I can tell, CCACHE_NOCPP2 is used by essentially nobody
which isn't surprising since it generally doesn't work well.
- The feature comes with increased code complexity. The most painful
part is that compiler arguments need to be carefully filtered and sent
to only the preprocessor, only the compiler or both, depending on
whether run_second_cpp is true or false. And it can be forced to true
in the middle of argument parsing when an argument that is
incompatible with "run_second_cpp = false" is found.
- There have been a non-trivial amount of bugs related to CCACHE_NOCPP2
during the years due to the added complexity and due to new compiler
behavior that is incompatible with the mode.a
- The depend mode is a more performant alternative to "run_second_cpp =
false" since ccache 3.6 (2019), though with different tradeoffs.
Thus it's time to make the code less complex and more maintainable:
remove the optimization to send the precompiled source code to the
compiler.
This opens up making argument juggling simpler and fixing bug #738.
Joel Rosdahl [Sat, 7 Jun 2025 19:16:30 +0000 (21:16 +0200)]
fix: Detect cc/c++ hard link to clang/clang++ before gcc/g++
Apparently clang/clang++ can be gcc/g++ in addition to cc/c++, at least
on some macOS versions, so detect clang hard link before gcc since the
other way around (gcc installed as an alias of clang) seems less likely.
Gregor Jasny [Sun, 25 May 2025 13:35:53 +0000 (15:35 +0200)]
ci: Use CodeQL v3 (#1592)
This workflow throws an deprecation warning right now:
CodeQL Action major versions v1 and v2 have been deprecated. Please update all occurrences of the CodeQL Action in your workflow files to v3. For more information, see https://github.blog/changelog/2025-01-10-code-scanning-codeql-action-v2-is-now-deprecated/
Joel Rosdahl [Thu, 1 May 2025 15:22:15 +0000 (17:22 +0200)]
ci: Disable testing for Windows MSYS2 mingw64 clang
Clang warns about doctest's include of ciso646:
In file included from D:/a/ccache/ccache/unittest/main.cpp:26:
In file included from D:/a/ccache/ccache/build/_deps/doctest-src/doctest/doctest.h:499:
D:/a/_temp/msys64/mingw64/include/c++/15.1.0/ciso646:46:4: error: "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros" [-Werror,-W#warnings]
46 | # warning "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros"
Joel Rosdahl [Wed, 23 Apr 2025 17:16:24 +0000 (19:16 +0200)]
chore: Split util::split_once into util::split_once{,_to_views}
The util::split_once(std::string&&, char) version is a bit overly smart
in that it returns std::string instead of std::string_view for a
temporary std::string input. To reduce the risk for surprises, introduce
a util::split_once_into_views so that input lifetime is indicated in the
method name instead.
kzlar [Wed, 5 Mar 2025 17:37:04 +0000 (19:37 +0200)]
feat: Add knowledge about options related to react-native builds (#1567)
- Add compopt entries for -ivfsoverlay, -fmodules-cache-path, -fmodule-map-file and -fbuild-session-file
- Add hashing of build session file mtime unless sloppiness flag is set
- Add unit tests for the flags above as well as an e2e test for -fbuild-session-file
feat: Add knowledge about --offload-compress (#1571)
Clang has a feature where it can compress compiler products such as object files, and this includes when it is just called to preprocess the input file.
Ccache expects to be able to process the output of the preprocessor, and is not expecting a compressed binary file.
The fix is to remove this "--offload-compress" option using the existing facilities when preprocessing.