Index: clang/lib/Driver/ToolChain.cpp =================================================================== --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -620,13 +620,18 @@ // --ld-path= takes precedence over -fuse-ld= and specifies the executable // name. -B, COMPILER_PATH and PATH and consulted if the value does not // contain a path component separator. + // -fuse-ld=lld can be used with --ld-path= to inform clang that the binary + // that --ld-path= points to is lld. if (const Arg *A = Args.getLastArg(options::OPT_ld_path_EQ)) { std::string Path(A->getValue()); if (!Path.empty()) { if (llvm::sys::path::parent_path(Path).empty()) Path = GetProgramPath(A->getValue()); - if (llvm::sys::fs::can_execute(Path)) + if (llvm::sys::fs::can_execute(Path)) { + if (LinkerIsLLD) + *LinkerIsLLD = UseLinker == "lld"; return std::string(Path); + } } getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args); return GetProgramPath(getDefaultLinker()); Index: clang/test/Driver/darwin-ld-demangle-lld.c =================================================================== --- clang/test/Driver/darwin-ld-demangle-lld.c +++ clang/test/Driver/darwin-ld-demangle-lld.c @@ -1,8 +1,12 @@ // With -fuse-ld=lld, -demangle is always passed to the linker on Darwin. // REQUIRES: shell -// RUN: %clang --target=x86_64-apple-darwin -### \ -// RUN: -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \ +// RUN: %clang --target=x86_64-apple-darwin -### -fuse-ld=lld \ +// RUN: -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \ +// RUN: | FileCheck %s + +// RUN: %clang --target=x86_64-apple-darwin -### -fuse-ld=lld \ +// RUN: --ld-path=%S/Inputs/lld/ld64.lld -mlinker-version=0 %s 2>&1 \ // RUN: | FileCheck %s // CHECK: "-demangle"