Author: Vincent Lee Date: 2025-02-21T13:15:03-08:00 New Revision: 74084ae73196441446c2beb5b9b57dd58eeeb3fe
URL: https://github.com/llvm/llvm-project/commit/74084ae73196441446c2beb5b9b57dd58eeeb3fe DIFF: https://github.com/llvm/llvm-project/commit/74084ae73196441446c2beb5b9b57dd58eeeb3fe.diff LOG: [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). Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/fat-lto-objects.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index ef4864996cb9a..360754bdb3161 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -864,7 +864,8 @@ 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..fae64ea7fd1a1 100644 --- a/clang/test/Driver/fat-lto-objects.c +++ b/clang/test/Driver/fat-lto-objects.c @@ -41,6 +41,8 @@ // CHECK-CC-NOLTO-SAME: -emit-obj // CHECK-CC-NOLTO-NOT: -ffat-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