Type aliases like `type T string` are no longer supported for
-ldflags -X rewrites. Only direct *string types are now allowed.
- Removed Underlying() call from isStringPtrType
- Added TestRewriteIgnoresStringAlias test case
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: cpunion <8459+cpunion@users.noreply.github.com>
- Replace isStringType with isStringPtrType to properly validate that only *string type variables can be rewritten with -ldflags -X
- Remove maxStringTypeDepth constant as it's no longer needed
- Update tests to reflect the new function name and add test case for valid *string type
- Fix compileGlobal to use gbl.Type() for accurate type checking
This addresses the review feedback that Go only allows -X rewrites for the basic string type, not derived types like "type T string".
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: cpunion <8459+cpunion@users.noreply.github.com>
Add extensive test coverage, demo program, and CI integration for
//export with different names feature:
Unit Tests (cl/builtin_test.go):
- TestHandleExportDiffName: core functionality with 4 scenarios
* Different names with enableExportRename
* Same names with enableExportRename
* Different names with spaces in export directive
* Matching names without enableExportRename
- TestInitLinknameByDocExportDiffNames: flag behavior verification
* Export with different names when enabled
* Export with same name when enabled
* Normal linkname directives
- TestInitLinkExportDiffNames: edge case handling
* Symbol not found in decl packages (silent handling)
Demo (_demo/embed/export/):
- Example program demonstrating various export patterns
- Verification script testing both embedded and non-embedded targets
- Documents expected behavior and error cases
CI Integration (.github/workflows/llgo.yml):
- Add export demo to embedded target tests
- Ensure feature works correctly across platforms
- Catch regressions in future changes
The tests verify:
✓ Different names work with -target flag
✓ Same names work in all cases
✓ Different names fail without -target flag
✓ Proper error messages for invalid exports
✓ Silent handling for decl packages
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add support for using different C symbol names in //export directives
when compiling for embedded targets (enabled via -target flag).
This is for TinyGo compatibility on embedded platforms where hardware
interrupt handlers often require specific naming conventions.
Implementation:
- Add EnableExportRename() to control export rename behavior
- Add isExport parameter to initLink callback for context awareness
- Update initLinknameByDoc() to handle export rename logic:
* When isExport && enableExportRename: allow different names
* Otherwise: require name match
- Clean error handling in initLink():
* export + enableExportRename: silent return (already processed)
* export + !enableExportRename: panic with clear error message
* other cases: warning for missing linkname
Example:
//export LPSPI2_IRQHandler
func interruptLPSPI2() { ... }
The Go function is named interruptLPSPI2 but exported as
LPSPI2_IRQHandler for the hardware vector table.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>