-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[FatLTO] Allow -fno-fat-lto-objects to override -ffat-lto-objects #128157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-driver Author: Vincent Lee (thevinster) ChangesFor builds that cannot be easily modified and enabled with Full diff: https://github.com/llvm/llvm-project/pull/128157.diff 2 Files Affected:
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 \
|
@llvm/pr-subscribers-clang Author: Vincent Lee (thevinster) ChangesFor builds that cannot be easily modified and enabled with Full diff: https://github.com/llvm/llvm-project/pull/128157.diff 2 Files Affected:
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 \
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
clang/test/Driver/fat-lto-objects.c
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete this comment. This is an obvious case and we don't add similar comments elsewhere.
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).