https://github.com/thevinster created https://github.com/llvm/llvm-project/pull/128157
For builds that cannot 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 many clang and lld flags are used). >From 4d44ed82dc822e486aee3620707b463214fb18cb Mon Sep 17 00:00:00 2001 From: Vincent Lee <leevi...@fb.com> Date: Fri, 21 Feb 2025 02:04:53 -0800 Subject: [PATCH] [FatLTO] Allow -fno-fat-lto-objects to override -ffat-lto-objects --- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/test/Driver/fat-lto-objects.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 1a2299a92c54e..50db1e2f7d509 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -860,7 +860,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args, const bool IsAMDGCN = Triple.isAMDGCN(); const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath()); const Driver &D = ToolChain.getDriver(); - const bool IsFatLTO = Args.hasArg(options::OPT_ffat_lto_objects); + 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()) { diff --git a/clang/test/Driver/fat-lto-objects.c b/clang/test/Driver/fat-lto-objects.c index d9a5ba88ea6d6..691fcbfc72140 100644 --- a/clang/test/Driver/fat-lto-objects.c +++ b/clang/test/Driver/fat-lto-objects.c @@ -41,6 +41,9 @@ // CHECK-CC-NOLTO-SAME: -emit-obj // CHECK-CC-NOLTO-NOT: -ffat-lto-objects +/// Disable fat LTO when it is overridden by -fno-fat-lto-objects +// 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 + /// We need to pass an additional flag (--fat-lto-objects) to lld when linking w/ -flto -ffat-lto-objects /// But it should not be there when LTO is disabled w/ -fno-lto // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits