Skip to content

Commit 74084ae

Browse files
authored
[FatLTO] Allow -fno-fat-lto-objects to override -ffat-lto-objects (#128157)
For builds that cannot be easily modified and enabled with `-ffat-lto-objects`, `-fno-fat-lto-objects` acts as an escape hatch to disable this option (which is standard to how clang and lld flags are used).
1 parent 374c470 commit 74084ae

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

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

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

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

44+
// 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
45+
4446
/// We need to pass an additional flag (--fat-lto-objects) to lld when linking w/ -flto -ffat-lto-objects
4547
/// But it should not be there when LTO is disabled w/ -fno-lto
4648
// RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \

0 commit comments

Comments
 (0)