]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add -arch options to hash
authorIvan Vaigult <i.vaigult@gmail.com>
Thu, 1 Sep 2016 01:27:27 +0000 (01:27 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 7 Sep 2016 19:11:05 +0000 (21:11 +0200)
Update tests.

Fixes #127 "ccache no longer supports building of single -archs".

ccache.c
test.sh

index 00e68369299609f95eb786e8868f3d997fc824df..e60620493c90b1e87424796d8dde47c6b6cdd5da 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1740,6 +1740,12 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                free(gcda_name);
        }
 
+       // Adding -arch to hash since cpp output is affected
+       for(size_t i = 0; i < arch_args_size; ++i) {
+               hash_delimiter(hash, "-arch");
+               hash_string(hash, arch_args[i]);
+       }
+
        struct file_hash *object_hash = NULL;
        if (direct_mode) {
                // Hash environment variables that affect the preprocessor output.
diff --git a/test.sh b/test.sh
index 2362b96df5d6395ec37f4327a045c5637bbb7d90..fe39a8220d3bd1065b90030943b429dddc8f3da7 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1119,19 +1119,62 @@ SUITE_multi_arch_PROBE() {
     fi
 }
 
+SUITE_multi_arch_SETUP() {
+    generate_code 1 test1.c
+    unset CCACHE_NODIRECT
+}
+
 SUITE_multi_arch() {
-    # -------------------------------------------------------------------------
+# -------------------------------------------------------------------------
     TEST "cache hit"
 
-    generate_code 1 test1.c
+    # Different arches shouldn't affect each other
+    $CCACHE_COMPILE -arch i386 -c test1.c
+    expect_stat 'cache hit (direct)' 0
+    expect_stat 'cache miss' 1
+    
+    $CCACHE_COMPILE -arch x86_64 -c test1.c
+    expect_stat 'cache hit (direct)' 0
+    expect_stat 'cache miss' 2
+    
+    $CCACHE_COMPILE -arch i386 -c test1.c
+    expect_stat 'cache hit (direct)' 1
+    expect_stat 'cache miss' 2
 
+    # Multiple arches should be cached too
+    $CCACHE_COMPILE -arch i386 -arch x86_64 -c test1.c
+    expect_stat 'cache hit (direct)' 1
+    expect_stat 'cache miss' 3
+    
     $CCACHE_COMPILE -arch i386 -arch x86_64 -c test1.c
+    expect_stat 'cache hit (direct)' 2
+    expect_stat 'cache miss' 3
+
+    #The same for preprocessor mode
+    clear_cache
+    export CCACHE_NODIRECT=1
+    
+    $CCACHE_COMPILE -arch i386 -c test1.c
     expect_stat 'cache hit (preprocessed)' 0
     expect_stat 'cache miss' 1
+    
+    $CCACHE_COMPILE -arch x86_64 -c test1.c
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 2
+    
+    $CCACHE_COMPILE -arch i386 -c test1.c
+    expect_stat 'cache hit (preprocessed)' 1
+    expect_stat 'cache miss' 2
 
+    # Multiple arches should be cached too
     $CCACHE_COMPILE -arch i386 -arch x86_64 -c test1.c
     expect_stat 'cache hit (preprocessed)' 1
-    expect_stat 'cache miss' 1
+    expect_stat 'cache miss' 3
+    
+    $CCACHE_COMPILE -arch i386 -arch x86_64 -c test1.c
+    expect_stat 'cache hit (preprocessed)' 2
+    expect_stat 'cache miss' 3
+
 }
 
 # =============================================================================
@@ -2402,7 +2445,7 @@ SUITE_readonly() {
         test_failed "Read-only mode + direct mode stored files in the cache"
     fi
 }
-
 # =============================================================================
 
 SUITE_readonly_direct_SETUP() {