]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Revert "Only pass implicit -MQ to preprocessor if needed"
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 1 Jan 2020 20:59:29 +0000 (21:59 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 5 Jan 2020 19:19:55 +0000 (20:19 +0100)
This reverts commit 19c3729d30640fc2c78242cb46136e619fdbd802 and also
removes the incorrect and superfluous condition that the fix fixes.

The reason for reverting is that the change introduced a nasty bug: the
dependency file will get an incorrect object file location if 1) build
directory != source directory and 2) -MF is not specified explictly by
the user.

Details: The dependency file is created by the preprocessor pass which
does not have access to the final output file name, so the preprocessor
uses the default object location derived from the source file location
instead.

Note that this partly reverts a compatibility improvement for EDG-based
compilers (see issue #460).

It should be possible to pass the dependency arguments to the compiler
instead of the preprocessor to make -MD/-MMD without -MQ work, but
that’s too risky to be done as a bug fix.

Fixes #499.

(cherry picked from commit 6d4537695f8753556362c6c5521360ca9b596ab2)

src/ccache.cpp
unittest/test_argument_processing.cpp

index 036bc6b2be327fce321e9c9e0069ba1860aa2bf7..ca63c0efb7980517dae9f7d69dcbcc370c748d3e 100644 (file)
@@ -3421,8 +3421,7 @@ cc_process_args(struct args* args,
       output_dep = make_relative_path(x_strdup(default_depfile_name.c_str()));
     }
 
-    if (!dependency_target_specified && !dependency_implicit_target_specified
-        && !str_eq(get_extension(output_obj), ".o")) {
+    if (!dependency_target_specified && !dependency_implicit_target_specified) {
       args_add(dep_args, "-MQ");
       args_add(dep_args, output_obj);
     }
index 24f4cb2193c3abfb7dbe660e470614486d02f5b9..59d5ec4ad8068a0df9bc8a5436cdaccf866b931b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2019 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2020 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -173,36 +173,6 @@ TEST(dependency_flags_that_take_an_argument_should_not_require_space_delimiter)
   args_free(orig);
 }
 
-TEST(MQ_flag_should_not_be_added_for_standard_obj_extension)
-{
-  struct args* orig = args_init_from_string("cc -c -MD foo.c -o foo.o");
-  struct args* exp_cpp = args_init_from_string("cc -MD -MF foo.d");
-  struct args* exp_cc = args_init_from_string("cc -c");
-  struct args *act_cpp = NULL, *act_cc = NULL;
-  create_file("foo.c", "");
-
-  CHECK(cc_process_args(orig, &act_cpp, NULL, &act_cc));
-  CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
-  CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
-
-  args_free(orig);
-}
-
-TEST(MQ_flag_should_be_added_for_non_standard_obj_extension)
-{
-  struct args* orig = args_init_from_string("cc -c -MD foo.c -o foo.obj");
-  struct args* exp_cpp = args_init_from_string("cc -MD -MF foo.d -MQ foo.obj");
-  struct args* exp_cc = args_init_from_string("cc -c");
-  struct args *act_cpp = NULL, *act_cc = NULL;
-  create_file("foo.c", "");
-
-  CHECK(cc_process_args(orig, &act_cpp, NULL, &act_cc));
-  CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
-  CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
-
-  args_free(orig);
-}
-
 TEST(equal_sign_after_MF_should_be_removed)
 {
   struct args* orig = args_init_from_string("cc -c -MF=path foo.c -o foo.o");