]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Improve docs and clean up
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 30 Jan 2018 20:51:17 +0000 (21:51 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 30 Jan 2018 20:51:17 +0000 (21:51 +0100)
MANUAL.txt
ccache.c
test/suites/cpp1.bash

index 8bcc9a0377da8e1ae9d0518a54e94271686383f8..0d37a42e26de3c978d0e4f39bc507446bb504e3a 100644 (file)
@@ -486,11 +486,12 @@ source code only has to be preprocessed once. The downside is that some
 compilers won't produce the same result (for instance diagnostics warnings)
 when compiling preprocessed source code.
 +
-An alternative to *run_second_cpp* is to use *-fdirectives-only* (for GCC) or
-*-frewrite-includes* (for Clang). This will cause the compiler to leave the
-macros and other preprocessor information, and only process the *#include*
-directives. When run in this way, the preprocessor arguments will be passed
-to the compiler since it still has to do _some_ preprocessing (like macros).
+A solution to the above mentioned downside is to set *run_second_cpp* to false
+and pass *-fdirectives-only* (for GCC) or *-frewrite-includes* (for Clang) to
+the compiler. This will cause the compiler to leave the macros and other
+preprocessor information, and only process the *#include* directives. When run
+in this way, the preprocessor arguments will be passed to the compiler since it
+still has to do _some_ preprocessing (like macros).
 
 *sloppiness* (*CCACHE_SLOPPINESS*)::
 
index 8b8746cac95d6aaa77e1a68260def4aeceabefc6..5ed9031863a0836ae67c924a82bc4a2ba62668eb 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -2955,17 +2955,17 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
        if (conf->run_second_cpp) {
                args_extend(*compiler_args, cpp_args);
        } else if (found_directives_only || found_rewrite_includes) {
-               // Need to pass the macros and any other preprocessor directives again
+               // Need to pass the macros and any other preprocessor directives again.
                args_extend(*compiler_args, cpp_args);
                if (found_directives_only) {
                        args_add(cpp_args, "-fdirectives-only");
-                       // The preprocessed source code still needs some more preprocessing
+                       // The preprocessed source code still needs some more preprocessing.
                        args_add(*compiler_args, "-fpreprocessed");
                        args_add(*compiler_args, "-fdirectives-only");
                }
                if (found_rewrite_includes) {
                        args_add(cpp_args, "-frewrite-includes");
-                       // The preprocessed source code still needs some more preprocessing
+                       // The preprocessed source code still needs some more preprocessing.
                        args_add(*compiler_args, "-x");
                        args_add(*compiler_args, actual_language);
                }
index eefa1f41d5db226f54c84dc44e97daf795410092..6d07dcb02ec022da10368cf69a5c4d4a9e676836 100644 (file)
@@ -1,12 +1,12 @@
 SUITE_cpp1_PROBE() {
     touch test.c
     if $COMPILER_TYPE_GCC; then
-        if ! $UNCACHED_COMPILE -E -fdirectives-only test.c >/dev/null 2>&1; then
+        if ! $UNCACHED_COMPILE -E -fdirectives-only test.c >&/dev/null; then
             echo "-fdirectives-only not supported by compiler"
             return
         fi
     elif $COMPILER_TYPE_CLANG; then
-        if ! $UNCACHED_COMPILE -E -frewrite-includes test.c >/dev/null 2>&1; then
+        if ! $UNCACHED_COMPILE -E -frewrite-includes test.c >&/dev/null; then
             echo "-frewrite-includes not supported by compiler"
             return
         fi
@@ -20,11 +20,11 @@ SUITE_cpp1_SETUP() {
     export CCACHE_NOCPP2=1
     echo "#define FOO 1" >test1.h
     backdate test1.h
-    echo "#include \"test1.h\"" >test1.c
-    echo "#define BAR 2" >>test1.c
-    echo "int foo(int x) { return FOO; }" >>test1.c
-    echo "int bar(int x) { return BAR; }" >>test1.c
-    echo "int baz(int x) { return BAZ; }" >>test1.c
+    echo '#include "test1.h"' >test1.c
+    echo '#define BAR 2' >>test1.c
+    echo 'int foo(int x) { return FOO; }' >>test1.c
+    echo 'int bar(int x) { return BAR; }' >>test1.c
+    echo 'int baz(int x) { return BAZ; }' >>test1.c
 }
 
 SUITE_cpp1() {
@@ -33,7 +33,7 @@ SUITE_cpp1() {
     elif $COMPILER_TYPE_CLANG; then
         cpp_flag="-frewrite-includes"
     fi
-    cpp_flag="$cpp_flag -DBAZ=3"
+    cpp_flag+=" -DBAZ=3"
 
     # -------------------------------------------------------------------------
     TEST "Base case"