]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Detect PCH for concatenated -include option
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 24 Aug 2022 17:41:07 +0000 (19:41 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 25 Aug 2022 19:43:01 +0000 (21:43 +0200)
Fixes #1143.

(cherry picked from commit 53b1fef9c818f53fb04455b357ebbc6572987962)

src/argprocessing.cpp
test/suites/pch.bash

index 2d3a868a3d9f7dbe3da7abff78652a1d065793ce..920f013aa1692471b214c2caa41975e1c98ce85a 100644 (file)
@@ -925,8 +925,10 @@ process_arg(const Context& ctx,
   }
 
   // Detect PCH for options with concatenated path (relative or absolute).
-  if (util::starts_with(args[i], "-Fp") || util::starts_with(args[i], "-Yu")) {
-    const size_t path_pos = 3;
+  if (util::starts_with(args[i], "-include")
+      || util::starts_with(args[i], "-Fp")
+      || util::starts_with(args[i], "-Yu")) {
+    const size_t path_pos = util::starts_with(args[i], "-include") ? 8 : 3;
     if (!detect_pch(args[i].substr(0, path_pos),
                     args[i].substr(path_pos),
                     args_info.included_pch_file,
index ec5fc08ad62037b28a16c5730ffd59d7e513d03d..12968b4101fb5859a7925cd37d4f450d3b3c4a31 100644 (file)
@@ -134,17 +134,23 @@ pch_suite_common() {
     expect_stat preprocessor_error 1
 
     # -------------------------------------------------------------------------
-    TEST "Use .gch, -include, no sloppiness"
-
-    $COMPILER $SYSROOT -c pch.h
-    backdate pch.h.gch
-
-    $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c
-    expect_stat direct_cache_hit 0
-    expect_stat preprocessed_cache_hit 0
-    expect_stat cache_miss 0
-    # Must enable sloppy time macros:
-    expect_stat could_not_use_precompiled_header 1
+    include_pch_variants=(
+        "-include pch.h"
+        "-includepch.h"
+    )
+    for args in "${include_pch_variants[@]}"; do
+        TEST "Use .gch, $args, no sloppiness"
+
+        $COMPILER $SYSROOT -c pch.h
+        backdate pch.h.gch
+
+        $CCACHE_COMPILE $SYSROOT -c $args pch2.c
+        expect_stat direct_cache_hit 0
+        expect_stat preprocessed_cache_hit 0
+        expect_stat cache_miss 0
+        # Must enable sloppy time macros:
+        expect_stat could_not_use_precompiled_header 1
+    done
 
     # -------------------------------------------------------------------------
     TEST "Use .gch, -include"