Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -8903,6 +8903,12 @@ // handled somewhere else. Args.ClaimAllArgs(options::OPT_w); + StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld"); + if (Linker.equals_lower("lld")) { + CmdArgs.push_back("-flavor"); + CmdArgs.push_back("gnu"); + } + if (!D.SysRoot.empty()) CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); @@ -8914,6 +8920,8 @@ CmdArgs.push_back("i386pe"); if (TC.getArch() == llvm::Triple::x86_64) CmdArgs.push_back("i386pep"); + if (TC.getArch() == llvm::Triple::arm) + CmdArgs.push_back("thumb2pe"); if (Args.hasArg(options::OPT_mwindows)) { CmdArgs.push_back("--subsystem"); @@ -9023,7 +9031,7 @@ if (Args.hasArg(options::OPT_static)) CmdArgs.push_back("--end-group"); - else + else if (!Linker.equals_lower("lld")) AddLibGCC(Args, CmdArgs); } @@ -9034,7 +9042,7 @@ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o"))); } } - const char *Exec = Args.MakeArgString(TC.GetProgramPath("ld")); + const char *Exec = Args.MakeArgString(TC.GetProgramPath(Linker.data())); C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs)); }