]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
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)
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

index 5a62038c618e2d59535e9a3ef7a245153ebdf5a5..e67b3589e219f180020fdd63e4d89f3b8db18b7b 100644 (file)
@@ -1013,31 +1013,6 @@ NOTE: In previous ccache versions this option was called *secondary_storage*
     Windows quoting behavior.
 --
 
-[#config_run_second_cpp]
-*run_second_cpp* (*CCACHE_CPP2* or *CCACHE_NOCPP2*, see _<<Boolean values>>_ above)::
-
-    If true, ccache will first run the preprocessor to preprocess the source
-    code (see _<<The preprocessor mode>>_) and then on a cache miss run the
-    compiler on the source code to get hold of the object file. This is the
-    default.
-+
-If false, ccache will first run preprocessor to preprocess the source code and
-then on a cache miss run the compiler on the _preprocessed source code_ instead
-of the original source code. This makes cache misses slightly faster since the
-source code only has to be preprocessed once. The downside is that some
-compilers won't produce the same result (for instance diagnostics warnings)
-when compiling preprocessed source code.
-+
-A solution to the above mentioned downside is to set *run_second_cpp* to false
-and pass `-fdirectives-only` (for GCC) or `-frewrite-includes` (for Clang) to
-the compiler. This will cause the compiler to leave the macros and other
-preprocessor information, and only process the *#include* directives. When run
-in this way, the preprocessor arguments will be passed to the compiler since it
-still has to do _some_ preprocessing (like macros).
-+
-This option is ignored with MSVC, as there is no way to make it compile without
-preprocessing first.
-
 [#config_sloppiness]
 *sloppiness* (*CCACHE_SLOPPINESS*)::
 
@@ -1703,7 +1678,6 @@ Disadvantages:
 The depend mode will be disabled if any of the following holds:
 
 * <<config_depend_mode,*depend_mode*>> is false.
-* <<config_run_second_cpp,*run_second_cpp*>> is false.
 * The compiler is not generating dependencies using `-MD` or `-MMD` (for MSVC,
   `/showIncludes` is added automatically if not specified by the user).
 
index 93cb2f4f2aa807f6c29d7c8abbf165126d0a07e7..33aff891e6b723fe753fee84905be36307b4eca7 100755 (executable)
@@ -1,6 +1,6 @@
 #! /usr/bin/env python3
 #
-# Copyright (C) 2010-2020 Joel Rosdahl and other contributors
+# Copyright (C) 2010-2025 Joel Rosdahl and other contributors
 #
 # See doc/AUTHORS.adoc for a complete list of contributors.
 #
@@ -107,8 +107,6 @@ def test(tmp_dir, options, compiler_args, source_file):
         environment["CCACHE_HARDLINK"] = "1"
     if options.no_compression:
         environment["CCACHE_NOCOMPRESS"] = "1"
-    if options.no_cpp2:
-        environment["CCACHE_NOCPP2"] = "1"
     if options.no_stats:
         environment["CCACHE_NOSTATS"] = "1"
 
@@ -282,9 +280,6 @@ def main(argv):
         ),
         type="int",
     )
-    op.add_option(
-        "--no-cpp2", help="compile preprocessed output", action="store_true"
-    )
     op.add_option(
         "--no-stats", help="don't write statistics", action="store_true"
     )
@@ -335,7 +330,6 @@ def main(argv):
         print("Compression level:", options.compression_level or "default")
         print("File cloning:", on_off(options.file_clone))
         print("Hard linking:", on_off(options.hardlink))
-        print("No cpp2:", on_off(options.no_cpp2))
         print("No stats:", on_off(options.no_stats))
 
     tmp_dir = "%s/perfdir.%d" % (abspath(options.directory), getpid())
index 2cca1887d27868f23e4cfa5dacc93f6f0faec2e6..ffff647f2ad90452df14ab9e5ab9d668c5703758 100644 (file)
@@ -83,8 +83,6 @@ struct ArgumentProcessingState
   bool found_valid_Fp = false;
   bool found_syntax_only = false;
   ColorDiagnostics color_diagnostics = ColorDiagnostics::automatic;
-  bool found_directives_only = false;
-  bool found_rewrite_includes = false;
   std::unordered_map<std::string, std::vector<std::string>> xarch_args;
   bool found_mf_opt = false;
   bool found_wp_md_or_mmd_opt = false;
@@ -105,15 +103,11 @@ struct ArgumentProcessingState
   std::vector<fs::path> input_files;
 
   // common_args contains all original arguments except:
-  // * those that never should be passed to the preprocessor,
-  // * those that only should be passed to the preprocessor (if run_second_cpp
-  //   is false), and
+  // * those that never should be passed to the preprocessor, and
   // * dependency options (like -MD and friends).
   Args common_args;
 
-  // cpp_args contains arguments that were not added to common_args, i.e. those
-  // that should only be passed to the preprocessor if run_second_cpp is false.
-  // If run_second_cpp is true, they will be passed to the compiler as well.
+  // cpp_args contains arguments that were not added to common_args.
   Args cpp_args;
 
   // dep_args contains dependency options like -MD. They are only passed to the
@@ -492,9 +486,6 @@ process_option_arg(const Context& ctx,
     }
     ++i;
     args_info.arch_args.emplace_back(args[i]);
-    if (args_info.arch_args.size() == 2) {
-      config.set_run_second_cpp(true);
-    }
     return Statistic::none;
   }
 
@@ -979,8 +970,6 @@ process_option_arg(const Context& ctx,
     // Avoid passing -P to the preprocessor since it removes preprocessor
     // information we need.
     state.compiler_only_args.push_back(args[i]);
-    LOG("{} used; not compiling preprocessed code", args[i]);
-    config.set_run_second_cpp(true);
     return Statistic::none;
   }
 
@@ -1093,18 +1082,6 @@ process_option_arg(const Context& ctx,
     }
   }
 
-  // GCC
-  if (arg == "-fdirectives-only") {
-    state.found_directives_only = true;
-    return Statistic::none;
-  }
-
-  // Clang
-  if (arg == "-frewrite-includes") {
-    state.found_rewrite_includes = true;
-    return Statistic::none;
-  }
-
   if (arg == "-fno-pch-timestamp") {
     args_info.fno_pch_timestamp = true;
     state.common_args.push_back(args[i]);
@@ -1437,22 +1414,6 @@ process_args(Context& ctx)
     return tl::unexpected(*argument_error);
   }
 
-  if (state.generating_debuginfo_level_3 && !config.run_second_cpp()) {
-    // Debug level 3 makes line number information incorrect when compiling
-    // preprocessed code.
-    LOG_RAW("Generating debug info level 3; not compiling preprocessed code");
-    config.set_run_second_cpp(true);
-  }
-
-#ifdef __APPLE__
-  // Newer Clang versions on macOS are known to produce different debug
-  // information when compiling preprocessed code.
-  if (args_info.generating_debuginfo && !config.run_second_cpp()) {
-    LOG_RAW("Generating debug info; not compiling preprocessed code");
-    config.set_run_second_cpp(true);
-  }
-#endif
-
   if (state.found_pch || state.found_fpch_preprocess) {
     args_info.using_precompiled_header = true;
     if (!(config.sloppiness().contains(core::Sloppy::time_macros))) {
@@ -1464,12 +1425,6 @@ process_args(Context& ctx)
     }
   }
 
-  if (args_info.profile_generate && !config.run_second_cpp()) {
-    LOG_RAW(
-      "Generating profiling information; not compiling preprocessed code");
-    config.set_run_second_cpp(true);
-  }
-
   if (args_info.profile_path.empty()) {
     args_info.profile_path = ctx.apparent_cwd;
   }
@@ -1532,22 +1487,8 @@ process_args(Context& ctx)
     args_info.generating_dependencies = false;
   }
 
-  if (!config.run_second_cpp()
-      && (args_info.actual_language == "cu"
-          || args_info.actual_language == "cuda")) {
-    LOG("Source language is \"{}\"; not compiling preprocessed code",
-        args_info.actual_language);
-    config.set_run_second_cpp(true);
-  }
-
   args_info.direct_i_file = language_is_preprocessed(args_info.actual_language);
 
-  if (args_info.output_is_precompiled_header && !config.run_second_cpp()) {
-    // It doesn't work to create the .gch from preprocessed source.
-    LOG_RAW("Creating precompiled header; not compiling preprocessed code");
-    config.set_run_second_cpp(true);
-  }
-
   if (config.cpp_extension().empty()) {
     std::string p_language = p_language_for_language(args_info.actual_language);
     config.set_cpp_extension(extension_for_language(p_language).substr(1));
@@ -1621,21 +1562,6 @@ process_args(Context& ctx)
   if (args_info.generating_dependencies) {
     if (state.output_dep_origin == OutputDepOrigin::none) {
       args_info.output_dep = util::with_extension(args_info.output_obj, ".d");
-      if (!config.run_second_cpp()) {
-        // If we're compiling preprocessed code we're sending dep_args to the
-        // preprocessor so we need to use -MF to write to the correct .d file
-        // location since the preprocessor doesn't know the final object path.
-        state.dep_args.push_back("-MF");
-        state.dep_args.push_back(args_info.output_dep);
-      }
-    }
-
-    if (!args_info.dependency_target && !config.run_second_cpp()) {
-      // If we're compiling preprocessed code we're sending dep_args to the
-      // preprocessor so we need to use -MQ to get the correct target object
-      // file in the .d file.
-      state.dep_args.push_back("-MQ");
-      state.dep_args.push_back(args_info.output_obj);
     }
 
     if (!args_info.dependency_target) {
@@ -1690,31 +1616,7 @@ process_args(Context& ctx)
   Args compiler_args = state.common_args;
   compiler_args.push_back(state.compiler_only_args_no_hash);
   compiler_args.push_back(state.compiler_only_args);
-
-  if (config.run_second_cpp()) {
-    compiler_args.push_back(state.cpp_args);
-  } else if (state.found_directives_only || state.found_rewrite_includes) {
-    // Need to pass the macros and any other preprocessor directives again.
-    compiler_args.push_back(state.cpp_args);
-    if (state.found_directives_only) {
-      state.cpp_args.push_back("-fdirectives-only");
-      // The preprocessed source code still needs some more preprocessing.
-      compiler_args.push_back("-fpreprocessed");
-      compiler_args.push_back("-fdirectives-only");
-    }
-    if (state.found_rewrite_includes) {
-      state.cpp_args.push_back("-frewrite-includes");
-      // The preprocessed source code still needs some more preprocessing.
-      compiler_args.push_back("-x");
-      compiler_args.push_back(args_info.actual_language);
-    }
-  } else if (!state.explicit_language.empty()) {
-    // Workaround for a bug in Apple's patched distcc -- it doesn't properly
-    // reset the language specified with -x, so if -x is given, we have to
-    // specify the preprocessed language explicitly.
-    compiler_args.push_back("-x");
-    compiler_args.push_back(p_language_for_language(state.explicit_language));
-  }
+  compiler_args.push_back(state.cpp_args);
 
   if (state.found_c_opt) {
     compiler_args.push_back("-c");
@@ -1750,34 +1652,16 @@ process_args(Context& ctx)
 
   Args preprocessor_args = state.common_args;
   preprocessor_args.push_back(state.cpp_args);
-
-  if (config.run_second_cpp()) {
-    // When not compiling the preprocessed source code, only pass dependency
-    // arguments to the compiler to avoid having to add -MQ, supporting e.g.
-    // EDG-based compilers which don't support -MQ.
-    compiler_args.push_back(state.dep_args);
-  } else {
-    // When compiling the preprocessed source code, pass dependency arguments to
-    // the preprocessor since the compiler doesn't produce a .d file when
-    // compiling preprocessed source code.
-    preprocessor_args.push_back(state.dep_args);
-  }
+  compiler_args.push_back(state.dep_args);
 
   Args extra_args_to_hash = state.compiler_only_args;
-  if (config.run_second_cpp()) {
-    extra_args_to_hash.push_back(state.dep_args);
-  }
+  extra_args_to_hash.push_back(state.dep_args);
   if (state.hash_full_command_line) {
     extra_args_to_hash.push_back(ctx.orig_args);
   }
 
   if (diagnostics_color_arg) {
     compiler_args.push_back(*diagnostics_color_arg);
-    if (!config.run_second_cpp()) {
-      // If we're compiling preprocessed code we're keeping any warnings from
-      // the preprocessor, so we need to make sure that they are in color.
-      preprocessor_args.push_back(*diagnostics_color_arg);
-    }
   }
 
   if (ctx.config.depend_mode() && !args_info.generating_includes
index c820b68373f1bff9affc21b536999188f48f852e..1dce4eda51357c2942184439b8abf23826c2e4ca 100644 (file)
@@ -1202,12 +1202,8 @@ to_cache(Context& ctx,
     args.push_back("--");
   }
 
-  if (ctx.config.run_second_cpp()) {
-    args.push_back(
-      FMT("{}{}", ctx.args_info.input_file_prefix, ctx.args_info.input_file));
-  } else {
-    args.push_back(ctx.i_tmpfile);
-  }
+  args.push_back(
+    FMT("{}{}", ctx.args_info.input_file_prefix, ctx.args_info.input_file));
 
   if (ctx.args_info.seen_split_dwarf) {
     // Remove any pre-existing .dwo file since we want to check if the compiler
@@ -1463,14 +1459,6 @@ get_result_key_from_cpp(Context& ctx, Args& args, Hash& hash)
 
   ctx.i_tmpfile = preprocessed_path;
 
-  if (!ctx.config.run_second_cpp()) {
-    // If we are using the CPP trick, we need to remember this stderr data and
-    // output it just before the main stderr from the compiler pass.
-    ctx.cpp_stderr_data = std::move(cpp_stderr_data);
-    hash.hash_delimiter("runsecondcpp");
-    hash.hash("false");
-  }
-
   return hash.digest();
 }
 
@@ -2727,15 +2715,9 @@ do_cache_compilation(Context& ctx)
     }
   }
 
-  if (!ctx.config.run_second_cpp() && ctx.config.is_compiler_group_msvc()) {
-    LOG_RAW("Second preprocessor cannot be disabled");
-    ctx.config.set_run_second_cpp(true);
-  }
-
   if (ctx.config.depend_mode()
-      && !(ctx.config.run_second_cpp()
-           && (ctx.args_info.generating_dependencies
-               || ctx.args_info.generating_includes))) {
+      && !(ctx.args_info.generating_dependencies
+           || ctx.args_info.generating_includes)) {
     LOG_RAW("Disabling depend mode");
     ctx.config.set_depend_mode(false);
   }
index aca1609ea5c1d7827b737ecefe3e6367a8929f38..9ec8e68ba5a01d0507a8663304237390b7dcf020 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -36,8 +36,8 @@ int TAKES_CONCAT_ARG = 1 << 3;
 // used.
 int TAKES_PATH = 1 << 4;
 
-// The option only affects preprocessing; not passed to the compiler if
-// run_second_cpp is false.
+// The option only affects preprocessing; not included in the input hash in
+// preprocessor mode.
 int AFFECTS_CPP = 1 << 5;
 
 // The option only affects compilation; not passed to the preprocessor.
index 66b89655da522294922d12a86fc06661faa29d58..9ccf43ef4a5fa0c313b2063b6d22620c69a2b722 100644 (file)
@@ -112,7 +112,6 @@ enum class ConfigItem : uint8_t {
   remote_storage,
   reshare,
   response_file_format,
-  run_second_cpp,
   sloppiness,
   stats,
   stats_log,
@@ -169,7 +168,6 @@ const std::unordered_map<std::string, ConfigKeyTableEntry> k_config_key_table =
     {"remote_storage",             {ConfigItem::remote_storage}                  },
     {"reshare",                    {ConfigItem::reshare}                         },
     {"response_file_format",       {ConfigItem::response_file_format}            },
-    {"run_second_cpp",             {ConfigItem::run_second_cpp}                  },
     {"secondary_storage",          {ConfigItem::remote_storage, "remote_storage"}},
     {"sloppiness",                 {ConfigItem::sloppiness}                      },
     {"stats",                      {ConfigItem::stats}                           },
@@ -188,7 +186,6 @@ const std::unordered_map<std::string, std::string> k_env_variable_table = {
   {"COMPILERTYPE",         "compiler_type"             },
   {"COMPRESS",             "compression"               },
   {"COMPRESSLEVEL",        "compression_level"         },
-  {"CPP2",                 "run_second_cpp"            },
   {"DEBUG",                "debug"                     },
   {"DEBUGDIR",             "debug_dir"                 },
   {"DEBUGLEVEL",           "debug_level"               },
@@ -918,9 +915,6 @@ Config::get_string_value(const std::string& key) const
   case ConfigItem::response_file_format:
     return response_file_format_to_string(m_response_file_format);
 
-  case ConfigItem::run_second_cpp:
-    return format_bool(m_run_second_cpp);
-
   case ConfigItem::sloppiness:
     return format_sloppiness(m_sloppiness);
 
@@ -1189,10 +1183,6 @@ Config::set_item(const std::string& key,
     m_response_file_format = parse_response_file_format(value);
     break;
 
-  case ConfigItem::run_second_cpp:
-    m_run_second_cpp = parse_bool(value, env_var_key, negate);
-    break;
-
   case ConfigItem::sloppiness:
     m_sloppiness = parse_sloppiness(value);
     break;
index 659f2cc335f1a6df463afd6663e87b070b790d1c..40d87c768a5262d08ebde72a68cd26143aaa4bb9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -94,7 +94,6 @@ public:
   bool remote_only() const;
   const std::string& remote_storage() const;
   bool reshare() const;
-  bool run_second_cpp() const;
   core::Sloppiness sloppiness() const;
   bool stats() const;
   const std::filesystem::path& stats_log() const;
@@ -125,7 +124,6 @@ public:
   void set_inode_cache(bool value);
   void set_max_files(uint64_t value);
   void set_msvc_dep_prefix(const std::string& value);
-  void set_run_second_cpp(bool value);
   void set_temporary_dir(const std::filesystem::path& value);
 
   // Where to write configuration changes.
@@ -214,7 +212,6 @@ private:
   bool m_read_only_direct = false;
   bool m_recache = false;
   bool m_reshare = false;
-  bool m_run_second_cpp = true;
   bool m_remote_only = false;
   std::string m_remote_storage;
   core::Sloppiness m_sloppiness;
@@ -480,12 +477,6 @@ Config::reshare() const
   return m_reshare;
 }
 
-inline bool
-Config::run_second_cpp() const
-{
-  return m_run_second_cpp;
-}
-
 inline bool
 Config::remote_only() const
 {
@@ -627,12 +618,6 @@ Config::set_msvc_dep_prefix(const std::string& value)
   m_msvc_dep_prefix = value;
 }
 
-inline void
-Config::set_run_second_cpp(bool value)
-{
-  m_run_second_cpp = value;
-}
-
 inline void
 Config::set_temporary_dir(const std::filesystem::path& value)
 {
index b3139392d797681fbaf5eb96be458ebba15dd1b5..ab3c3b9f58026b7680b0dcc8801281e78946df2b 100644 (file)
@@ -26,11 +26,9 @@ addtest(cache_levels)
 addtest(clang_cu)
 addtest(clang_cu_alias)
 addtest(clang_cu_direct)
-addtest(clang_cu_nocpp2)
 addtest(cleanup)
 addtest(color_diagnostics)
 addtest(config)
-addtest(cpp1)
 addtest(debug_compilation_dir)
 addtest(debug_prefix_map)
 addtest(depend)
@@ -45,11 +43,9 @@ addtest(modules)
 addtest(multi_arch)
 addtest(namespace)
 addtest(no_compression)
-addtest(nocpp2)
 addtest(nvcc)
 addtest(nvcc_direct)
 addtest(nvcc_ldir)
-addtest(nvcc_nocpp2)
 addtest(pch)
 addtest(profiling)
 addtest(profiling_clang)
@@ -73,4 +69,3 @@ addtest(split_dwarf)
 addtest(stats_log)
 addtest(trim_dir)
 addtest(upgrade)
-
index ac7bc1571f45a6e87a6e6eb1a65df825280ef286..ab1bd9cbd761a2d15f626a66ce9a5c1625511795 100644 (file)
@@ -1374,7 +1374,7 @@ EOF
     expect_equal_text_content stderr_2_ref.txt stderr_2.txt
 
     # -------------------------------------------------------------------------
-    TEST "Merging stderr"
+    TEST "Stderr from cpp not emitted"
 
     cat >compiler.sh <<EOF
 #!/bin/sh
@@ -1388,19 +1388,12 @@ fi
 EOF
     chmod +x compiler.sh
 
-    unset CCACHE_NOCPP2
     stderr=$($CCACHE ./compiler.sh -c test1.c 2>stderr)
     expect_stat preprocessed_cache_hit 0
     expect_stat cache_miss 1
     expect_stat files_in_cache 1
     expect_content stderr "[cc_stderr]"
 
-    stderr=$(CCACHE_NOCPP2=1 $CCACHE ./compiler.sh -c test1.c 2>stderr)
-    expect_stat preprocessed_cache_hit 0
-    expect_stat cache_miss 2
-    expect_stat files_in_cache 2
-    expect_content stderr "[cpp_stderr][cc_stderr]"
-
     # -------------------------------------------------------------------------
     TEST "Stderr and dependency file"
 
@@ -1654,9 +1647,7 @@ EOF
     expect_stat preprocessed_cache_hit 0
     expect_stat cache_miss 1
     expect_stat files_in_cache 1
-    if [ -z "$CCACHE_NOCPP2" ]; then
-        expect_content_pattern compiler.args "(-E -o * test1.c)(-c -o test1.o test1.c)"
-    fi
+    expect_content_pattern compiler.args "(-E -o * test1.c)(-c -o test1.o test1.c)"
     rm compiler.args
 
     $CCACHE ./compiler.sh -c test1.c
@@ -1672,9 +1663,7 @@ EOF
     expect_stat preprocessed_cache_hit 1
     expect_stat cache_miss 2
     expect_stat files_in_cache 2
-    if [ -z "$CCACHE_NOCPP2" ]; then
-        expect_content_pattern compiler.args "(-E -o * test1.c)(-Werror -rdynamic -c -o test1.o test1.c)"
-    fi
+    expect_content_pattern compiler.args "(-E -o * test1.c)(-Werror -rdynamic -c -o test1.o test1.c)"
     rm compiler.args
 
     # -------------------------------------------------------------------------
diff --git a/test/suites/clang_cu_nocpp2.bash b/test/suites/clang_cu_nocpp2.bash
deleted file mode 100644 (file)
index 84672eb..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-SUITE_clang_cu_nocpp2_PROBE() {
-    clang_cu_PROBE
-}
-
-SUITE_clang_cu_nocpp2_SETUP() {
-    export CCACHE_NOCPP2=1
-
-    clang_cu_SETUP
-}
-
-SUITE_clang_cu_nocpp2() {
-    clang_cu_tests
-}
index 77a45800cd7ad41adc496b2b13cda203d58aaf2c..0aef2b595634d2ba91be3f0ad7f69c6db65da5f9 100644 (file)
@@ -28,12 +28,6 @@ SUITE_color_diagnostics_PROBE() {
 }
 
 SUITE_color_diagnostics_SETUP() {
-    if $run_second_cpp; then
-        export CCACHE_CPP2=1
-    else
-        export CCACHE_NOCPP2=1
-    fi
-
     unset GCC_COLORS
     export TERM=vt100
 }
@@ -93,9 +87,9 @@ color_diagnostics_run_on_pty() {
     done
 }
 
-color_diagnostics_test() {
+SUITE_color_diagnostics() {
     # -------------------------------------------------------------------------
-    TEST "Colored diagnostics automatically disabled when stderr is not a TTY (run_second_cpp=$run_second_cpp)"
+    TEST "Colored diagnostics automatically disabled when stderr is not a TTY"
 
     color_diagnostics_generate_code test1.c
     $CCACHE_COMPILE -Wreturn-type -c -o test1.o test1.c 2>test1.stderr
@@ -108,7 +102,7 @@ color_diagnostics_test() {
     expect_stat preprocessed_cache_hit 1
 
     # -------------------------------------------------------------------------
-    TEST "Colored diagnostics automatically enabled when stderr is a TTY (run_second_cpp=$run_second_cpp)"
+    TEST "Colored diagnostics automatically enabled when stderr is a TTY"
 
     color_diagnostics_generate_code test1.c
     color_diagnostics_run_on_pty test1.output "$CCACHE_COMPILE -Wreturn-type -c -o test1.o test1.c"
@@ -169,7 +163,7 @@ color_diagnostics_test() {
 
     while read -r case; do
         # ---------------------------------------------------------------------
-        TEST "Cache object shared across ${case} (run_second_cpp=$run_second_cpp)"
+        TEST "Cache object shared across ${case}"
 
         color_diagnostics_generate_code test1.c
         local each
@@ -202,8 +196,3 @@ color_diagnostics_test() {
         color_diagnostics_generate_permutations "${#A[@]}"
     )
 }
-
-SUITE_color_diagnostics() {
-    run_second_cpp=true color_diagnostics_test
-    run_second_cpp=false color_diagnostics_test
-}
diff --git a/test/suites/cpp1.bash b/test/suites/cpp1.bash
deleted file mode 100644 (file)
index 26d1b5b..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-SUITE_cpp1_PROBE() {
-    touch test.c
-    if $COMPILER_TYPE_GCC; then
-        if ! $COMPILER -E -fdirectives-only test.c >&/dev/null; then
-            echo "-fdirectives-only not supported by compiler"
-            return
-        fi
-    elif $COMPILER_TYPE_CLANG; then
-        if ! $COMPILER -E -frewrite-includes test.c >&/dev/null; then
-            echo "-frewrite-includes not supported by compiler"
-            return
-        fi
-        if $HOST_OS_WINDOWS && ! $COMPILER_USES_MSVC; then
-            echo "This test is broken on msys2 clang: Stores wrong file names like 'tmp.cpp_stdout.2Gq' instead of 'test1.c'."
-            return
-        fi
-    else
-        echo "Unknown compiler: $COMPILER"
-        return
-    fi
-}
-
-SUITE_cpp1_SETUP() {
-    export CCACHE_NOCPP2=1
-    echo "#define FOO 1" >test1.h
-    backdate test1.h
-    echo '#include "test1.h"' >test1.c
-    echo '#define BAR 2' >>test1.c
-    echo 'int foo(int x) { return FOO; }' >>test1.c
-    echo 'int bar(int x) { return BAR; }' >>test1.c
-    echo 'int baz(int x) { return BAZ; }' >>test1.c
-}
-
-SUITE_cpp1() {
-    if $COMPILER_TYPE_GCC; then
-        cpp_flag="-fdirectives-only"
-    elif $COMPILER_TYPE_CLANG; then
-        cpp_flag="-frewrite-includes"
-    fi
-    cpp_flag="$cpp_flag -DBAZ=3"
-
-    # -------------------------------------------------------------------------
-    TEST "Base case"
-
-    $COMPILER $cpp_flag -c -o reference_test1.o test1.c
-
-    $CCACHE_COMPILE $cpp_flag -c test1.c
-    expect_stat direct_cache_hit 0
-    expect_stat preprocessed_cache_hit 0
-    expect_stat cache_miss 1
-    expect_stat files_in_cache 1
-    expect_equal_object_files reference_test1.o test1.o
-
-    unset CCACHE_NODIRECT
-
-    $CCACHE_COMPILE $cpp_flag -c test1.c
-    expect_stat direct_cache_hit 0
-    expect_stat preprocessed_cache_hit 1
-    expect_stat cache_miss 1
-    expect_stat files_in_cache 2
-    expect_equal_object_files reference_test1.o test1.o
-
-    $CCACHE_COMPILE $cpp_flag -c test1.c
-    expect_stat direct_cache_hit 1
-    expect_stat preprocessed_cache_hit 1
-    expect_stat cache_miss 1
-    expect_stat files_in_cache 2
-    expect_equal_object_files reference_test1.o test1.o
-}
index 833ab3b47af1b70fd2501940f2c9e9b6aba13938..74c411ac7bd7605236e58c200ef5a63ecf59014d 100644 (file)
@@ -18,12 +18,4 @@ SUITE_input_charset() {
     $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
     expect_stat preprocessed_cache_hit 1
     expect_stat cache_miss 1
-
-    CCACHE_NOCPP2=1 $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
-    expect_stat preprocessed_cache_hit 1
-    expect_stat cache_miss 2
-
-    CCACHE_NOCPP2=1 $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
-    expect_stat preprocessed_cache_hit 2
-    expect_stat cache_miss 2
 }
diff --git a/test/suites/nocpp2.bash b/test/suites/nocpp2.bash
deleted file mode 100644 (file)
index 6768776..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-SUITE_nocpp2_PROBE() {
-    if $HOST_OS_WINDOWS; then
-        echo "CCACHE_NOCPP2 does not work correct on Windows"
-        return
-    fi
-}
-
-SUITE_nocpp2_SETUP() {
-    export CCACHE_NOCPP2=1
-    generate_code 1 test1.c
-}
-
-SUITE_nocpp2() {
-    base_tests
-}
diff --git a/test/suites/nvcc_nocpp2.bash b/test/suites/nvcc_nocpp2.bash
deleted file mode 100644 (file)
index 8af57f7..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-SUITE_nvcc_nocpp2_PROBE() {
-    nvcc_PROBE
-}
-
-SUITE_nvcc_nocpp2_SETUP() {
-    export CCACHE_NOCPP2=1
-    nvcc_SETUP
-}
-
-SUITE_nvcc_nocpp2() {
-    nvcc_tests
-}
index 68687ec5ef2d53e847e3180c3f339b507b57e7ee..919eecc9272bc81796327a8099d4e5b85bb6ff06 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -96,26 +96,7 @@ TEST_CASE("dash_M_should_be_unsupported")
   CHECK(process_args(ctx).error() == Statistic::unsupported_compiler_option);
 }
 
-TEST_CASE("dependency_args_to_preprocessor_if_run_second_cpp_is_false")
-{
-  TestContext test_context;
-  const std::string dep_args =
-    "-MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2 -Wp,-MP"
-    " -Wp,-MT,wpmt -Wp,-MQ,wpmq -Wp,-MF,wpf";
-  Context ctx;
-  ctx.orig_args = Args::from_string("cc " + dep_args + " -c foo.c -o foo.o");
-  util::write_file("foo.c", "");
-  ctx.config.set_run_second_cpp(false);
-
-  const auto result = process_args(ctx);
-
-  CHECK(result);
-  CHECK(result->preprocessor_args.to_string() == "cc " + dep_args);
-  CHECK(result->extra_args_to_hash.to_string() == "");
-  CHECK(result->compiler_args.to_string() == "cc -c");
-}
-
-TEST_CASE("dependency_args_to_compiler_if_run_second_cpp_is_true")
+TEST_CASE("dependency_args_to_compiler")
 {
   TestContext test_context;
   const std::string dep_args =
@@ -133,34 +114,7 @@ TEST_CASE("dependency_args_to_compiler_if_run_second_cpp_is_true")
   CHECK(result->compiler_args.to_string() == "cc -c " + dep_args);
 }
 
-TEST_CASE("cpp_only_args_to_preprocessor_if_run_second_cpp_is_false")
-{
-  TestContext test_context;
-  const std::string cpp_args =
-    "-I. -idirafter . -iframework. -imacros . -imultilib . -include test.h"
-    " -include-pch test.pch -iprefix . -iquote . -isysroot . -isystem ."
-    " -iwithprefix . -iwithprefixbefore . -DTEST_MACRO -DTEST_MACRO2=1 -F."
-    " -trigraphs -fworking-directory -fno-working-directory";
-  const std::string dep_args =
-    "-MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2 -Wp,-MP"
-    " -Wp,-MT,wpmt -Wp,-MQ,wpmq -Wp,-MF,wpf";
-  Context ctx;
-  ctx.orig_args =
-    Args::from_string("cc " + cpp_args + " " + dep_args + " -c foo.c -o foo.o");
-  util::write_file("foo.c", "");
-  ctx.config.set_run_second_cpp(false);
-
-  const auto result = process_args(ctx);
-
-  CHECK(result);
-  CHECK(result->preprocessor_args.to_string()
-        == "cc " + cpp_args + " " + dep_args);
-  CHECK(result->extra_args_to_hash.to_string() == "");
-  CHECK(result->compiler_args.to_string() == "cc -c");
-}
-
-TEST_CASE(
-  "cpp_only_args_to_preprocessor_and_compiler_if_run_second_cpp_is_true")
+TEST_CASE("cpp_only_args_to_preprocessor_and_compiler")
 {
   TestContext test_context;
   const std::string cpp_args =
@@ -201,68 +155,6 @@ TEST_CASE(
   CHECK(result->compiler_args.to_string() == "cc -c " + dep_args);
 }
 
-TEST_CASE("MQ_flag_should_not_be_added_if_run_second_cpp_is_true")
-{
-  TestContext test_context;
-  Context ctx;
-  ctx.orig_args = Args::from_string("cc -c -MD foo.c -MF foo.d -o foo.o");
-  util::write_file("foo.c", "");
-
-  const auto result = process_args(ctx);
-
-  CHECK(result);
-  CHECK(result->preprocessor_args.to_string() == "cc");
-  CHECK(result->extra_args_to_hash.to_string() == "-MD -MF foo.d");
-  CHECK(result->compiler_args.to_string() == "cc -c -MD -MF foo.d");
-}
-
-TEST_CASE("MQ_flag_should_be_added_if_run_second_cpp_is_false")
-{
-  TestContext test_context;
-  Context ctx;
-  ctx.orig_args = Args::from_string("cc -c -MD foo.c -MF foo.d -o foo.o");
-  util::write_file("foo.c", "");
-  ctx.config.set_run_second_cpp(false);
-
-  const auto result = process_args(ctx);
-
-  CHECK(result);
-  CHECK(result->preprocessor_args.to_string() == "cc -MD -MF foo.d -MQ foo.o");
-  CHECK(result->extra_args_to_hash.to_string() == "");
-  CHECK(result->compiler_args.to_string() == "cc -c");
-}
-
-TEST_CASE("MF_should_be_added_if_run_second_cpp_is_false")
-{
-  TestContext test_context;
-  Context ctx;
-  ctx.orig_args = Args::from_string("cc -c -MD foo.c -o foo.o");
-  util::write_file("foo.c", "");
-  ctx.config.set_run_second_cpp(false);
-
-  const auto result = process_args(ctx);
-
-  CHECK(result);
-  CHECK(result->preprocessor_args.to_string() == "cc -MD -MF foo.d -MQ foo.o");
-  CHECK(result->extra_args_to_hash.to_string() == "");
-  CHECK(result->compiler_args.to_string() == "cc -c");
-}
-
-TEST_CASE("MF_should_not_be_added_if_run_second_cpp_is_true")
-{
-  TestContext test_context;
-  Context ctx;
-  ctx.orig_args = Args::from_string("cc -c -MD foo.c -o foo.o");
-  util::write_file("foo.c", "");
-
-  const auto result = process_args(ctx);
-
-  CHECK(result);
-  CHECK(result->preprocessor_args.to_string() == "cc");
-  CHECK(result->extra_args_to_hash.to_string() == "-MD");
-  CHECK(result->compiler_args.to_string() == "cc -c -MD");
-}
-
 TEST_CASE("equal_sign_after_MF_should_be_removed")
 {
   TestContext test_context;
index 0ca6d068e99b1405503a6b44f1d87941864d27b2..c8fb8cde5641723f3d6d8abf1194c80f0e726853 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2011-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -79,7 +79,6 @@ TEST_CASE("Config: default values")
   CHECK_FALSE(config.remote_only());
   CHECK(config.remote_storage().empty());
   CHECK_FALSE(config.reshare());
-  CHECK(config.run_second_cpp());
   CHECK(config.sloppiness().to_bitmask() == 0);
   CHECK(config.stats());
   CHECK(config.temporary_dir().empty()); // Set later
@@ -138,7 +137,6 @@ TEST_CASE("Config::update_from_file")
     "read_only_direct = true\n"
     "recache = true\n"
     "reshare = true\n"
-    "run_second_cpp = false\n"
     "sloppiness =     time_macros   ,include_file_mtime"
     "  include_file_ctime,file_stat_matches,file_stat_matches_ctime,pch_defines"
     " ,  no_system_headers,system_headers,clang_index_store,ivfsoverlay,"
@@ -182,7 +180,6 @@ TEST_CASE("Config::update_from_file")
   CHECK(config.read_only_direct());
   CHECK(config.recache());
   CHECK(config.reshare());
-  CHECK_FALSE(config.run_second_cpp());
   CHECK(config.sloppiness().to_bitmask()
         == (static_cast<uint32_t>(core::Sloppy::clang_index_store)
             | static_cast<uint32_t>(core::Sloppy::file_stat_matches)
@@ -479,7 +476,6 @@ TEST_CASE("Config::visit_items")
     "remote_storage = rs\n"
     "reshare = true\n"
     "response_file_format = posix\n"
-    "run_second_cpp = false\n"
     "sloppiness = include_file_mtime, include_file_ctime, time_macros,"
     " file_stat_matches, file_stat_matches_ctime, pch_defines, system_headers,"
     " clang_index_store, ivfsoverlay, gcno_cwd \n"
@@ -542,7 +538,6 @@ TEST_CASE("Config::visit_items")
     "(test.conf) remote_storage = rs",
     "(test.conf) reshare = true",
     "(test.conf) response_file_format = posix",
-    "(test.conf) run_second_cpp = false",
     "(test.conf) sloppiness = clang_index_store, file_stat_matches,"
     " file_stat_matches_ctime, gcno_cwd, include_file_ctime,"
     " include_file_mtime, ivfsoverlay, pch_defines, system_headers,"