Skip to content

Conversation

maksfb
Copy link
Contributor

@maksfb maksfb commented Oct 9, 2025

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.

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.
@llvmbot
Copy link
Member

llvmbot commented Oct 9, 2025

@llvm/pr-subscribers-bolt

Author: Maksim Panchenko (maksfb)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/162731.diff

1 Files Affected:

  • (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+6-4)
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;
     }
   }

@maksfb maksfb merged commit 6fe878a into llvm:main Oct 9, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants