]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Avoid creating ccache directory when CCACHE_DISABLE is set
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 30 Aug 2013 20:29:28 +0000 (22:29 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 30 Aug 2013 20:29:28 +0000 (22:29 +0200)
ccache.c
test.sh

index b20c087bcdd19d07eb586bdcc910fdb73af36add..7cd32a162b63785fea2e3fb3b50e96d9f2d75b20 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1964,7 +1964,7 @@ setup_uncached_err(void)
 
 /* the main ccache driver function */
 static void
-ccache(int argc, char *argv[])
+ccache(char *argv[])
 {
        bool put_object_in_manifest = false;
        struct file_hash *object_hash;
@@ -1980,14 +1980,8 @@ ccache(int argc, char *argv[])
        /* Arguments to send to the real compiler. */
        struct args *compiler_args;
 
-       find_compiler(argc, argv);
        setup_uncached_err();
 
-       if (getenv("CCACHE_DISABLE")) {
-               cc_log("ccache is disabled");
-               failed();
-       }
-
        if (!getenv("CCACHE_READONLY")) {
                if (create_cachedirtag(cache_dir) != 0) {
                        cc_log("failed to create %s/CACHEDIR.TAG (%s)\n",
@@ -2286,6 +2280,14 @@ ccache_main(int argc, char *argv[])
        }
        free(program_name);
 
+       /* find_compiler sets up orig_args, needed by failed(), so do it early. */
+       find_compiler(argc, argv);
+
+       if (getenv("CCACHE_DISABLE")) {
+               cc_log("ccache is disabled");
+               failed();
+       }
+
        check_cache_dir();
 
        temp_dir = getenv("CCACHE_TEMPDIR");
@@ -2317,6 +2319,6 @@ ccache_main(int argc, char *argv[])
                exit(1);
        }
 
-       ccache(argc, argv);
+       ccache(argv);
        return 1;
 }
diff --git a/test.sh b/test.sh
index 71912ce335ae0ff123ba19b3b2728195227bad0d..d74e520c622898e49f2c2ccf95c3e609ba233b53 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -216,7 +216,12 @@ base_tests() {
     checkstat 'no input file' 1
 
     testname="CCACHE_DISABLE"
+    mv $CCACHE_DIR $CCACHE_DIR.saved
     CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null
+    if [ -d $CCACHE_DIR ]; then
+        test_failed "$CCACHE_DIR created dispite CCACHE_DISABLE being set"
+    fi
+    mv $CCACHE_DIR.saved $CCACHE_DIR
     checkstat 'cache hit (preprocessed)' 3
     $CCACHE_COMPILE -c test1.c
     checkstat 'cache hit (preprocessed)' 4