Index: lld/COFF/Driver.cpp =================================================================== --- lld/COFF/Driver.cpp +++ lld/COFF/Driver.cpp @@ -756,15 +756,6 @@ if (Args.hasArg(OPT_force) || Args.hasArg(OPT_force_unresolved)) Config->Force = true; - // Handle /debug - if (Args.hasArg(OPT_debug)) { - Config->Debug = true; - Config->DebugTypes = - Args.hasArg(OPT_debugtype) - ? parseDebugType(Args.getLastArg(OPT_debugtype)->getValue()) - : getDefaultDebugType(Args); - } - // Create a dummy PDB file to satisfy build sytem rules. if (auto *Arg = Args.getLastArg(OPT_pdb)) Config->PDBPath = Arg->getValue(); @@ -842,6 +833,19 @@ if (auto *Arg = Args.getLastArg(OPT_implib)) Config->Implib = Arg->getValue(); + // Handle /debug + if (Args.hasArg(OPT_debug)) { + Config->Debug = true; + Config->DebugTypes = + Args.hasArg(OPT_debugtype) + ? parseDebugType(Args.getLastArg(OPT_debugtype)->getValue()) + : getDefaultDebugType(Args); + + // msvc linker uses /opt:noref by default in debug builds + Config->DoGC = false; + Config->DoICF = false; + } + // Handle /opt for (auto *Arg : Args.filtered(OPT_opt)) { std::string Str = StringRef(Arg->getValue()).lower();