From dfc7a90173b25fb4d7cf7e440b34e99bf3b2a1cb Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sun, 28 Aug 2022 12:31:41 +0200 Subject: [PATCH] feat: Add support for Clang "--" option Closes #1149. --- src/ArgsInfo.hpp | 3 +++ src/argprocessing.cpp | 5 +++++ src/ccache.cpp | 4 ++++ test/suites/base.bash | 13 +++++++++++++ 4 files changed, 25 insertions(+) diff --git a/src/ArgsInfo.hpp b/src/ArgsInfo.hpp index 793eb3dc0..92d089b52 100644 --- a/src/ArgsInfo.hpp +++ b/src/ArgsInfo.hpp @@ -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; diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index f1aab5388..404623585 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -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]) diff --git a/src/ccache.cpp b/src/ccache.cpp index cef6ffab7..5b58f5e6b 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -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 { diff --git a/test/suites/base.bash b/test/suites/base.bash index 0314ee489..c7272363a 100644 --- a/test/suites/base.bash +++ b/test/suites/base.bash @@ -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" -- 2.47.2