Skip to content
Closed
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
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
if (llvm::sys::fs::can_execute(UseLinker))
return std::string(UseLinker);
} else {
llvm::SmallString<8> LinkerName;
llvm::SmallString<8> LinkerName = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unnecessary? Would be nice to stay as close to upstream as possible.

if (Triple.isOSDarwin())
LinkerName.append("ld64.");
else
Expand Down
11 changes: 10 additions & 1 deletion clang/lib/Driver/ToolChains/Gnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,17 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}

Args.AddAllArgs(CmdArgs, options::OPT_T);
bool useLLD = false;
const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath(&useLLD));
if (useLLD) {
Comment on lines +680 to +682
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not if (Args.hasArg(options::OPT_fuse_ld_EQ) && Args.getLastArgValue(options::OPT_fuse_ld_EQ).ends_with_insensitive("lld"))?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, mainly to support when someone isn't passing --fuse-ld=lld. It should still catch it if clang was configured to use lld by default. We're already calling GetLinkerPath, which is also conveniently supposed to detect when the linker is lld either through clang being configured to use lld by default, --fuse-ld=lld, or --ld-path=<filepath>/ld.lld.

/// Workaround for https://reviews.llvm.org/D96914 breaking Swift.
/// Newer LLD versions change symbols, resulting in incorrect locations
/// for the type metadata tables. Forcing `-z nostart-stop-gc` on LLD so
/// that it does not munge the symbols.
CmdArgs.push_back("-z");
CmdArgs.push_back("nostart-stop-gc");
}

const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
C.addCommand(std::make_unique<Command>(JA, *this,
ResponseFileSupport::AtFileCurCP(),
Exec, CmdArgs, Inputs, Output));
Expand Down