683 Commits

Author SHA1 Message Date
xushiwei
b25ae1b4e7 Merge pull request #1384 from luoliwoshang/feature/export-different-names-1378
cl: support //export with different symbol names on embedded targets
2025-11-17 08:10:09 +08:00
xgopilot
034b05c53c cl: remove Underlying() call to reject string type aliases in rewrites
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>
2025-11-14 14:49:30 +00:00
xgopilot
1ba7d1e561 fix: change to isStringPtrType for global string var
- 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>
2025-11-14 14:38:46 +00:00
xgopilot
d17ff2592a build: improve error handling and code quality
- Fix missing error handling in exportObject function
- Add explicit warning for non-string variable rewrites
- Improve documentation for maxRewriteValueLength constant

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: cpunion <8459+cpunion@users.noreply.github.com>
2025-11-14 11:37:09 +00:00
Li Jie
4b26cccc90 cl: cover rewrite guards 2025-11-14 18:29:00 +08:00
Li Jie
3a1d8693e9 rewrite: address review feedback 2025-11-14 17:57:05 +08:00
Li Jie
2a52d422c5 cl: broaden rewrite coverage 2025-11-14 17:48:16 +08:00
Li Jie
b0f5d34b39 cl: add rewrite coverage test 2025-11-14 17:32:52 +08:00
Li Jie
22a43622a0 cl: fix global var rewrite in alt pkg 2025-11-14 16:58:30 +08:00
Li Jie
9b76be9e9e support ldflags rewrites for initialized globals 2025-11-14 11:59:13 +08:00
Li Jie
21fef123d2 di: clean unreachable code 2025-11-13 15:48:50 +08:00
Li Jie
cb173f91d0 ssa: rely on runtime thread defer TLS 2025-11-13 15:48:49 +08:00
Li Jie
16709411a0 defer: enable loop lowering 2025-11-13 15:48:46 +08:00
xushiwei
0dbe528e6d Merge pull request #1304 from MeteorsLiu/impl-stacksave
feat: implement `llgo.stackSave`
2025-11-13 07:48:01 +08:00
luoliwoshang
e11ae0e21b test: add comprehensive tests and CI for export feature
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>
2025-11-10 18:52:58 +08:00
luoliwoshang
dac3365c73 cl,build: support //export with different names on embedded targets
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>
2025-11-10 18:52:36 +08:00
luoliwoshang
4e374a99ff test:refression test for https://github.com/goplus/llgo/issues/1370
Co-authored-by: xgopilot <noreply@goplus.org>
Co-authored-by: Claude <noreply@anthropic.com>
2025-11-06 21:02:36 +08:00
Haolan
2ec5653f5e feat: implement llgo.stackSave 2025-09-28 09:20:50 +08:00
visualfc
5592a8fc26 ssa: fix abiTupleOf 2025-09-25 20:16:44 +08:00
visualfc
7323187f90 ssa: impl builtin alignof offsetof 2025-09-18 21:16:06 +08:00
Li Jie
3605eeeef7 export c header file for build library 2025-09-11 14:07:58 +08:00
Li Jie
729e5772a0 process //export with initLink 2025-09-11 08:53:17 +08:00
visualfc
5dbf1a7561 cl/_testrt/vamethod: optimize code 2025-09-09 17:25:22 +08:00
visualfc
fd17a43ade cl: interface support __llgo_va_list 2025-09-09 16:51:08 +08:00
visualfc
89af430329 cl: embed struct support __llgo_va_list 2025-09-09 16:14:25 +08:00
luoliwoshang
f3de14da4b cl/instr:note for why asm not support pointer type: 2025-08-22 16:14:57 +08:00
luoliwoshang
49b9b92790 ci/instr:fix asmFull return type to match function signature when no output 2025-08-22 15:01:59 +08:00
luoliwoshang
d9dc4d5943 cl/instr:move to one asm 2025-08-21 23:44:46 +08:00
luoliwoshang
04f613dd15 cl/test:asmFull error 2025-08-21 23:44:46 +08:00
luoliwoshang
0faef117ca cl/instr:refine register collect 2025-08-21 23:44:46 +08:00
luoliwoshang
f6bc5ac538 cl/instr:regexp compile one time 2025-08-21 23:44:46 +08:00
luoliwoshang
26fb156d6b cl/instr:only permit interger at asmfull 2025-08-21 23:44:46 +08:00
luoliwoshang
9dfc6d1d52 ssa:refine asmFull interface 2025-08-21 23:44:46 +08:00
luoliwoshang
6beb50b367 cl/instr:asmFull test case with multiple input & output 2025-08-21 23:44:46 +08:00
luoliwoshang
9e0c50dafe cl/instr:asmFull test case with input only 2025-08-21 23:44:46 +08:00
luoliwoshang
f5d4f93ed7 ssa:inlineAsmFull 2025-08-21 23:44:46 +08:00
luoliwoshang
ae36ef4a0e cl/instr:replace register & build constraints 2025-08-21 23:44:46 +08:00
luoliwoshang
485dbe4021 cl/instr:asm with two situation 2025-08-21 23:44:46 +08:00
xushiwei
cbac24cf97 Merge pull request #1188 from visualfc/cabi
cabi transform
2025-08-19 14:56:10 +08:00
luoliwoshang
afee2beebe cl/instr:rm llgoAsmBase 2025-08-17 18:41:38 +08:00
luoliwoshang
a148964878 feat:llgo.Asm
test:asm test with `nop`
2025-08-17 16:50:16 +08:00
visualfc
7b36cca86b _demo/cabi: abi test demo 2025-08-12 09:46:03 +08:00
xushiwei
6940a5846b Merge pull request #1210 from visualfc/ssa_typeassert
ssa: fix TypeAssert check null
2025-08-08 19:48:27 +08:00
visualfc
56f90dbcf9 ssa: fix TypeAssert check null 2025-08-08 12:11:17 +08:00
visualfc
54dfd3c701 ssa: PyVal support pointer to long 2025-08-07 20:39:35 +08:00
visualfc
36fa18b28c ssa: PyVal support py bytes 2025-07-30 12:12:19 +08:00
visualfc
2538be9318 ssa: PyVal support pyfunc 2025-07-29 20:55:56 +08:00
visualfc
0a6588c348 ssa: PyVal support bool,int,uint,string,bytearray,complex 2025-07-29 16:08:09 +08:00
visualfc
d7f2f4efdd cl: patchType check func signature 2025-07-03 20:48:51 +08:00
luoliwoshang
6e8f3d1d19 test(build):collect llgo test ./... output to test 2025-06-25 15:38:20 +08:00