Skip to content

feat(metadata): add PackageMeta Builder for summary extraction during compilation#1860

Draft
luoliwoshang wants to merge 1 commit into
xgo-dev:mainfrom
luoliwoshang:feature/pkg-summary-extraction-v1
Draft

feat(metadata): add PackageMeta Builder for summary extraction during compilation#1860
luoliwoshang wants to merge 1 commit into
xgo-dev:mainfrom
luoliwoshang:feature/pkg-summary-extraction-v1

Conversation

@luoliwoshang
Copy link
Copy Markdown
Contributor

Summary

First PR for Whole-Program Method Reachability Analysis and Package Summary Cache (#1853). Implements Package Summary extraction — collecting metadata facts during compilation and storing them in PackageMeta.

What's Included

Core Infrastructure

SSA-Layer Metadata Collection

  • ssa/abitype.gocollectTypeChildren() for parent→child ABI type relationships; mthName() for method name normalization; MethodInfo collection in abiUncommonMethods()
  • ssa/interface.go — Interface metadata: emitIfaceMethodUse, emitInterfaceInfo, emitUseIface during Imethod/MakeInterface
  • ssa/metadata.go — Bridge functions EmitUseNamedMethod/EmitReflectMethod for future cl-layer use
  • ssa/package.goSetMetaBuilder/MetaBuilder/BuildMeta/Meta accessors

CL-Layer Wiring

  • cl/compile.go — Creates Builder, calls BuildMeta() after deferred init functions
  • internal/build/build.goModuleHook callback field on Config

Testing

  • cl/_testmeta/ — 3 golden-file test cases (iface, methods, nested)
  • cl/cltest/meta.goTestMetaFromDir helper + CaptureMeta for regeneration
  • cl/compile_test.goTestMeta entry point
  • chore/gentests/gentests.gogenMetaDir for golden file regeneration

What's Excluded (Separate PRs)

  • OrdinaryEdges — top-level symbol reachability
  • Recursive TypeChildren — full dependency chain
  • cl/instr.go reflection interception
  • Cache serialization/deserialization and reuse

Test Plan

  • LLGO_ROOT=. go test ./cl/ -run TestMeta -v — all 3 cases PASS
  • go build ./... compiles cleanly
  • Golden files use [SectionName]\nkey:\n value format

🤖 Generated with Claude Code

@luoliwoshang luoliwoshang force-pushed the feature/pkg-summary-extraction-v1 branch from 6b6744e to 46d870b Compare May 12, 2026 11:06
… compilation

Add metadata.Builder to accumulate facts (TypeChildren, InterfaceInfo,
UseIface, UseIfaceMethod, MethodInfo) during cl/ssa compilation. Wire
via aPackage.SetMetaBuilder/BuildMeta, called after deferred inits.

Includes golden-file tests under cl/_testmeta/ and gentests support.
Excludes OrdinaryEdges (separate PR).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@luoliwoshang luoliwoshang force-pushed the feature/pkg-summary-extraction-v1 branch from 46d870b to 126f9ec Compare May 12, 2026 11:16
@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

❌ Patch coverage is 20.41199% with 425 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/metadata/decode.go 0.00% 216 Missing ⚠️
internal/metadata/format.go 0.00% 81 Missing ⚠️
internal/metadata/encode.go 0.00% 77 Missing ⚠️
internal/metadata/builder.go 0.00% 32 Missing ⚠️
internal/metadata/meta.go 0.00% 12 Missing ⚠️
ssa/metadata.go 0.00% 6 Missing ⚠️
ssa/package.go 85.71% 1 Missing ⚠️

📢 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