From d293df1a8c62d8ad72714fc9879c8a9122f27b5f Mon Sep 17 00:00:00 2001 From: Maksim Panchenko 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; } }