From: Orion Poplawski Date: Tue, 14 Jun 2016 16:50:25 +0000 (-0600) Subject: Add support for -Wp,-D in direct mode X-Git-Tag: v3.3~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a8b98b4462c613442a5debf6c6f6b38365a149a;p=thirdparty%2Fccache.git Add support for -Wp,-D in direct mode --- diff --git a/MANUAL.txt b/MANUAL.txt index 6d5d8fb5a..0d9b7a397 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -621,8 +621,8 @@ The direct mode will be disabled if any of the following holds: race condition) * the unifier is enabled (the configuration setting *unify* is true) * a compiler option not supported by the direct mode is used: -** a *-Wp,_X_* compiler option other than *-Wp,-MD,_path_* and - *-Wp,-MMD,_path_* +** a *-Wp,_X_* compiler option other than *-Wp,-MD,_path_*, + *-Wp,-MMD,_path_* and *-Wp,-D_define_* ** *-Xpreprocessor* * the string ``\_\_TIME__'' is present in the source code @@ -829,8 +829,8 @@ problems and what may be done to increase the hit rate: ** Compiler arguments that are hashed in the direct mode but not in the preprocessor mode have changed (*-I*, *-include*, *-D*, etc) and they didn't affect the preprocessor output. -** The compiler option *-Xpreprocessor* or *-Wp,_X_* (except *-Wp,-MD,_path_* - and *Wp,-MMD,_path_*) is used. +** The compiler option *-Xpreprocessor* or *-Wp,_X_* (except *-Wp,-MD,_path_*, + *-Wp,-MMD,_path_*, and *-Wp,-D_define_*) is used. ** This was the first compilation with a new value of the base directory setting. ** A modification time of one of the include files is too new (created the same diff --git a/NEWS.txt b/NEWS.txt index 2aac6ae37..189bb2c84 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -43,6 +43,8 @@ New features and improvements - Improved parsing of `-g*` options. +- Made ccache understand `-Wp,-D*` options. + Bug fixes ~~~~~~~~~ diff --git a/ccache.c b/ccache.c index 500dc0beb..34f8352de 100644 --- a/ccache.c +++ b/ccache.c @@ -2480,6 +2480,11 @@ cc_process_args(struct args *args, struct args **preprocessor_args, output_dep = make_relative_path(x_strdup(argv[i] + 9)); args_add(dep_args, argv[i]); continue; + } else if (str_startswith(argv[i], "-Wp,-D") + && !strchr(argv[i] + 6, ',')) { + /* Treat it like -D */ + args_add(dep_args, argv[i] + 4); + continue; } else if (conf->direct_mode) { /* * -Wp, can be used to pass too hard options to diff --git a/test.sh b/test.sh index 35cfdbd39..abc14274f 100755 --- a/test.sh +++ b/test.sh @@ -686,6 +686,23 @@ EOF checkstat 'cache miss' 0 checkstat 'unsupported compiler option' 4 + ################################################################## + # Check that -Wp,-D works + testname="-Wp,-D" + $CCACHE -Cz >/dev/null + $CCACHE_COMPILE -c -Wp,-DFOO test1.c + checkstat 'cache hit (direct)' 0 + checkstat 'cache hit (preprocessed)' 0 + checkstat 'cache miss' 1 + $CCACHE_COMPILE -c -DFOO test1.c + checkstat 'cache hit (direct)' 0 + checkstat 'cache hit (preprocessed)' 1 + checkstat 'cache miss' 1 + $CCACHE_COMPILE -c -Wp,-DFOO,-P test1.c + checkstat 'cache hit (direct)' 0 + checkstat 'cache hit (preprocessed)' 1 + checkstat 'cache miss' 2 + ################################################################## if [ $COMPILER_TYPE_CLANG -eq 1 ]; then @@ -987,6 +1004,23 @@ EOF rm -f different_name.d + ################################################################## + # Check that -Wp,-D works + testname="-Wp,-D" + $CCACHE -Cz >/dev/null + $CCACHE_COMPILE -c -Wp,-DFOO test.c + checkstat 'cache hit (direct)' 0 + checkstat 'cache hit (preprocessed)' 0 + checkstat 'cache miss' 1 + $CCACHE_COMPILE -c -DFOO test.c + checkstat 'cache hit (direct)' 1 + checkstat 'cache hit (preprocessed)' 0 + checkstat 'cache miss' 1 + $CCACHE_COMPILE -c -Wp,-DFOO,-P test.c + checkstat 'cache hit (direct)' 1 + checkstat 'cache hit (preprocessed)' 0 + checkstat 'cache miss' 2 + ################################################################## # Test some header modifications to get multiple objects in the manifest. testname="several objects"