Skip to content

Commit 4d44ed8

Browse files
committed
[FatLTO] Allow -fno-fat-lto-objects to override -ffat-lto-objects
1 parent af64f0a commit 4d44ed8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
860860
const bool IsAMDGCN = Triple.isAMDGCN();
861861
const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
862862
const Driver &D = ToolChain.getDriver();
863-
const bool IsFatLTO = Args.hasArg(options::OPT_ffat_lto_objects);
863+
const bool IsFatLTO = Args.hasFlag(options::OPT_ffat_lto_objects, options::OPT_fno_fat_lto_objects, false);
864864
const bool IsUnifiedLTO = Args.hasArg(options::OPT_funified_lto);
865865
if (llvm::sys::path::filename(Linker) != "ld.lld" &&
866866
llvm::sys::path::stem(Linker) != "ld.lld" && !Triple.isOSOpenBSD()) {

clang/test/Driver/fat-lto-objects.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
// CHECK-CC-NOLTO-SAME: -emit-obj
4242
// CHECK-CC-NOLTO-NOT: -ffat-lto-objects
4343

44+
/// Disable fat LTO when it is overridden by -fno-fat-lto-objects
45+
// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -fno-fat-lto-objects -### %s -c 2>&1 | FileCheck %s -check-prefix=CHECK-CC-NOLTO
46+
4447
/// We need to pass an additional flag (--fat-lto-objects) to lld when linking w/ -flto -ffat-lto-objects
4548
/// But it should not be there when LTO is disabled w/ -fno-lto
4649
// RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \

0 commit comments

Comments
 (0)