]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Clang emits warnings for unused linker arguments, respect that!
authorEdward Z. Yang <ezyang@fb.com>
Fri, 30 Jun 2017 14:35:29 +0000 (07:35 -0700)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 11 Jan 2018 20:02:33 +0000 (21:02 +0100)
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 <ezyang@fb.com>
ccache.c

index 099380b65415166fbf912ebeda67512391c988b8..19df19502dd59ac2d38ac986d4edfd134ee89d87 100644 (file)
--- 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;
                }