From: Edward Z. Yang Date: Fri, 30 Jun 2017 14:35:29 +0000 (-0700) Subject: Clang emits warnings for unused linker arguments, respect that! X-Git-Tag: v3.3.5~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da4fa01e97938fd969fbe0cf616fdaeccd87d6f3;p=thirdparty%2Fccache.git 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 --- diff --git a/ccache.c b/ccache.c index 099380b65..19df19502 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; }