From ace03d0df4fa861981c79a38892584bcbc4e3c15 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 2 Dec 2021 11:10:41 -0800 Subject: [PATCH] [clang][Darwin] Remove old lld implementation handling This now assumes that for the darwin driver any lld is the "new" macho lld implementation. Differential Revision: https://reviews.llvm.org/D114974 --- clang/include/clang/Driver/ToolChain.h | 5 +---- clang/lib/Driver/ToolChain.cpp | 10 ++-------- clang/lib/Driver/ToolChains/Darwin.cpp | 16 +++++++--------- clang/lib/Driver/ToolChains/Darwin.h | 2 +- clang/test/Driver/darwin-ld-demangle-lld.c | 5 ----- clang/test/Driver/darwin-ld-platform-version-ios.c | 4 ---- clang/test/Driver/darwin-ld-platform-version-macos.c | 4 ---- clang/test/Driver/darwin-ld-platform-version-tvos.c | 4 ---- clang/test/Driver/darwin-ld-platform-version-watchos.c | 4 ---- 9 files changed, 11 insertions(+), 43 deletions(-) diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index dad861d..e7b13ee 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -348,10 +348,7 @@ public: /// is LLD. If it's set, it can be assumed that the linker is LLD built /// at the same revision as clang, and clang can make assumptions about /// LLD's supported flags, error output, etc. - /// If LinkerIsLLDDarwinNew is non-nullptr, it's set if the linker is - /// the new version in lld/MachO. - std::string GetLinkerPath(bool *LinkerIsLLD = nullptr, - bool *LinkerIsLLDDarwinNew = nullptr) const; + std::string GetLinkerPath(bool *LinkerIsLLD = nullptr) const; /// Returns the linker path for emitting a static library. std::string GetStaticLibToolPath() const; diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 6588cdf..ac033dd 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -541,12 +541,9 @@ std::string ToolChain::GetProgramPath(const char *Name) const { return D.GetProgramPath(Name, *this); } -std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD, - bool *LinkerIsLLDDarwinNew) const { +std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const { if (LinkerIsLLD) *LinkerIsLLD = false; - if (LinkerIsLLDDarwinNew) - *LinkerIsLLDDarwinNew = false; // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= is // considered as the linker flavor, e.g. "bfd", "gold", or "lld". @@ -599,11 +596,8 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD, std::string LinkerPath(GetProgramPath(LinkerName.c_str())); if (llvm::sys::fs::can_execute(LinkerPath)) { - // FIXME: Remove LinkerIsLLDDarwinNew once there's only one MachO lld. if (LinkerIsLLD) - *LinkerIsLLD = UseLinker == "lld" || UseLinker == "lld.darwinold"; - if (LinkerIsLLDDarwinNew) - *LinkerIsLLDDarwinNew = UseLinker == "lld"; + *LinkerIsLLD = UseLinker == "lld"; return LinkerPath; } } diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 06d3edc..89d8fbe 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -209,8 +209,7 @@ static bool shouldLinkerNotDedup(bool IsLinkerOnlyAction, const ArgList &Args) { void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, ArgStringList &CmdArgs, const InputInfoList &Inputs, - unsigned Version[5], bool LinkerIsLLD, - bool LinkerIsLLDDarwinNew) const { + unsigned Version[5], bool LinkerIsLLD) const { const Driver &D = getToolChain().getDriver(); const toolchains::MachO &MachOTC = getMachOToolChain(); @@ -343,7 +342,7 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, Args.AddAllArgs(CmdArgs, options::OPT_init); // Add the deployment target. - if (Version[0] >= 520 || LinkerIsLLDDarwinNew) + if (Version[0] >= 520 || LinkerIsLLD) MachOTC.addPlatformVersionArgs(Args, CmdArgs); else MachOTC.addMinVersionArgs(Args, CmdArgs); @@ -556,14 +555,13 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA, << A->getAsString(Args); } - bool LinkerIsLLD, LinkerIsLLDDarwinNew; - const char *Exec = Args.MakeArgString( - getToolChain().GetLinkerPath(&LinkerIsLLD, &LinkerIsLLDDarwinNew)); + bool LinkerIsLLD; + const char *Exec = + Args.MakeArgString(getToolChain().GetLinkerPath(&LinkerIsLLD)); // I'm not sure why this particular decomposition exists in gcc, but // we follow suite for ease of comparison. - AddLinkArgs(C, Args, CmdArgs, Inputs, Version, LinkerIsLLD, - LinkerIsLLDDarwinNew); + AddLinkArgs(C, Args, CmdArgs, Inputs, Version, LinkerIsLLD); if (willEmitRemarks(Args) && checkRemarksOptions(getToolChain().getDriver(), Args, @@ -715,7 +713,7 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA, } ResponseFileSupport ResponseSupport; - if (Version[0] >= 705 || LinkerIsLLDDarwinNew) { + if (Version[0] >= 705 || LinkerIsLLD) { ResponseSupport = ResponseFileSupport::AtFileUTF8(); } else { // For older versions of the linker, use the legacy filelist method instead. diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h index a307cd3..5e23047 100644 --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -64,7 +64,7 @@ class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool { void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const InputInfoList &Inputs, unsigned Version[5], - bool LinkerIsLLD, bool LinkerIsLLDDarwinNew) const; + bool LinkerIsLLD) const; public: Linker(const ToolChain &TC) : MachOTool("darwin::Linker", "linker", TC) {} diff --git a/clang/test/Driver/darwin-ld-demangle-lld.c b/clang/test/Driver/darwin-ld-demangle-lld.c index 9610f6b..3d44c3d 100644 --- a/clang/test/Driver/darwin-ld-demangle-lld.c +++ b/clang/test/Driver/darwin-ld-demangle-lld.c @@ -1,11 +1,6 @@ // With -fuse-ld=lld, -demangle is always passed to the linker on Darwin. // REQUIRES: shell -// FIXME: Remove this test case when we remove the lld.darwinold backend. -// RUN: %clang --target=x86_64-apple-darwin -### \ -// RUN: -fuse-ld=lld.darwinold -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \ -// RUN: | FileCheck %s - // RUN: %clang --target=x86_64-apple-darwin -### \ // RUN: -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \ // RUN: | FileCheck %s diff --git a/clang/test/Driver/darwin-ld-platform-version-ios.c b/clang/test/Driver/darwin-ld-platform-version-ios.c index bd518c3..685caa7 100644 --- a/clang/test/Driver/darwin-ld-platform-version-ios.c +++ b/clang/test/Driver/darwin-ld-platform-version-ios.c @@ -1,9 +1,5 @@ // RUN: touch %t.o -// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld=lld.darwinold \ -// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \ -// RUN: -### %t.o 2>&1 \ -// RUN: | FileCheck --check-prefix=LINKER-OLD %s // RUN: %clang -target arm64-apple-ios12.3 -fuse-ld= \ // RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \ // RUN: -### %t.o 2>&1 \ diff --git a/clang/test/Driver/darwin-ld-platform-version-macos.c b/clang/test/Driver/darwin-ld-platform-version-macos.c index 8778281..355df8d 100644 --- a/clang/test/Driver/darwin-ld-platform-version-macos.c +++ b/clang/test/Driver/darwin-ld-platform-version-macos.c @@ -1,9 +1,5 @@ // RUN: touch %t.o -// RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld.darwinold \ -// RUN: -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \ -// RUN: -### %t.o 2>&1 \ -// RUN: | FileCheck --check-prefix=LINKER-OLD %s // RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld \ // RUN: -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \ // RUN: -### %t.o -B%S/Inputs/lld 2>&1 \ diff --git a/clang/test/Driver/darwin-ld-platform-version-tvos.c b/clang/test/Driver/darwin-ld-platform-version-tvos.c index bf57c26..28890cf 100644 --- a/clang/test/Driver/darwin-ld-platform-version-tvos.c +++ b/clang/test/Driver/darwin-ld-platform-version-tvos.c @@ -1,9 +1,5 @@ // RUN: touch %t.o -// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld.darwinold \ -// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \ -// RUN: -### %t.o 2>&1 \ -// RUN: | FileCheck --check-prefix=LINKER-OLD %s // RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld= \ // RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \ // RUN: -### %t.o 2>&1 \ diff --git a/clang/test/Driver/darwin-ld-platform-version-watchos.c b/clang/test/Driver/darwin-ld-platform-version-watchos.c index 639c937..3d405a7 100644 --- a/clang/test/Driver/darwin-ld-platform-version-watchos.c +++ b/clang/test/Driver/darwin-ld-platform-version-watchos.c @@ -1,9 +1,5 @@ // RUN: touch %t.o -// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinold \ -// RUN: -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \ -// RUN: -### %t.o 2>&1 \ -// RUN: | FileCheck --check-prefix=LINKER-OLD %s // RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld= \ // RUN: -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 \ // RUN: -### %t.o 2>&1 \ -- 2.7.4