With the depend mode enabled, ccache executes the original command line
verbatim, potentially with the addition of a few extra options. However,
for clang or clang-cl it is not possible to simply append the additional
options to the end of the original command line since there may be a
"--" option to indicate the end of options.
Fix this by inserting the additional options directly after the compiler
instead of at the end.
Fixes #1273.
// mode.
Args depend_mode_args = ctx.orig_args;
depend_mode_args.erase_with_prefix("--ccache-");
- depend_mode_args.push_back(depend_extra_args);
+ // Add depend_mode_args directly after the compiler. We can't add them last
+ // since options then may be placed after a "--" option.
+ depend_mode_args.insert(1, depend_extra_args);
add_prefix(ctx, depend_mode_args, ctx.config.prefix_command());
ctx.time_of_compilation = util::TimePoint::now();
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_equal_content 'file with$special#characters.d' reference.d
+
+ # -------------------------------------------------------------------------
+ if touch empty.c && $COMPILER -c -- empty.c 2>/dev/null; then
+ TEST "--"
+
+ $CCACHE_COMPILE -c -- test.c
+ expect_stat direct_cache_hit 0
+ expect_stat cache_miss 1
+
+ $CCACHE_COMPILE -c -- test.c
+ expect_stat direct_cache_hit 1
+ expect_stat cache_miss 1
+ fi
}