// the compiler, not the preprocessor, and that also should not be part of the
// hash identifying the result.
Args compiler_only_args_no_hash;
+
+ // Whether to include the full command line in the hash.
+ bool hash_full_command_line = false;
};
bool
return nullopt;
}
+ if (args[i] == "-frecord-gcc-switches") {
+ state.hash_full_command_line = true;
+ }
+
// Options taking an argument that we may want to rewrite to relative paths to
// get better hit rate. A secondary effect is that paths in the standard error
// output produced by the compiler will be normalized.
if (config.run_second_cpp()) {
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);
-// Copyright (C) 2010-2020 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
expect_stat 'cache hit (preprocessed)' 2
expect_stat 'cache miss' 2
+ # -------------------------------------------------------------------------
+ TEST "-frecord-gcc-switches"
+
+ if $REAL_COMPILER -frecord-gcc-switches -c test1.c >&/dev/null; then
+ $CCACHE_COMPILE -frecord-gcc-switches -c test1.c
+ expect_stat 'cache hit (preprocessed)' 0
+ expect_stat 'cache miss' 1
+
+ $CCACHE_COMPILE -frecord-gcc-switches -c test1.c
+ expect_stat 'cache hit (preprocessed)' 1
+ expect_stat 'cache miss' 1
+
+ $CCACHE_COMPILE -frecord-gcc-switches -Wall -c test1.c
+ expect_stat 'cache hit (preprocessed)' 1
+ expect_stat 'cache miss' 2
+
+ $CCACHE_COMPILE -frecord-gcc-switches -Wall -c test1.c
+ expect_stat 'cache hit (preprocessed)' 2
+ expect_stat 'cache miss' 2
+ fi
+
# -------------------------------------------------------------------------
TEST "CCACHE_COMPILER"