]> 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:00:56 +0000 (20:00 +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.

src/ccache.c
unittest/test_argument_processing.c

index 03aa97a96cd4834c1cca9d66226548826105cd00..9978d3874ed3cd42649bd9b851c2bc42d2c7ce31 100644 (file)
@@ -1,7 +1,7 @@
 // ccache -- a fast C/C++ compiler cache
 //
 // Copyright (C) 2002-2007 Andrew Tridgell
-// Copyright (C) 2009-2019 Joel Rosdahl
+// Copyright (C) 2009-2020 Joel Rosdahl
 //
 // This program is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by the Free
@@ -3548,8 +3548,7 @@ cc_process_args(struct args *args,
                }
 
                if (!dependency_target_specified
-                   && !dependency_implicit_target_specified
-                   && !str_eq(get_extension(output_obj), ".o")) {
+                   && !dependency_implicit_target_specified) {
                        args_add(dep_args, "-MQ");
                        args_add(dep_args, output_obj);
                }
index 3a2d0ed37adbca5ae66cbe8984b9bb90689e5acf..c0504bee1d8949c8b1f246570af00bc62d040aec 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2019 Joel Rosdahl
+// Copyright (C) 2010-2020 Joel Rosdahl
 //
 // This program is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by the Free
@@ -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");