diff --git a/ccache.c b/ccache.c index 36129c438f..33a6192a7e 100644 --- a/ccache.c +++ b/ccache.c @@ -1166,8 +1166,14 @@ to_cache(struct args *args) free(base_name); } + if (compiler_is_msvc(args)) { + char *fo = format("-Fo%s", output_obj); + args_add(args, fo); + free(fo); + } else { args_add(args, "-o"); args_add(args, output_obj); + } if (output_dia) { args_add(args, "--serialize-diagnostics"); @@ -2394,11 +2400,18 @@ cc_process_args(struct args *args, struct args **preprocessor_args, continue; } - // Alternate form of -o with no space. + // Alternate form of -o/-Fo with no space. + if (compiler_is_msvc(args)) { + if (str_startswith(argv[i], "-Fo")) { + output_obj = make_relative_path(x_strdup(&argv[i][3])); + continue; + } + } else { if (str_startswith(argv[i], "-o")) { output_obj = make_relative_path(x_strdup(&argv[i][2])); continue; } + } if (str_eq(argv[i], "-gsplit-dwarf")) { cc_log("Enabling caching of dwarf files since -gsplit-dwarf is used");