]> git.ipfire.org Git - thirdparty/ccache.git/commit
chore: Remove ability to avoid 2nd call to preprocessor (run_second_cpp)
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 19 Jul 2025 18:43:32 +0000 (20:43 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 21 Jul 2025 12:36:56 +0000 (14:36 +0200)
commitfd9de83446aeaf1eb1b33a2d900ea1ff757c4509
treeafec02fd56246e2f902ffb061569c9b2f04a07aa
parent88e1967fffab8e95e0826453fc60f9b35b75bca3
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.
17 files changed:
doc/MANUAL.adoc
misc/performance
src/ccache/argprocessing.cpp
src/ccache/ccache.cpp
src/ccache/compopt.cpp
src/ccache/config.cpp
src/ccache/config.hpp
test/CMakeLists.txt
test/suites/base.bash
test/suites/clang_cu_nocpp2.bash [deleted file]
test/suites/color_diagnostics.bash
test/suites/cpp1.bash [deleted file]
test/suites/input_charset.bash
test/suites/nocpp2.bash [deleted file]
test/suites/nvcc_nocpp2.bash [deleted file]
unittest/test_argprocessing.cpp
unittest/test_config.cpp