Commit Graph

495 Commits

Author SHA1 Message Date
xgopilot
05da9ec252 fix: preserve Named interface type information through interface construction
This commit addresses the root cause identified in issue #1370 by preserving
Named interface type information through the interface construction phase.

**Root Cause:**
Named interfaces were prematurely unwrapped via Underlying() in the interface
construction phase (MakeInterface()/unsafeInterface()), causing the subsequent
ABI type generation to hit `case *types.Interface:` instead of
`case *types.Named:`, resulting in loss of package information.

**The Fix:**
1. Modified `unsafeInterface()` to accept a `namedIntf types.Type` parameter
2. Updated all callers to pass the Named type (tinter.raw.Type, assertedTyp.raw.Type, etc.)
3. When namedIntf is available, pass it to `abiType()` to ensure proper routing
   through the type switch to `abiNamedInterfaceOf()` which has correct package context
4. Reverted the workaround logic in `abiInterfaceOf()` that extracted pkgPath from methods

**Impact:**
- Fixes segmentation faults when calling interface private methods across packages
- Ensures runtime receives correct package path for interface metadata
- Allows private method slots in itab to be properly filled

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 10:32:20 +00:00
xgopilot
b62dafbc3a fix(ssa): use abi.PathOf() for correct package path in interface metadata
Fixes os.ReadDir segfault caused by package path mismatch between llgo
overlay packages and canonical standard library paths.

The issue occurred in: os.ReadDir → sort.Slice → reflectlite.Swapper
where internal/reflectlite.Type interface has private methods common()
and uncommon(). Using mPkg.Path() returned the overlay path
'github.com/goplus/llgo/runtime/internal/lib/internal/reflectlite'
instead of the canonical 'internal/reflectlite', causing runtime to
only fill public methods and leave private method pointers NULL.

Changed to use abi.PathOf() which returns the correct canonical package
path for matching, ensuring all interface methods (both public and
private) are properly filled in the interface table.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 11:32:38 +00:00
xgopilot
18de107520 Revert "fix(ssa): extract PkgPath from any method, not just private methods"
This reverts commit dee7b873f56a6dd86a9b74cdf8f3ebe49c5ccb98.

The fix didn't resolve the readdir segfault. Need to investigate
more thoroughly by examining LLVM IR output.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-27 09:27:43 +00:00
xgopilot
dee7b873a6 fix(ssa): extract PkgPath from any method, not just private methods
The previous fix only extracted package path from private methods,
causing segfaults for interfaces with only exported methods (like fs.DirEntry).

Root cause:
- For interfaces with only exported methods, the loop never entered
  the !token.IsExported(mName) block
- pkgPath remained empty and fell back to pkg.Path() (compilation package)
- This caused wrong PkgPath for standard library interfaces like fs.DirEntry
- Runtime received wrong package path, leading to segfaults

Fix:
- Extract pkgPath from the FIRST method (any method), not just private ones
- All methods have correct package information via m.Pkg()
- Only fall back to pkg.Path() if the interface has no methods or m.Pkg() is nil

This fixes the readdir demo segfault while maintaining the fix for issue #1370.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-27 09:07:35 +00:00
xgopilot
dba9bcc4e4 fix(ssa): use correct package path for interface metadata in abiInterfaceOf
When converting concrete type pointers to interfaces with private methods
across packages, the interface metadata's PkgPath was incorrectly set to
the current compilation package instead of the interface definition package.

This caused the runtime to only fill exported methods in the itab, leaving
private method slots as NULL (0x0), which led to segmentation faults when
calling these private methods.

The fix extracts the package path from the interface's private methods
(if any) instead of using the current package path. This ensures the
runtime receives the correct package path for the visibility check.

Fixes #1370

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-23 10:30:00 +00:00
Li Jie
00dd09c7f4 ssa: improve hasTypeParam coverage 2025-10-15 13:51:16 +08:00
Li Jie
1ed418e77e tls: document package and guard helpers 2025-10-15 13:11:35 +08:00
Li Jie
2110db7263 tls: add gc-aware pthread slots 2025-10-15 12:21:51 +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
cc65ee18b5 full test params passing of exported functions 2025-09-12 10:08:01 +08:00
Li Jie
3605eeeef7 export c header file for build library 2025-09-11 14:07:58 +08:00
visualfc
fd17a43ade cl: interface support __llgo_va_list 2025-09-09 16:51:08 +08:00
luoliwoshang
9dfc6d1d52 ssa:refine asmFull interface 2025-08-21 23:44:46 +08:00
luoliwoshang
f5d4f93ed7 ssa:inlineAsmFull 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
a148964878 feat:llgo.Asm
test:asm test with `nop`
2025-08-17 16:50:16 +08:00
visualfc
2a88d5777a ssa: export target and module 2025-08-12 09:29:43 +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
4726e824a0 build: link globals importpath.name=value 2025-06-17 11:11:06 +08:00
runsys
c1550cf608 windows mingw64 llvm 20 support patch 1 2025-05-18 17:03:47 +08:00
visualfc
e8a91696d6 go.mod go1.23 2025-05-05 10:19:23 +08:00
Li Jie
8512395985 AllocCStr allocates on heap 2025-04-11 16:28:48 +08:00
Li Jie
d4bf66936a specify setjmp/longjmp function names on wasm 2025-04-11 16:28:47 +08:00
Li Jie
e6c7627ee8 cross compilation 2025-04-08 10:46:14 +08:00
Li Jie
ed366568b4 move out c/cpp/py 2025-04-03 16:26:11 +08:00
Li Jie
1172e5bdce build: separate compiler and libs 2025-01-08 14:59:01 +08:00
Li Jie
239ac496b2 test: map/slice clear 2025-01-08 14:59:00 +08:00
Li Jie
03b469212e feat: upgrade to x/tools 0.28 2025-01-08 14:58:59 +08:00
visualfc
3741a28d94 ssa: fix bitcast for float32 2024-12-24 10:02:30 +08:00
visualfc
a6a3c09c05 ssa: closure use specific struct field name { $f ftype, $data unsafe.pointer } 2024-12-22 12:44:33 +08:00
visualfc
ef28abe896 internal/runtime: funcStr, interfaceStr, array str 2024-12-20 12:33:34 +08:00
visualfc
d251232f8a internal/runtime: named(ptr) type preset for method type 2024-12-20 11:37:30 +08:00
xushiwei
539b55f826 Merge pull request #917 from visualfc/conststring
ssa: fix const for named string
2024-12-19 18:13:24 +08:00
xushiwei
b4af70ada9 Merge pull request #916 from visualfc/runtime.interface
abi: fix named interface init
2024-12-17 14:43:15 +08:00
visualfc
eaf7e56083 ssa: fix const for named string 2024-12-16 15:00:32 +08:00
visualfc
e55a5d7486 internal/runtime: NewNamedInterface, InitNamedInterface 2024-12-16 12:07:13 +08:00
xushiwei
29ad96862f Merge pull request #628 from visualfc/go
ssa: fix ssa.go for builtin
2024-12-14 06:44:35 +08:00
七叶
3505be422e Revert "ssa: defer load/store func and args" 2024-12-03 21:00:49 +08:00
visualfc
7eeb8084bf ssa: fix ssa.go for builtin 2024-12-02 15:40:56 +08:00
visualfc
6e8cecd13e cl/_testgo: defer6 2024-12-02 11:43:20 +08:00
visualfc
11f2ecd675 ssa: defer load/store func and args 2024-11-30 14:31:23 +08:00
Li Jie
90763de93c cgo: supports c/go callback funcs 2024-11-27 18:41:56 +08:00
Li Jie
d879d0d924 build: make llgen, cltest, gentests call build.Do 2024-11-26 13:17:36 +08:00
visualfc
8fb0dfad94 ssa: abiNamed use NameOf 2024-11-26 12:46:11 +08:00