]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Add support for Clang "--" option
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 28 Aug 2022 10:31:41 +0000 (12:31 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 28 Aug 2022 11:30:07 +0000 (13:30 +0200)
Closes #1149.

src/ArgsInfo.hpp
src/argprocessing.cpp
src/ccache.cpp
test/suites/base.bash

index 793eb3dc00240f3a829bf8c45370f878fdf24807..92d089b52d0ef9b331c21331945bc03953a6643a 100644 (file)
@@ -92,6 +92,9 @@ struct ArgsInfo
   // Whether to strip color codes from diagnostic messages on output.
   bool strip_diagnostics_colors = false;
 
+  // Have we seen --?
+  bool seen_double_dash = false;
+
   // Have we seen -gsplit-dwarf?
   bool seen_split_dwarf = false;
 
index f1aab538891af02d0fedd8a15075395edf39a600..404623585fecb3320ed16d40882597b6a4983626 100644 (file)
@@ -1027,6 +1027,11 @@ process_option_arg(const Context& ctx,
     return Statistic::none;
   }
 
+  if (args[i] == "--") {
+    args_info.seen_double_dash = true;
+    return Statistic::none;
+  }
+
   // Other options.
   if (args[i][0] == '-') {
     if (compopt_affects_cpp_output(args[i])
index cef6ffab705ef908c97db89f905df3ce883a1613..5b58f5e6beb8d067f1e444bee9602bca7b7b8f3a 100644 (file)
@@ -1007,6 +1007,10 @@ to_cache(Context& ctx,
     args.push_back(ctx.args_info.output_dia);
   }
 
+  if (ctx.args_info.seen_double_dash) {
+    args.push_back("--");
+  }
+
   if (ctx.config.run_second_cpp()) {
     args.push_back(ctx.args_info.input_file);
   } else {
index 0314ee48906166b92e9aa4ea88fbe9e8c0f92a87..c7272363acfa40d6206791bd0a71b4b7dbfabb88 100644 (file)
@@ -1472,6 +1472,19 @@ EOF
     expect_stat preprocessed_cache_hit 1
     expect_stat cache_miss 1
 
+    # -------------------------------------------------------------------------
+    if touch empty.c && $COMPILER -c -- empty.c 2>/dev/null; then
+        TEST "--"
+
+        $CCACHE_COMPILE -c -- test1.c
+        expect_stat preprocessed_cache_hit 0
+        expect_stat cache_miss 1
+
+        $CCACHE_COMPILE -c -- test1.c
+        expect_stat preprocessed_cache_hit 1
+        expect_stat cache_miss 1
+    fi
+
     # -------------------------------------------------------------------------
     TEST "Handling of compiler-only arguments"