continue;
}
if (str_startswith(argv[i], "-Wp,")) {
- if (str_eq(argv[i], "-Wp,-P") || strstr(argv[i], ",-P,")) {
+ if (str_eq(argv[i], "-Wp,-P")
+ || strstr(argv[i], ",-P,")
+ || str_endswith(argv[i], ",-P")) {
// -P removes preprocessor information in such a way that the object
// file from compiling the preprocessed file will not be equal to the
// object file produced when compiling without ccache.
#define SLOPPY_NO_SYSTEM_HEADERS 64
#define str_eq(s1, s2) (strcmp((s1), (s2)) == 0)
-#define str_startswith(s, p) (strncmp((s), (p), strlen((p))) == 0)
+#define str_startswith(s, prefix) \
+ (strncmp((s), (prefix), strlen((prefix))) == 0)
+#define str_endswith(s, suffix) \
+ (strlen(s) >= strlen(suffix) \
+ && str_eq((s) + strlen(s) - strlen(suffix), (suffix)))
// ----------------------------------------------------------------------------
// args.c
expect_stat 'cache miss' 0
expect_stat 'unsupported compiler option' 1
- $CCACHE_COMPILE -c -Wp,-P test1.c
+ $CCACHE_COMPILE -c -Wp,-P,-DFOO test1.c
expect_stat 'cache hit (direct)' 0
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 0
expect_stat 'unsupported compiler option' 2
- $CCACHE_COMPILE -c -Wp,-DFOO,-P,-DGOO test1.c
+ $CCACHE_COMPILE -c -Wp,-DFOO,-P test1.c
expect_stat 'cache hit (direct)' 0
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 0
expect_stat 'unsupported compiler option' 3
- $CCACHE_COMPILE -c -Wp,-DFOO,-P,-DGOO test1.c
- expect_stat 'cache hit (direct)' 0
- expect_stat 'cache hit (preprocessed)' 0
- expect_stat 'cache miss' 0
- expect_stat 'unsupported compiler option' 4
-
# -------------------------------------------------------------------------
TEST "-Wp,-D"
expect_stat 'cache hit (preprocessed)' 1
expect_stat 'cache miss' 1
- $CCACHE_COMPILE -c -Wp,-DFOO,-P test1.c
- expect_stat 'cache hit (direct)' 0
- expect_stat 'cache hit (preprocessed)' 1
- expect_stat 'cache miss' 2
-
# -------------------------------------------------------------------------
TEST "Buggy GCC 6 cpp"