Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 3 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,13 +862,12 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
const llvm::Triple &Triple = ToolChain.getTriple();
Copy link
Member

Choose a reason for hiding this comment

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

This change would be desired as -fuse-ld= is better than --ld-path=. However, some users customize CLANG_DEFAULT_LINKER or hard code lld. They have no -fuse-ld= but still use lld....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can restore the original behavior on the linker path plus the additional check on -fuse-ld=. This would at least solve our use case if that's what you're suggesting here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think it's best to keep the old check as well as adding the new one.

const bool IsOSAIX = Triple.isOSAIX();
const bool IsAMDGCN = Triple.isAMDGCN();
const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ);
const Driver &D = ToolChain.getDriver();
const bool IsFatLTO = Args.hasFlag(options::OPT_ffat_lto_objects,
options::OPT_fno_fat_lto_objects, false);
const bool IsUnifiedLTO = Args.hasArg(options::OPT_funified_lto);
if (llvm::sys::path::filename(Linker) != "ld.lld" &&
llvm::sys::path::stem(Linker) != "ld.lld" && !Triple.isOSOpenBSD()) {
if (Linker != "lld" && Linker != "lld-link" && !Triple.isOSOpenBSD()) {
// Tell the linker to load the plugin. This has to come before
// AddLinkerInputs as gold requires -plugin and AIX ld requires -bplugin to
// come before any -plugin-opt/-bplugin_opt that -Wl might forward.
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Driver/fat-lto-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@
// RUN: -fuse-ld=lld -flto -ffat-lto-objects -### 2>&1 | FileCheck --check-prefix=LTO %s
// RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \
// RUN: -fuse-ld=lld -fno-lto -ffat-lto-objects -### 2>&1 | FileCheck --check-prefix=NOLTO %s
// RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \
// RUN: -fuse-ld=lld --ld-path=%S/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/lld-wrapper \
// RUN: -flto -ffat-lto-objects -### 2>&1 | FileCheck --check-prefix=LTO %s
// LTO: "--fat-lto-objects"
// NOLTO-NOT: "--fat-lto-objects"
Loading