diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2019-10-03 20:21:54 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2019-10-03 20:21:54 +0200 |
commit | 19c3729d30640fc2c78242cb46136e619fdbd802 (patch) | |
tree | c517065eebd2a6634be5292d9f6a72c92b37ed2d | |
parent | 3c0e894c58b887bc40e2be99e722bd9b68df8689 (diff) | |
download | ccache-19c3729d30640fc2c78242cb46136e619fdbd802.tar.gz |
Only pass implicit -MQ to preprocessor if needed
This is a bug fix of 76a9959f3d3e.
-rw-r--r-- | doc/NEWS.adoc | 5 | ||||
-rw-r--r-- | src/ccache.c | 2 | ||||
-rw-r--r-- | unittest/test_argument_processing.c | 30 |
3 files changed, 36 insertions, 1 deletions
diff --git a/doc/NEWS.adoc b/doc/NEWS.adoc index 10a827b4..ae195180 100644 --- a/doc/NEWS.adoc +++ b/doc/NEWS.adoc @@ -11,6 +11,11 @@ Bug fixes - Fixed a regression in 3.7.2 that could result in a warning message instead of an error in an edge case related to usage of “-Werror”. +- 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`. (This is a bug fix of the + corresponding improvement implemented in ccache 3.4.) + ccache 3.7.4 ------------ diff --git a/src/ccache.c b/src/ccache.c index 9c605934..b9f1e479 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -3522,7 +3522,7 @@ cc_process_args(struct args *args, if (!dependency_target_specified && !dependency_implicit_target_specified - && !str_eq(get_extension(output_dep), ".o")) { + && !str_eq(get_extension(output_obj), ".o")) { args_add(dep_args, "-MQ"); args_add(dep_args, output_obj); } diff --git a/unittest/test_argument_processing.c b/unittest/test_argument_processing.c index ca48c2a5..b6c7476a 100644 --- a/unittest/test_argument_processing.c +++ b/unittest/test_argument_processing.c @@ -173,6 +173,36 @@ 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(sysroot_should_be_rewritten_if_basedir_is_used) { extern char *current_working_dir; |