From da4fa01e97938fd969fbe0cf616fdaeccd87d6f3 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Fri, 30 Jun 2017 07:35:29 -0700 Subject: Clang emits warnings for unused linker arguments, respect that! If ccache concludes the invocation with/without linker arguments is the same as before, then it may show/fail to show a warning when it should. I know we're not supposed to rely on the is clang check, but this solves it in normal cases. Fixes #189. Signed-off-by: Edward Z. Yang --- ccache.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ccache.c b/ccache.c index 099380b6..19df1950 100644 --- a/ccache.c +++ b/ccache.c @@ -1639,19 +1639,24 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode) hash_int(hash, MANIFEST_VERSION); } + // clang will emit warnings for unused linker flags, so we shouldn't + // skip those arguments + int is_clang = compiler_is_clang(args); + // First the arguments. for (int i = 1; i < args->argc; i++) { // -L doesn't affect compilation. - if (i < args->argc-1 && str_eq(args->argv[i], "-L")) { + if (i < args->argc-1 && str_eq(args->argv[i], "-L") && !is_clang) { i++; continue; } - if (str_startswith(args->argv[i], "-L")) { + if (str_startswith(args->argv[i], "-L") && !is_clang) { continue; } // -Wl,... doesn't affect compilation. - if (str_startswith(args->argv[i], "-Wl,")) { + if (str_startswith(args->argv[i], "-Wl,") && !is_clang) { + // ...but it affects warnings with clang continue; } -- cgit v1.2.1