summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Hieta <tobias@hieta.se>2023-03-28 21:45:37 +0200
committerGitHub <noreply@github.com>2023-03-28 21:45:37 +0200
commite9d33e4f5edb23c7db661c6cbb451fb45c573f67 (patch)
tree8a7df06af76f2981c8185628ad4a8412230e50df
parent1519c9aa1d89608f2690584a15ff5d4d021b27ed (diff)
downloadccache-e9d33e4f5edb23c7db661c6cbb451fb45c573f67.tar.gz
feat: Don't treat /Zi as unsupported for clang-cl (#1266)
For MSVC /Zi is unsupported since it writes a additional .pdb file per each .obj file and it creates some messy interaction with ccache. But for clang-cl /Zi is actually treated as /Z7 and only embeds the debug info in the .obj file so it makes sense to allow this flag when compiling with clang-cl.
-rw-r--r--src/argprocessing.cpp3
-rw-r--r--unittest/test_argprocessing.cpp26
2 files changed, 28 insertions, 1 deletions
diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp
index bad2dadd..f300e7bd 100644
--- a/src/argprocessing.cpp
+++ b/src/argprocessing.cpp
@@ -608,7 +608,8 @@ process_option_arg(const Context& ctx,
return Statistic::none;
}
- if (config.is_compiler_group_msvc() && util::starts_with(arg, "-Z")) {
+ if (config.is_compiler_group_msvc() && !config.is_compiler_group_clang()
+ && util::starts_with(arg, "-Z")) {
state.last_seen_msvc_z_option = args[i];
state.common_args.push_back(args[i]);
return Statistic::none;
diff --git a/unittest/test_argprocessing.cpp b/unittest/test_argprocessing.cpp
index bf98b090..ccb6e117 100644
--- a/unittest/test_argprocessing.cpp
+++ b/unittest/test_argprocessing.cpp
@@ -746,4 +746,30 @@ TEST_CASE("MSVC debug information format options")
}
}
+// Check that clang-cl debug information is parsed different,
+// since for clang-cl /Zi and /Z7 is the same!
+TEST_CASE("ClangCL Debug information options")
+{
+ TestContext test_context;
+ Context ctx;
+ ctx.config.set_compiler_type(CompilerType::clang_cl);
+ util::write_file("foo.c", "");
+
+ SUBCASE("/Z7")
+ {
+ ctx.orig_args = Args::from_string("clang-cl.exe /c foo.c /Z7");
+ const ProcessArgsResult result = process_args(ctx);
+ REQUIRE(!result.error);
+ CHECK(result.preprocessor_args.to_string() == "clang-cl.exe /Z7");
+ }
+
+ SUBCASE("/Zi")
+ {
+ ctx.orig_args = Args::from_string("clang-cl.exe /c foo.c /Zi");
+ const ProcessArgsResult result = process_args(ctx);
+ REQUIRE(!result.error);
+ CHECK(result.preprocessor_args.to_string() == "clang-cl.exe /Zi");
+ }
+}
+
TEST_SUITE_END();