Skip to content

runtime: match legacy print float exponents#1887

Draft
cpunion wants to merge 3 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-print-coverage
Draft

runtime: match legacy print float exponents#1887
cpunion wants to merge 3 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-print-coverage

Conversation

@cpunion
Copy link
Copy Markdown
Collaborator

@cpunion cpunion commented May 22, 2026

Summary

  • Match Go legacy builtin print/println float exponent formatting by padding %e exponents to three digits for the !go1.26 runtime path.
  • Add focused test/go coverage that compares baseline Go output with llgo output for builtin print/println, nil interfaces/maps/slices, integers, floats, complex values, bools, strings, spacing, deferred print calls, constant complex printing, and the generic type-switch float print shape from typeparam/typeswitch5.go.
  • Remove the now-fixed print.go, deferprint.go, ken/cplx0.go, and typeparam/typeswitch5.go GOROOT xfail entries for go1.24/go1.25 on darwin/arm64 and linux/amd64.

goprint.go is intentionally not removed from xfail here. With the exponent format fixed, go1.25 still mismatches because go println(...) output can be truncated before the goroutine finishes; that is a goroutine/NumGoroutine scheduling issue, not a print/float formatting issue.

GOROOT CI is slow/disabled, so this PR keeps durable coverage in test/go. Normal PR CI should run from the fork branch.

Targeted Tests

  • go test ./test/goroot -count=1 -run TestGoRootRunCases -args -goroot /Users/lijie/sdk/go1.24.11 -go /Users/lijie/sdk/go1.24.11/bin/go -dirs .,ken,typeparam -case '^(print|deferprint)\\.go$|^typeparam/typeswitch5\\.go$|^ken/cplx0\\.go$' -run-timeout 2m
  • go test ./test/goroot -count=1 -run TestGoRootRunCases -args -goroot /Users/lijie/sdk/go1.25.0 -go /Users/lijie/sdk/go1.25.0/bin/go -dirs .,ken,typeparam -case '^(print|deferprint)\\.go$|^typeparam/typeswitch5\\.go$|^ken/cplx0\\.go$' -run-timeout 2m
  • go test ./test/goroot -count=1 -run TestGoRootRunCases -args -goroot /Users/lijie/sdk/go1.26.0 -go /Users/lijie/sdk/go1.26.0/bin/go -dirs .,ken,typeparam -case '^(print|deferprint)\\.go$|^typeparam/typeswitch5\\.go$|^ken/cplx0\\.go$' -run-timeout 2m
  • go test ./test/goroot -count=1 -run TestGoRootRunCases -args -goroot /Users/lijie/sdk/go1.25.0 -go /Users/lijie/sdk/go1.25.0/bin/go -dirs . -case '^goprint\\.go$' -xfail /tmp/llgo-empty-xfail.yaml -run-timeout 2m (expected mismatch; classified out of scope)
  • go test ./test/go -count=1
  • go test ./ssa ./cl ./runtime/internal/runtime -count=1 (./ssa and ./cl passed; ./runtime/internal/runtime is not in the main module)
  • (cd runtime && go test ./internal/runtime ./abi ./internal/test -count=1)
  • (cd runtime && go test ./internal/clite ./internal/clite/bitcast -count=1)
  • git diff --check

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 22, 2026

Root cause: the runtime change intentionally normalizes legacy builtin print/println float and complex output to Go's three-digit exponent form for pre-Go 1.26, but several fixed LLGo expectations still used the previous C %e two-digit exponent form. That broke cl fixture comparisons and the ESP32-C3 float-1664 startup regression check.

Fix: updated the affected fixed expectations (cl/_testgo, cl/_testrt, cl/_testdata, and _demo/embed/test_esp32c3_startup.sh) to the new legacy print format. I also expanded test/go/print_builtin_test.go to cover non-zero positive and negative exponents so this behavior is covered outside the slow goroot suite.

Local tests:

  • go test ./cl -run 'TestRunAndTestFrom(Testgo|Testrt|Testdata)/(alias|invoke|multiret|struczero|complex|cpkgimp)$' -count=1 -v ✅\n- go test ./test/go -count=1 -v ✅\n- go test ./test -run TestBuiltinPrintLegacyFloatFormat -count=1 -v ✅\n\nPushed commit: 25ff4833525cc536709436d1db85d303a30698cc to cpunion/llgo:codex/goroot-print-coverage. New PR CI is running for this head; I will keep watching and iterate if anything fails.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants