From: Joel Rosdahl Date: Tue, 30 Jan 2018 21:38:29 +0000 (+0100) Subject: Only pass implicit -MQ to preprocessor if needed X-Git-Tag: v3.4~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=76a9959f3d3e;p=thirdparty%2Fccache.git Only pass implicit -MQ to preprocessor if needed Fixes #209. --- diff --git a/NEWS.txt b/NEWS.txt index 16d7790e0..7383b6608 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -31,6 +31,10 @@ New features and improvements `-fdirectives-only` (GCC) or `frewrite-includes` (Clang) to the compiler, diagnostics warnings and similar will be correct. +- An implicit `-MQ` is now passed to the preprocessor only if the object file + extension is non-standard. This should make it easier to use EDG-based + compilers (e.g. GHS) which don't understand `-MQ`. + Bug fixes ~~~~~~~~~ diff --git a/ccache.c b/ccache.c index 5ed903186..22a76cf39 100644 --- a/ccache.c +++ b/ccache.c @@ -2933,7 +2933,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args, output_dep = make_relative_path(x_strdup(default_depfile_name)); } - if (!dependency_target_specified) { + if (!dependency_target_specified + && !str_eq(get_extension(output_dep), ".o")) { args_add(dep_args, "-MQ"); args_add(dep_args, output_obj); } diff --git a/test/suites/direct.bash b/test/suites/direct.bash index 13d5d66dc..0b2b3c8a5 100644 --- a/test/suites/direct.bash +++ b/test/suites/direct.bash @@ -127,8 +127,9 @@ EOF TEST "Calculation of dependency file names" mkdir test.dir - for ext in .obj "" . .foo.bar; do + for ext in .o .obj "" . .foo.bar; do dep_file=test.dir/`echo test$ext | sed 's/\.[^.]*\$//'`.d + $CCACHE_COMPILE -MD -c test.c -o test.dir/test$ext rm -f $dep_file $CCACHE_COMPILE -MD -c test.c -o test.dir/test$ext @@ -138,8 +139,19 @@ EOF if ! grep "test$ext:" $dep_file >/dev/null 2>&1; then test_failed "$dep_file does not contain test$ext" fi + + dep_target=foo.bar + $CCACHE_COMPILE -MD -MQ $dep_target -c test.c -o test.dir/test$ext + rm -f $dep_target + $CCACHE_COMPILE -MD -MQ $dep_target -c test.c -o test.dir/test$ext + if [ ! -f $dep_file ]; then + test_failed "$dep_file missing" + fi + if ! grep $dep_target $dep_file >/dev/null 2>&1; then + test_failed "$dep_file does not contain $dep_target" + fi done - expect_stat 'files in cache' 12 + expect_stat 'files in cache' 18 # ------------------------------------------------------------------------- TEST "-MMD for different source files"