From: Joel Rosdahl Date: Tue, 9 Dec 2025 19:14:57 +0000 (+0100) Subject: fix: Look for correct -march=native expansion line on Windows X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f51598e8805db8bd08e9da98d154f65fd0295300;p=thirdparty%2Fccache.git fix: Look for correct -march=native expansion line on Windows --- diff --git a/src/ccache/ccache.cpp b/src/ccache/ccache.cpp index 99ccfe49..b44296db 100644 --- a/src/ccache/ccache.cpp +++ b/src/ccache/ccache.cpp @@ -2026,7 +2026,11 @@ hash_native_args(Context& ctx, const util::Args& native_args, Hash& hash) std::string_view search_string = ctx.config.is_compiler_group_clang() ? "\"-cc1\"" // "/usr/lib/llvm-18/bin/clang" "-cc1" "-triple" ... - : "/cc1 -E"; // /usr/libexec/gcc/x86_64-linux-gnu/13/cc1 -E -quiet ... +#ifdef _WIN32 + : "/cc1.exe\" -E"; // "C:/.../cc1.exe" -E -quiet ... +#else + : "/cc1 -E"; // /usr/.../cc1 -E -quiet ... +#endif std::optional line_to_hash; for (const auto line : util::Tokenizer(*output, "\n")) { if (line.find(search_string) != std::string_view::npos) { diff --git a/test/fake-compilers/gcc-march-native-win.sh b/test/fake-compilers/gcc-march-native-win.sh new file mode 100755 index 00000000..7501a822 --- /dev/null +++ b/test/fake-compilers/gcc-march-native-win.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +args=("$@") + +if [ "$1" = "-###" ]; then + cat <&2 +Using built-in specs. +... +COLLECT_GCC_OPTIONS='-E' ... + "/example/cc1.exe" -E -quiet $CC1_ARGS +COMPILER_PATH=/example +EOF + echo "bin/cc1" +elif [ "$1" = "-E" ]; then + echo preprocessed >"${args[$#-2]}" +else + echo compiled >"${args[$#-2]}" +fi diff --git a/test/suites/base.bash b/test/suites/base.bash index 0074ebf7..cdb7daff 100644 --- a/test/suites/base.bash +++ b/test/suites/base.bash @@ -1661,19 +1661,25 @@ EOF # ------------------------------------------------------------------------- TEST "-march=native, GCC" - CC1_ARGS=one $CCACHE "$TEST_BASE_DIR/fake-compilers/gcc-march-native.sh" -march=native -c test1.c + if $HOST_OS_WINDOWS; then + compiler="$TEST_BASE_DIR/fake-compilers/gcc-march-native-win.sh" + else + compiler="$TEST_BASE_DIR/fake-compilers/gcc-march-native.sh" + fi + + CC1_ARGS=one $CCACHE "${compiler}" -march=native -c test1.c expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 - CC1_ARGS=one $CCACHE "$TEST_BASE_DIR/fake-compilers/gcc-march-native.sh" -march=native -c test1.c + CC1_ARGS=one $CCACHE "${compiler}" -march=native -c test1.c expect_stat preprocessed_cache_hit 1 expect_stat cache_miss 1 - CC1_ARGS=two $CCACHE "$TEST_BASE_DIR/fake-compilers/gcc-march-native.sh" -march=native -c test1.c + CC1_ARGS=two $CCACHE "${compiler}" -march=native -c test1.c expect_stat preprocessed_cache_hit 1 expect_stat cache_miss 2 - CC1_ARGS=two $CCACHE "$TEST_BASE_DIR/fake-compilers/gcc-march-native.sh" -march=native -c test1.c + CC1_ARGS=two $CCACHE "${compiler}" -march=native -c test1.c expect_stat preprocessed_cache_hit 2 expect_stat cache_miss 2