From: Joel Rosdahl Date: Wed, 24 Aug 2022 17:41:07 +0000 (+0200) Subject: fix: Detect PCH for concatenated -include option X-Git-Tag: v4.7~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53b1fef9c818f53fb04455b357ebbc6572987962;p=thirdparty%2Fccache.git fix: Detect PCH for concatenated -include option Fixes #1143. --- diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index daf3b5ff0..ca8d379d4 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -962,8 +962,10 @@ process_option_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, diff --git a/test/suites/pch.bash b/test/suites/pch.bash index ec5fc08ad..12968b410 100644 --- a/test/suites/pch.bash +++ b/test/suites/pch.bash @@ -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"