]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Don't treat -Wp,-D as interchangeable with -D
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 18 Jan 2023 20:30:25 +0000 (21:30 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 18 Jan 2023 21:00:59 +0000 (22:00 +0100)
Fixes #1238.

src/argprocessing.cpp
test/suites/base.bash
test/suites/direct.bash

index 0bc37e5754a8452595e758a8f0bddbf6d9e6a6af..80905b36c8421e6d6fc4d5e5a74bf2a54414c798 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2022 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2023 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -817,8 +817,7 @@ process_option_arg(const Context& ctx,
       return Statistic::none;
     } else if (util::starts_with(args[i], "-Wp,-D")
                && args[i].find(',', 6) == std::string::npos) {
-      // Treat it like -D.
-      state.cpp_args.push_back(args[i].substr(4));
+      state.cpp_args.push_back(args[i]);
       return Statistic::none;
     } else if (args[i] == "-Wp,-MP"
                || (args[i].size() > 8 && util::starts_with(args[i], "-Wp,-M")
index 2bb8d349ab7f4f96a8d200a818d2e9bae713bca6..ff9059420100802fb1825981750ae7bf43f8828a 100644 (file)
@@ -1520,11 +1520,21 @@ EOF
     expect_stat preprocessed_cache_hit 0
     expect_stat cache_miss 1
 
-    $CCACHE_COMPILE -c -DFOO test1.c
+    $CCACHE_COMPILE -c -Wp,-DFOO test1.c
     expect_stat direct_cache_hit 0
     expect_stat preprocessed_cache_hit 1
     expect_stat cache_miss 1
 
+    $CCACHE_COMPILE -c -DFOO test1.c
+    expect_stat direct_cache_hit 0
+    expect_stat preprocessed_cache_hit 1
+    expect_stat cache_miss 2
+
+    $CCACHE_COMPILE -c -DFOO test1.c
+    expect_stat direct_cache_hit 0
+    expect_stat preprocessed_cache_hit 2
+    expect_stat cache_miss 2
+
     # -------------------------------------------------------------------------
     if touch empty.c && $COMPILER -c -- empty.c 2>/dev/null; then
         TEST "--"
index e297d688af10fa9f3f734df8e50356c381a32f3d..a9dc9c5e326007eb62a4f11417a9f42c6a7ace64 100644 (file)
@@ -443,11 +443,21 @@ fi
     expect_stat preprocessed_cache_hit 0
     expect_stat cache_miss 1
 
-    $CCACHE_COMPILE -c -DFOO test.c
+    $CCACHE_COMPILE -c -Wp,-DFOO test.c
     expect_stat direct_cache_hit 1
     expect_stat preprocessed_cache_hit 0
     expect_stat cache_miss 1
 
+    $CCACHE_COMPILE -c -DFOO test.c
+    expect_stat direct_cache_hit 1
+    expect_stat preprocessed_cache_hit 0
+    expect_stat cache_miss 2
+
+    $CCACHE_COMPILE -c -DFOO test.c
+    expect_stat direct_cache_hit 2
+    expect_stat preprocessed_cache_hit 0
+    expect_stat cache_miss 2
+
     # -------------------------------------------------------------------------
     TEST "-Wp, with multiple arguments"