]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Handle MSVC flags -MD[d], -MT[d] and -LT[d] properly (#971)
authorLuboš Luňák <l.lunak@centrum.cz>
Sun, 12 Dec 2021 20:09:40 +0000 (21:09 +0100)
committerGitHub <noreply@github.com>
Sun, 12 Dec 2021 20:09:40 +0000 (21:09 +0100)
src/argprocessing.cpp

index 67dda2c64a195140b9406413d722392a12149818..85bd800767c55d4ae0305fb57bddbb53286f0b8a 100644 (file)
@@ -570,7 +570,8 @@ process_arg(const Context& ctx,
     return nullopt;
   }
 
-  if (util::starts_with(args[i], "-MQ") || util::starts_with(args[i], "-MT")) {
+  if ((util::starts_with(args[i], "-MQ") || util::starts_with(args[i], "-MT"))
+      && config.compiler_type() != CompilerType::cl) {
     args_info.dependency_target_specified = true;
 
     if (args[i].size() == 3) {
@@ -592,6 +593,21 @@ process_arg(const Context& ctx,
     return nullopt;
   }
 
+  // MSVC -MD[d], -MT[d] and -LT[d] options are something different than GCC's
+  // -MD etc.
+  if (config.compiler_type() == CompilerType::cl
+      && (util::starts_with(args[i], "-MD")
+          || util::starts_with(args[i], "-MDd")
+          || util::starts_with(args[i], "-MT")
+          || util::starts_with(args[i], "-MTd")
+          || util::starts_with(args[i], "-LD")
+          || util::starts_with(args[i], "-LDd"))) {
+    // These affect compiler but also #define some things.
+    state.cpp_args.push_back(args[i]);
+    state.common_args.push_back(args[i]);
+    return nullopt;
+  }
+
   if (args[i] == "-fprofile-arcs") {
     args_info.profile_arcs = true;
     state.common_args.push_back(args[i]);