[llvm] [BOLT] Modify warning when --use-old-text fails. NFC (PR #162731)
Maksim Panchenko via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 9 13:38:08 PDT 2025
https://github.com/maksfb created https://github.com/llvm/llvm-project/pull/162731
When --use-old-text fails, we are emitting all code meant for the original `.text` section into the new section. This could be more bytes compared to those emitted under no `--use-old-text`, especially under `--lite`. As a result, `--use-old-text` results in a larger binary, not smaller which could be confusing to the user.
Add more information to the warning, including recommendation to rebuild without `--use-old-text` for smaller binary size.
>From d293df1a8c62d8ad72714fc9879c8a9122f27b5f Mon Sep 17 00:00:00 2001
From: Maksim Panchenko <maks at fb.com>
Date: Thu, 9 Oct 2025 13:27:38 -0700
Subject: [PATCH] [BOLT] Modify warning when --use-old-text fails. NFC
When --use-old-text fails, we are emitting all code meant for the
original `.text` section into the new section. This could be more bytes
compared to those emitted under no `--use-old-text`, especially under
`--lite`. As a result, `--use-old-text` results in a larger binary, not
smaller which could be confusing to the user.
Add more information to the warning, including recommendation to rebuild
without `--use-old-text` for smaller binary size.
---
bolt/lib/Rewrite/RewriteInstance.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index c428828956ca0..dad67175ad410 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -4005,10 +4005,12 @@ void RewriteInstance::mapCodeSections(BOLTLinker::SectionMapper MapSection) {
BC->outs() << '\n';
AllocationDone = true;
} else {
- BC->errs() << "BOLT-WARNING: original .text too small to fit the new code"
- << " using 0x" << Twine::utohexstr(opts::AlignText)
- << " alignment. " << CodeSize << " bytes needed, have "
- << BC->OldTextSectionSize << " bytes available.\n";
+ BC->errs() << "BOLT-WARNING: --use-old-text failed. The original .text "
+ "too small to fit the new code using 0x"
+ << Twine::utohexstr(opts::AlignText) << " alignment. "
+ << CodeSize << " bytes needed, have " << BC->OldTextSectionSize
+ << " bytes available. Rebuilding without --use-old-text may "
+ "produce a smaller binary\n";
opts::UseOldText = false;
}
}
More information about the llvm-commits
mailing list