diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4785,8 +4785,8 @@ break; case llvm::Triple::MSVC: case llvm::Triple::UnknownEnvironment: - if (Args.getLastArgValue(options::OPT_fuse_ld_EQ) - .startswith_lower("bfd")) + auto linkerFlavor = Args.getLastArgValue(options::OPT_fuse_ld_EQ); + if (linkerFlavor.startswith_lower("bfd") || linkerFlavor.equals_lower("lld") TC = std::make_unique( *this, Target, Args); else diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -490,13 +490,10 @@ std::vector Environment; - // We need to special case some linker paths. In the case of lld, we need to - // translate 'lld' into 'lld-link', and in the case of the regular msvc + // We need to special case some linker paths. In the case of the regular msvc // linker, we need to use a special search algorithm. llvm::SmallString<128> linkPath; StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link"); - if (Linker.equals_lower("lld")) - Linker = "lld-link"; if (Linker.equals_lower("link")) { // If we're using the MSVC linker, it's not sufficient to just use link diff --git a/clang/test/Driver/fuse-ld.c b/clang/test/Driver/fuse-ld.c --- a/clang/test/Driver/fuse-ld.c +++ b/clang/test/Driver/fuse-ld.c @@ -79,8 +79,13 @@ // RUN: %clang %s -### -fuse-ld=lld \ // RUN: -target i686-unknown-windows-msvc 2>&1 \ // RUN: | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-LLD -// CHECK-WINDOWS-MSVC-LLD: "{{.*}}lld-link" -// CHECK-WINDOWS-MSVC-LLD-SAME: "-out:{{.*}}" +// CHECK-WINDOWS-MSVC-LLD: "{{.*}}ld.lld" +// CHECK-WINDOWS-MSVC-LLD-SAME: "-o" + +// RUN: %clang-cl %s -### -fuse-ld=lld \ +// RUN: | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-LLD +// CHECK-cl-WINDOWS-MSVC-LLD: "{{.*}}ld.lld" +// CHECK-cl-WINDOWS-MSVC-LLD-SAME: "-o" // RUN: %clang %s -### -fuse-ld=lld-link \ // RUN: -target i686-unknown-windows-msvc 2>&1 \