Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLGo can't compile hello world in an independent environment #892

Closed
cpunion opened this issue Nov 28, 2024 · 0 comments · Fixed by #933
Closed

LLGo can't compile hello world in an independent environment #892

cpunion opened this issue Nov 28, 2024 · 0 comments · Fixed by #933
Labels
bug Something isn't working

Comments

@cpunion
Copy link
Contributor

cpunion commented Nov 28, 2024

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello, main!")
}

Compiling crashes

llgo run ./cmd/foo
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x50 pc=0x102d463d4]

goroutine 1 [running]:
github.com/goplus/llgo/ssa.(*aProgram).rtNamed(0x14000022600, {0x102dda0f2, 0x5})
	/Users/lijie/source/goplus/llgo/ssa/package.go:282 +0xc4
github.com/goplus/llgo/ssa.(*aProgram).rtType(0x0?, {0x102dda0f2?, 0x14007b59018?})
	/Users/lijie/source/goplus/llgo/ssa/package.go:288 +0x24
github.com/goplus/llgo/ssa.(*aProgram).rtIface(0x14000022600)
	/Users/lijie/source/goplus/llgo/ssa/package.go:300 +0x34
github.com/goplus/llgo/ssa.(*aProgram).toType(0x14000022600, {0x102f02290?, 0x1400009caf0})
	/Users/lijie/source/goplus/llgo/ssa/type.go:372 +0x8f8
github.com/goplus/llgo/ssa.(*aProgram).rawType(0x14000022600, {0x102f02290, 0x1400009caf0})
	/Users/lijie/source/goplus/llgo/ssa/type.go:251 +0x6c
github.com/goplus/llgo/ssa.(*aProgram).toNamed(0x14007b59158?, 0x140000e07e0)
	/Users/lijie/source/goplus/llgo/ssa/type.go:510 +0x184
github.com/goplus/llgo/ssa.(*aProgram).toType(0x14000022600, {0x102f022e0?, 0x140000e07e0})
	/Users/lijie/source/goplus/llgo/ssa/type.go:381 +0xacc
github.com/goplus/llgo/ssa.(*aProgram).rawType(0x14000022600, {0x102f022e0, 0x140000e07e0})
	/Users/lijie/source/goplus/llgo/ssa/type.go:251 +0x6c
github.com/goplus/llgo/ssa.(*aProgram).toLLVMTypes(0x14000022600, 0x14002930300, 0x2)
	/Users/lijie/source/goplus/llgo/ssa/type.go:446 +0x84
github.com/goplus/llgo/ssa.(*aProgram).toLLVMFunc(0x14000022600, 0x140018e8c40)
	/Users/lijie/source/goplus/llgo/ssa/type.go:459 +0xdc
github.com/goplus/llgo/ssa.(*aProgram).FuncDecl(0x14000022600, 0x102d60780?, 0x1400ceb0d20?)
	/Users/lijie/source/goplus/llgo/ssa/type_cvt.go:66 +0x94
github.com/goplus/llgo/ssa.(*aPackage).NewFuncEx(0x1400ea153f0, {0x1400ceb0d20, 0x9}, 0x9?, 0x14007b593b8?, 0x0, 0x0)
	/Users/lijie/source/goplus/llgo/ssa/decl.go:202 +0x78
github.com/goplus/llgo/cl.(*context).compileFuncDecl(0x1400c85ba00, 0x1400ea153f0, 0x1400b6104e0)
	/Users/lijie/source/goplus/llgo/cl/compile.go:244 +0x750
github.com/goplus/llgo/cl.processPkg(0x1400c85ba00, 0x14000279406?, 0x1400b5f8b80)
	/Users/lijie/source/goplus/llgo/cl/compile.go:1073 +0x2c0
github.com/goplus/llgo/cl.NewPackageEx(0x14000022600, 0x1400748de30, 0x1400b5f8b80, {0x140038b9290, 0x3, 0x3})
	/Users/lijie/source/goplus/llgo/cl/compile.go:1026 +0x698
github.com/goplus/llgo/internal/build.buildPkg(0x14006084c00, 0x140065c7140, 0x0)
	/Users/lijie/source/goplus/llgo/internal/build/build.go:522 +0x2d4
github.com/goplus/llgo/internal/build.buildAllPkgs(0x14006084c00, {0x14007e44df8?, 0x140026082c0?, 0x102dd9a24?}, 0x11?)
	/Users/lijie/source/goplus/llgo/internal/build/build.go:349 +0x438
github.com/goplus/llgo/internal/build.Do({0x140000201d0?, 0x1?, 0x1?}, 0x1400009a600)
	/Users/lijie/source/goplus/llgo/internal/build/build.go:204 +0xa60
github.com/goplus/llgo/cmd/internal/run.runCmdEx(0x102dec760?, {0x140000201d0, 0x1, 0x1}, 0x2)
	/Users/lijie/source/goplus/llgo/cmd/internal/run/run.go:68 +0x12c
github.com/goplus/llgo/cmd/internal/run.runCmd(0x1400009a180?, {0x140000201d0?, 0x140000646e8?, 0x102b0d844?})
	/Users/lijie/source/goplus/llgo/cmd/internal/run/run.go:52 +0x24
main.main()
	/Users/lijie/source/goplus/llgo/cmd/llgo/llgo.go:90 +0x4c8

Must add:

import _ "github.com/goplus/llgo/c"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants