Duplicated -arch option results in "unsupported compiler option"

Gautier Pelloux-Prayer <[email protected]> Tue, 20 Oct 2015 14:43:40 +0200
Newsgroups gmane.comp.compilers.ccache
Message-ID <[email protected]>
Hi,

When invoking ccache with twice -arch option, it fails to use its cache and "unsupported compiler option" counter increment.

Basically doing:

ccache clang test.c -arch i386 # cache miss: 1 - OK
ccache clang test.c -arch i386 # cache hit (direct): 1 - OK
ccache clang test.c -arch i386 -arch i386 # unsupported compiler option: 1 - NOK actually expected cache hit (direct): 2

Similarly, invoking it twice with -Wall option results in cache not being used:

ccache clang test.c -Wall # cache miss: 1 - OK
ccache clang test.c -Wall # cache hit (direct): 1 - OK
ccache clang test.c -Wall -Wall # cache miss: 2 - NOK actually expected cache hit (direct): 2

I know that passing multiple times same options is invalid, but when build process is complex it's quite hard not to have some of them...

Cheers,

Gautier PP.

_______________________________________________
ccache mailing list
[email protected]
https://lists.samba.org/mailman/listinfo/ccache
0001-test.sh-add-test-where-arch-is-duplicated-resulting-.patch (application/octet-stream, 1.7 KB)
From 84bd98ffc70c9d73b0b87b11c1a6f06aea1aa6b1 Mon Sep 17 00:00:00 2001
From: Gautier Pelloux-Prayer
 <[email protected]>
Date: Tue, 20 Oct 2015 14:30:54 +0200
Subject: [PATCH] test.sh: add test where arch is duplicated, resulting in
 "unsupported compiler option"

---
 test.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/test.sh b/test.sh
index 1090649..ec37907 100755
--- a/test.sh
+++ b/test.sh
@@ -367,6 +367,28 @@ base_tests() {
     checkstat 'cache hit (preprocessed)' 14
     checkstat 'cache miss' 39
 
+    testname="duplication-option"
+    $CCACHE_COMPILE -Wall -c test1.c
+    checkstat 'unsupported compiler option' 1
+    checkstat 'cache hit (preprocessed)' 14
+    checkstat 'cache miss' 40
+    $CCACHE_COMPILE -Wall -Wall -c test1.c
+    checkstat 'cache hit (preprocessed)' 15
+    checkstat 'cache miss' 40
+
+    testname="custom-arch"
+    $CCACHE_COMPILE -arch i386 -c test1.c
+    checkstat 'unsupported compiler option' 1
+    checkstat 'cache hit (preprocessed)' 15
+    checkstat 'cache miss' 41
+
+    testname="custom-arch-duplicate"
+    $CCACHE_COMPILE -arch i386 -arch i386 -c test1.c
+    checkstat 'unsupported compiler option' 1
+    checkstat 'cache hit (preprocessed)' 16
+    checkstat 'cache miss' 41
+
+
     if [ -x /usr/bin/printf ]; then
         /usr/bin/printf '#include <wchar.h>\nwchar_t foo[] = L"\xbf";\n' >latin1.c
         if CCACHE_DISABLE=1 $COMPILER -c -finput-charset=latin1 latin1.c >/dev/null 2>&1; then
@@ -2440,6 +2462,7 @@ COMPILER_USES_LLVM=0
 HOST_OS_APPLE=0
 
 compiler_version="`$COMPILER --version 2>&1 | head -1`"
+
 case $compiler_version in
     *gcc*|*g++*|2.95*)
         COMPILER_TYPE_GCC=1
-- 
2.3.2 (Apple Git-55)