Skip to content

cherry-pick upstream changes to remove "old" Darwin lld support #3636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions clang/include/clang/Driver/ToolChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,7 @@ class ToolChain {
/// 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;
Expand Down
10 changes: 2 additions & 8 deletions clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,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".
Expand Down Expand Up @@ -601,11 +598,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;
}
}
Expand Down
16 changes: 7 additions & 9 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -561,14 +560,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,
Expand Down Expand Up @@ -720,7 +718,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.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
5 changes: 0 additions & 5 deletions clang/test/Driver/darwin-ld-demangle-lld.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 0 additions & 4 deletions clang/test/Driver/darwin-ld-platform-version-ios.c
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
4 changes: 0 additions & 4 deletions clang/test/Driver/darwin-ld-platform-version-macos.c
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
4 changes: 0 additions & 4 deletions clang/test/Driver/darwin-ld-platform-version-tvos.c
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
4 changes: 0 additions & 4 deletions clang/test/Driver/darwin-ld-platform-version-watchos.c
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
2 changes: 0 additions & 2 deletions lld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,10 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
endif()

add_subdirectory(Common)
add_subdirectory(lib)
add_subdirectory(tools/lld)

if (LLVM_INCLUDE_TESTS)
add_subdirectory(test)
add_subdirectory(unittests)
endif()

add_subdirectory(docs)
Expand Down
5 changes: 0 additions & 5 deletions lld/include/lld/Common/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ bool link(llvm::ArrayRef<const char *> args, bool canExitEarly,
llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS);
}

namespace mach_o {
bool link(llvm::ArrayRef<const char *> args, bool canExitEarly,
llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS);
}

namespace macho {
bool link(llvm::ArrayRef<const char *> args, bool canExitEarly,
llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS);
Expand Down
3 changes: 1 addition & 2 deletions lld/include/lld/Core/Reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ class Reference {
public:
/// Which universe defines the kindValue().
enum class KindNamespace {
all = 0,
all = 0,
testing = 1,
mach_o = 2,
};

KindNamespace kindNamespace() const { return (KindNamespace)_kindNamespace; }
Expand Down
Loading