[WIP] cl: preserve linknames for main test variants - #2365
Conversation
There was a problem hiding this comment.
Review: fix main test linkname
This is a small, focused change that records an extra go:linkname alias under the raw import path for main packages compiled as test variants (go test emits symbols under the import path rather than the canonical main. prefix). The logic is correct, and the main.-prefix rewrite in testMainLinkname is safely anchored (targets like C.foo, example.com/pkg.X, or mainfoo.bar are untouched). No security or performance concerns — the added work is guarded so non-main packages short-circuit before any map access.
The findings below are maintainability and documentation/test-clarity suggestions; none block merge.
|
Addressed the review suggestions in c7c50dd:
Verified with:
|
efe7b81 to
c7a592c
Compare
LLGo baseline benchmarks
Program measurements
Core language and compiler benchmarks
Compared with |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
Preserve preloaded
//go:linknameentries forpackage maintest variants.Behavior
main.*target declared in ordinary package source is rewritten to the package import path when llgo builds the test variant.main.*target declared in a_test.gosource file is intentionally left unchanged. Test variants do not definemain.*symbols, so this remains unsupported.Tests
GOCACHE=/tmp/llgo-bug-gocache go test ./cl -run TestParsePkgSyntaxCollectsLinknames -count=1GOCACHE=/tmp/llgo-bug-gocache go run ./cmd/llgo test -v ./cmd/demo/bugHistory
The branch is a single commit:
c7a592c59 cl: preserve linknames for main test variants.