Skip to content

plan9asm: support generated Go asm data and RET targets - #22

Merged
xushiwei merged 14 commits into
xgo-dev:mainfrom
cpunion:codex/asmhdr-constants-20260821
Aug 21, 2026
Merged

plan9asm: support generated Go asm data and RET targets#22
xushiwei merged 14 commits into
xgo-dev:mainfrom
cpunion:codex/asmhdr-constants-20260821

Conversation

@cpunion

@cpunion cpunion commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • expand signed, full-width unsigned, and string Go constants without panicking on non-integer values
  • resolve the struct size and field-offset macros emitted by go tool compile -asmhdr from target-aware go/types data
  • preserve Plan 9 DATA string payload bytes and cmd/asm-compatible zero padding
  • accept and lower assembly files containing only DATA/GLOBL, so their initialized globals are not silently dropped
  • parse string payloads containing commas and reject payloads wider than the DATA directive
  • lower RET symbol(SB) as a tail call on ARM, ARM64, and AMD64 while preserving register-form returns such as Go 1.25 ARM64 RET (R27)
  • exercise the standard-library assembly corpus and host tooling on Linux, macOS, and Windows for Go 1.21 through Go 1.26.x

This was exposed by Go 1.26 GOROOT tests while validating LLGo Windows support: test/asmhdr.go uses generated constants, struct layout macros, and a data-only assembly file; test/retjmp.go uses a symbol-targeted RET. The initial RET implementation also exposed an older Go 1.25 ARM64 register-return form, now covered by a regression test.

Validation

  • go test ./...
  • go test -coverprofile=/tmp/plan9asm-cover.out ./...
  • focused ARM, ARM64, and AMD64 RET target, register return, and invalid operand-count tests
  • data-only parse and LLVM-module lowering tests
  • end-to-end regression covering the official asmhdr small integer, max uint64, short/long string, struct size, and field-offset forms
  • CI standard-library corpus on Ubuntu, macOS, and Windows for Go 1.21 through Go 1.26.x, including Windows amd64/arm64 COFF generation
  • CI host tests on Windows/x64 for Go 1.21 through Go 1.26.x; the Go 1.26 lane uploads Windows coverage to Codecov
  • LLGo Go 1.26.x GOROOT asmhdr.go and retjmp.go execution on Windows/ARM64; the same focused set also passes on macOS

The LLGo integration branch temporarily pins this fork commit for native Windows ARM64 GOROOT validation; it can return to an upstream version after this change is merged and released.

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.56522% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
translate.go 89.18% 2 Missing and 2 partials ⚠️
amd64_ctx.go 90.90% 1 Missing and 1 partial ⚠️
go_translate.go 95.23% 1 Missing and 1 partial ⚠️
translate_module_direct.go 81.81% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@cpunion cpunion changed the title plan9asm: preserve generated Go DATA constants plan9asm: support generated Go DATA constants and RET targets Aug 21, 2026
@cpunion cpunion changed the title plan9asm: support generated Go DATA constants and RET targets plan9asm: support generated Go asm data and RET targets Aug 21, 2026
@cpunion
cpunion marked this pull request as ready for review August 21, 2026 14:07

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FennoAI Review

Solid, well-tested PR. RET sym(SB) tail-call lowering is added uniformly across amd64/arm64/arm with matching multi-operand rejection, dataStmtPayload cleanly unifies string/integer payloads and is shared by both lowering paths, and the go_asm.h macro expansion correctly reuses the authoritative go/types sizing. Good test coverage in retjmp_test.go and parser_data_globl_test.go.

A few non-blocking findings below (2 inline). Additional minor notes that lack a reliable diff-line anchor:

  • [P3] Unbounded GLOBL size in the text-emit path (translate.go, emitDataGlobals): GLOBL x(SB),0,$<huge> flows into make([]byte, sd.size) with no cap on this path, while translate_module_direct.go:597 caps at 1<<31. Same class as the inline DATA-width note. Consider applying a shared cap.
  • [P3] RET sym(SB) missing-signature handling differs by arch: amd64/arm64 fall back to the caller signature (csig = c.sig), but arm returns a hard error (arm tailcall missing signature). The same input can translate on two arches and fail on the third. Worth aligning or documenting.
  • [P3] Stale comment at parser.go:168 (accept "RET x" as generic for now): RET sym(SB) is now specifically modeled as a tail call, so the "generic for now" wording is outdated.
  • [P3] Codecov label at .github/workflows/go-ci.yml:294 still reads name: ubuntu-go1.25 after the job's Go version was bumped to 1.26.7. Cosmetic label mismatch.
  • [P3] Pinned patch vs .x: single-version jobs pin exact 1.26.7 while matrices mix 1.26.7 with 1.2x.x ranges — slightly inconsistent.

Comment thread translate.go
Comment thread go_translate.go Outdated
@cpunion

cpunion commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the remaining review notes in 51c97bd and 541c2ab: ARM now uses the same missing-tail-signature fallback as AMD64/ARM64, the RET parser comment is current, all latest-version jobs consistently select Go 1.26.x, and the Codecov upload name is ubuntu-go1.26. Local validation passed full tests, race, and the Linux/Darwin amd64/arm64 stdlib corpus; measured changed-statement coverage is 97.30% (180/185).

@xushiwei
xushiwei merged commit 7239b77 into xgo-dev:main Aug 21, 2026
41 checks passed
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