From 2df9dfc9096de4b337ba55cb978c17f10fd8c441 Mon Sep 17 00:00:00 2001 From: Yaya48 <34249303+Yaya48@users.noreply.github.com> Date: Wed, 4 Nov 2026 21:03:10 +0100 Subject: [PATCH] StarletBootstrapProbe: read --cycles where it stands, as before --broadway-h1a had moved --cycles' reading after the options, which changed the usage errors' text for a missing value or a second --cycles. The bound is now known before the options are read (whether --broadway-h1a is among them), and --cycles is read in place, with master's messages: without --broadway-h1a, every run and every refusal is master's, byte for byte. Co-Authored-By: Claude Opus 5.5 --- .../StarletBootstrapProbe.cpp | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Tools/StarletBootstrapProbe/StarletBootstrapProbe.cpp b/Tools/StarletBootstrapProbe/StarletBootstrapProbe.cpp index 8e3494e894..317ab046f5 100644 --- a/Tools/StarletBootstrapProbe/StarletBootstrapProbe.cpp +++ b/Tools/StarletBootstrapProbe/StarletBootstrapProbe.cpp @@ -423,8 +423,15 @@ int main(int argc, char** argv) SBR1Mode sbr1 = SBR1Mode::None; ExpectedOutcome expected = ExpectedOutcome::Idle; bool outcome_selected = false; - std::optional cycles_text; + std::optional cycles; bool broadway_h1a = false; + // --cycles' bound: MAX_CYCLES, or MAX_CLIENT_CYCLES when --broadway-h1a is among the options + // (ProbeBudget.h), known before they are read so that --cycles is read where it stands. + const auto is_client = [](const char* argument) { + return std::string_view(argument) == "--broadway-h1a"; + }; + const u64 max_cycles = + std::any_of(argv + 2, argv + argc, is_client) ? MAX_CLIENT_CYCLES : MAX_CYCLES; std::optional package_path; std::optional script_path; for (int index = 2; index < argc; ++index) @@ -462,13 +469,14 @@ int main(int argc, char** argv) } else if (option == "--cycles") { - // Given once; read below, once the mode, which bounds it, is known. - if (cycles_text || index + 1 == argc) + // A whole number of slices, at most max_cycles (ProbeBudget.h); given once. + if (cycles || index + 1 == argc || !(cycles = ParseCycles(argv[index + 1], max_cycles))) { - std::cerr << "--cycles takes one decimal multiple of " << SLICE_CYCLES << ", once\n"; + std::cerr << "--cycles takes one decimal multiple of " << SLICE_CYCLES << ", at most " + << max_cycles << ", once\n"; return 2; } - cycles_text = argv[++index]; + ++index; } else if (option == "--jit") jit = true; @@ -516,16 +524,6 @@ int main(int argc, char** argv) std::cerr << "--broadway-h1a takes --sbr1-record: the loader's monitor reads the record\n"; return 2; } - // A whole number of slices, at most MAX_CYCLES, or MAX_CLIENT_CYCLES with the client - // (ProbeBudget.h). - const u64 max_cycles = broadway_h1a ? MAX_CLIENT_CYCLES : MAX_CYCLES; - std::optional cycles; - if (cycles_text && !(cycles = ParseCycles(*cycles_text, max_cycles))) - { - std::cerr << "--cycles takes one decimal multiple of " << SLICE_CYCLES << ", at most " - << max_cycles << ", once\n"; - return 2; - } // The package file read and checked before anything is set up: a refused file ends the run // before StarOS starts.