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<std::string_view> line_to_hash;
for (const auto line : util::Tokenizer(*output, "\n")) {
if (line.find(search_string) != std::string_view::npos) {
--- /dev/null
+#!/bin/bash
+
+args=("$@")
+
+if [ "$1" = "-###" ]; then
+ cat <<EOF >&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
# -------------------------------------------------------------------------
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