Giter Club home page Giter Club logo

llgo's People

Contributors

antongulenko avatar avnik avatar axw avatar casualsuperman avatar minux avatar mortdeus avatar pcc avatar quarnster avatar spate avatar taruti avatar tmc avatar tvi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

llgo's Issues

net/http build fails

$ llgo-build net/http
2013/09/26 16:44:31 building net/http
panic: runtime error: index out of range [recovered]
panic: /Users/quarnster/code/3rdparty/go/src/pkg/net/http/header.go:123:1: runtime error: index out of range [recovered]
panic: /Users/quarnster/code/3rdparty/go/src/pkg/net/http/header.go:123:1: runtime error: index out of range

goroutine 1 [running]:
runtime.panic(0x42a6ea0, 0xc210c3fe40)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/axw/llgo.func·004()
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:274 +0x87
runtime.panic(0x42a6ea0, 0xc210c3fe40)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.func·006()
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:437 +0x2a0
runtime.panic(0x4286ea0, 0x462b257)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.(_compiler).VisitSelectStmt(0xc21004a160, 0xc210113d60)
/Users/quarnster/code/go/src/github.com/axw/llgo/channels.go:133 +0x2f14
github.com/axw/llgo.(_compiler).VisitStmt(0xc21004a160, 0x89168c0, 0xc210113d60)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:928 +0x5a5
github.com/axw/llgo.(_compiler).VisitBlockStmt(0xc21004a160, 0xc210122030, 0x891f400)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:73 +0x2b4
github.com/axw/llgo.(_compiler).buildFunction(0xc21004a160, 0xc210f1b6f0, 0x0, 0xc210c3fde0, 0xc2104b4600, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:184 +0x1132
github.com/axw/llgo.(_compiler).VisitFuncDecl(0xc21004a160, 0xc210122090, 0xc210122090, 0xc210122090)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:230 +0x425
github.com/axw/llgo.(_compiler).VisitDecl(0xc21004a160, 0x8911860, 0xc210122090, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:443 +0x283
github.com/axw/llgo.(*compiler).Compile(0xc21004a160, 0xc21006a240, 0xc210112a80, 0x10, 0x10, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:291 +0x71d
main.compileFiles(0x8911630, 0xc21004a160, 0xc21000a080, 0x10, 0x10, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:116 +0x32e
main.main()
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:272 +0x3b4

goroutine 3 [syscall]:
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396
2013/09/26 16:44:32 exit status 2

errors when issuing go get

When I go get this (after setting CGO_*) I get the following compiler errors:

%go get github.com/axw/llgo

github.com/axw/llgo

workspace/go/src/github.com/axw/llgo/check.go:27: cannot use c.llvmtypes.Offsetsof (type func([]_types.Field) []int64) as type func(_types.Scope) []int64 in field value
workspace/go/src/github.com/axw/llgo/expr.go:480: cannot use t.Field(i).object.Type (type func() types.Type) as type types.Type in assignment:
func() types.Type does not implement types.Type (missing Deref method)
workspace/go/src/github.com/axw/llgo/expr.go:486: field.IsAnonymous undefined (type *types.Field has no field or method IsAnonymous)
workspace/go/src/github.com/axw/llgo/expr.go:489: cannot use t (type func() types.Type) as type types.Type in field value:
func() types.Type does not implement types.Type (missing Deref method)
workspace/go/src/github.com/axw/llgo/expr.go:520: invalid type assertion: field.object.Type.(types.Type) (non-interface type func() types.Type on left)
workspace/go/src/github.com/axw/llgo/functions.go:168: field.IsAnonymous undefined (type *types.Field has no field or method IsAnonymous)
workspace/go/src/github.com/axw/llgo/functions.go:171: cannot use ftype (type func() types.Type) as type types.Type in field value:
func() types.Type does not implement types.Type (missing Deref method)
workspace/go/src/github.com/axw/llgo/functions.go:218: cannot use pkg (type *types.Package) as type token.Pos in function argument
workspace/go/src/github.com/axw/llgo/functions.go:218: cannot use "" (type string) as type *types.Package in function argument
workspace/go/src/github.com/axw/llgo/functions.go:218: cannot use recv (type types.Type) as type string in function argument
workspace/go/src/github.com/axw/llgo/functions.go:218: too many errors

compress/flate asserts

16:35 ~/code/go/src/github.com/axw/llgo/cmd/llgo-dist $ llgo-build compress/flate
2013/09/26 16:36:09 building compress/flate
Assertion failed: (Ty && "Invalid GetElementPtrInst indices for type!"), function checkGEPType, file /Users/quarnster/code/3rdparty/llvm-3.3.src/include/llvm/IR/Instructions.h, line 704.
SIGABRT: abort
PC=0x7fff8605c212
signal arrived during cgo execution

runtime.cgocall(0x4002850, 0x87e8f70)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:149 +0x11b fp=0x87e8f58
github.com/axw/gollvm/llvm._Cfunc_LLVMBuildGEP(0xa100010, 0x8823940, 0xc210894d00, 0xc200000002, 0x881de90, ...)
github.com/axw/gollvm/llvm/_obj/_cgo_defun.c:935 +0x31 fp=0x87e8f70
----- stack segment boundary -----
github.com/axw/gollvm/llvm.Builder.CreateGEP(0xa100010, 0x8823940, 0xc210894d00, 0x2, 0x2, ...)
/Users/quarnster/code/go/src/github.com/axw/gollvm/llvm/core.go:1473 +0x9f fp=0x87db140
github.com/axw/llgo.(_compiler).VisitRangeStmt(0xc21004a160, 0xc2100742d0)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:715 +0x11dd fp=0x87db4a0
github.com/axw/llgo.(_compiler).VisitStmt(0xc21004a160, 0x8910d90, 0xc2100742d0)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:916 +0x727 fp=0x87db5b0
github.com/axw/llgo.(_compiler).VisitBlockStmt(0xc21004a160, 0xc2100aedb0, 0x8916200)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:73 +0x2b4 fp=0x87db618
github.com/axw/llgo.(_compiler).buildFunction(0xc21004a160, 0xc21065dc30, 0x0, 0xc2102e15e0, 0x0, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:184 +0x1132 fp=0x87db958
github.com/axw/llgo.(_compiler).VisitFuncDecl(0xc21004a160, 0xc2100aede0, 0xc2100aede0, 0xc2100aede0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:230 +0x425 fp=0x87dba60
github.com/axw/llgo.(_compiler).VisitDecl(0xc21004a160, 0x89107e0, 0xc2100aede0, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:443 +0x283 fp=0x87dbb98
github.com/axw/llgo.(*compiler).Compile(0xc21004a160, 0xc210046e80, 0xc2100ff6c0, 0x8, 0x8, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:291 +0x71d fp=0x87dbd40
main.compileFiles(0x8910738, 0xc21004a160, 0xc21000a080, 0x8, 0x8, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:116 +0x32e fp=0x87dbe10
main.main()
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:272 +0x3b4 fp=0x87dbf48
runtime.main()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:222 +0x11f fp=0x87dbfa0
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396 fp=0x87dbfa8

goroutine 3 [syscall]:
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396

rax 0x0
rbx 0x6
rcx 0x7fff5fbff128
rdx 0x0
rdi 0x303
rsi 0x6
rbp 0x7fff5fbff150
rsp 0x7fff5fbff128
r8 0x7fff74d60278
r9 0x2c0
r10 0x20000000
r11 0x206
r12 0x83ce6ec
r13 0x83ce6df
r14 0x7fff74d61180
r15 0x83c7c4a
rip 0x7fff8605c212
rflags 0x206
cs 0x7
fs 0x0
gs 0x0
2013/09/26 16:36:09 exit status 2

crypto/x509 doesn't build on darwin

16:44 ~/code/go/src/github.com/axw/llgo/pkg/math/big $ llgo-build crypto/x509
2013/09/26 16:48:08 building crypto/x509
/Users/quarnster/code/3rdparty/go/src/pkg/crypto/x509/verify.go:209:10: invalid operation: c (variable of type *x509.Certificate) has no field or method systemVerify
/Users/quarnster/code/3rdparty/go/src/pkg/crypto/x509/root.go:15:10: undeclared name: initSystemRoots
2013/09/26 16:48:08 exit status 2

os/exec build fails

16:37 ~/code/go/src/github.com/axw/llgo/llgo $ llgo-build os/exec
2013/09/26 16:37:15 building os/exec
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: /Users/quarnster/code/3rdparty/go/src/pkg/os/exec/exec.go:285:1: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: /Users/quarnster/code/3rdparty/go/src/pkg/os/exec/exec.go:285:1: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0x40a7640]

goroutine 1 [running]:
runtime.panic(0x42a6ea0, 0xc2106f2ba0)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/axw/llgo.func·004()
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:274 +0x87
runtime.panic(0x42a6ea0, 0xc2106f2ba0)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.func·006()
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:437 +0x2a0
runtime.panic(0x4286ea0, 0x462b939)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.(_TypeMap).nameRuntimeType(0xc210234780, 0xc2100b6b40, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:872 +0xa0
github.com/axw/llgo.(_TypeMap).makeRuntimeType(0xc210234780, 0xc2106f2b80, 0x15, 0x89112f8, 0xc2100b6b40, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:495 +0x6e7
github.com/axw/llgo.(_TypeMap).toRuntime(0xc210234780, 0x89112f8, 0xc2100b6b40, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:165 +0x117
github.com/axw/llgo.(_TypeMap).ToRuntime(0xc210234780, 0x89112f8, 0xc2100b6b40, 0xc2103ce3a8)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:157 +0x3b
github.com/axw/llgo.(_TypeMap).rtypeSlice(0xc210234780, 0xc210074060, 0xc2103ce398)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:727 +0xd6
github.com/axw/llgo.(_TypeMap).funcRuntimeType(0xc210234780, 0xc2106f2b00, 0x1c, 0xc2106f35a0, 0x8b546f8, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:748 +0x367
github.com/axw/llgo.(_TypeMap).makeRuntimeType(0xc210234780, 0xc2106f2b00, 0x1c, 0x8911288, 0xc2106f35a0, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:487 +0x4f2
github.com/axw/llgo.(_TypeMap).toRuntime(0xc210234780, 0x8911288, 0xc2106f35a0, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:165 +0x117
github.com/axw/llgo.(_TypeMap).ToRuntime(0xc210234780, 0x8911288, 0xc2106f35a0, 0xc210074060)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:157 +0x3b
github.com/axw/llgo.(_TypeMap).uncommonType(0xc210234780, 0xc210191960, 0x0, 0x1)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:840 +0x640
github.com/axw/llgo.(_TypeMap).nameRuntimeType(0xc210234780, 0xc210191960, 0x8b3de88, 0x8b3df38)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:907 +0x38a
github.com/axw/llgo.(_TypeMap).makeRuntimeType(0xc210234780, 0xc210740560, 0x1e, 0x89112f8, 0xc210191960, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:495 +0x6e7
github.com/axw/llgo.(_TypeMap).toRuntime(0xc210234780, 0x89112f8, 0xc210191960, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:165 +0x117
github.com/axw/llgo.(_TypeMap).ToRuntime(0xc210234780, 0x89112f8, 0xc210191960, 0xc210a40fa0)
/Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:157 +0x3b
github.com/axw/llgo.(_compiler).VisitGenDecl(0xc21004a160, 0xc21007fdc0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:405 +0x111
github.com/axw/llgo.(_compiler).VisitDecl(0xc21004a160, 0x89116f8, 0xc21007fdc0, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:445 +0x2fa
github.com/axw/llgo.(*compiler).Compile(0xc21004a160, 0xc210046f00, 0xc210095620, 0x2, 0x2, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:291 +0x71d
main.compileFiles(0x8911618, 0xc21004a160, 0xc21000a080, 0x2, 0x2, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:116 +0x32e
main.main()
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:272 +0x3b4

goroutine 3 [syscall]:
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396
2013/09/26 16:37:15 exit status 2

go install fails with 'cannot find package'

I have tried to go install llvmgo with the following command:

$ go install -v github.com/axw/llgo
can't load package: package github.com/axw/llgo: import "github.com/axw/llgo": cannot find package

I use Go tip: e07bc909079c

LICENSE is missing

It would be nice to have LICENSE file on the top of the repository to make it clear under which terms the code is available.

Many tests crash

When I started using llgo, I found it was crashing on a lot of the programs I wrote. I thought I was using features that hadn't been implemented yet, but it turns out that about half of the files in testdata/ will not build for me either.

They crash in different places, but seem to be having trouble dealing with certain types. Could there perhaps be something wrong with my LLVM installation? I am using LLVM 3.1 release, with --enable-targets=all --enable-shared. LLVM is able to compile generated bitcode to native assembly no problem.

Here are the results I got from testing:

  • array.go: works
  • array_index.go: works
  • circulartype.go:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x38 pc=0x486cf3]

goroutine 1 [running]:
llgo/types._func_002(0x7fefb59cff98, 0x7fefb59cffa8, 0xf84007f8a0, 0xf84007f900)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:170 +0x3a
llgo/types.(*checker).checkExpr(0xf84007f870, 0xf8400aa8c0, 0xf84007dee0, 0xf840097300, 0x100000001, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:159 +0xa2
----- stack segment boundary -----
llgo/types.(*checker).checkStmt(0xf84007f870, 0xf8400aab80, 0xf84007f7e0, 0xf84007df20)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:804 +0x14dc
llgo/types.(*checker).checkStmt(0xf84007f870, 0xf8400aad00, 0xf84007df20, 0xf8400aad00)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:819 +0x1831
llgo/types.(*checker).checkObj(0xf84007f870, 0xf8400b1d20, 0x7fef00000000, 0xf8400b1d20, 0x8, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:1043 +0xd44
llgo/types.Check(0xf8400aa800, 0xf84007f840, 0x47fab1, 0x0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:1069 +0x1bf
main.compilePackage(0xf8400aa800, 0xf84007db00, 0x100000001, 0xf84007db00, 0x0, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:136 +0xd8
main.compileFiles(0xf84007f290, 0x100000001, 0x4, 0x60ad8c, 0x7fff00000005, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:125 +0x233
main.main()
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:190 +0x9c

goroutine 2 [syscall]:
created by runtime.main
    /build/buildd/golang-1/src/pkg/runtime/proc.c:221
  • fun.go: works
  • if/lazy.go: works
  • init2.go: works
  • init.go: works
  • interface_basic.go: works
  • interface.go:
Invalid GEP pointer type
UNREACHABLE executed at /mnt/share/Programming/opensource/llvm-3.1.src/lib/VMCore/Instructions.cpp:1387!
SIGABRT: abort
PC=0x7f0a920f5445


goroutine 1 [syscall]:
gollvm/llvm._Cfunc_LLVMBuildStructGEP(0x7f0a8c0012a0, 0x7f0a8c017af8)
    /tmp/go-build510752760/gollvm/llvm/_obj/_cgo_defun.c:2266 +0x2f
gollvm/llvm.Builder.CreateStructGEP(0x7f0a8c0012a0, 0x7f0a8c017af8, 0x7f0a00000000, 0x601fac, 0x0, ...)
    /tmp/go-build510752760/gollvm/llvm/_obj/analysis.cgo1.go:1731 +0x68
llgo.(*compiler).VisitSelectorExpr(0xf8400be120, 0xf8400c3440, 0xf8400c3440, 0xf8400c3440, 0x7f0a940d0d01, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/expr.go:259 +0x2ac
llgo.(*compiler).VisitExpr(0xf8400be120, 0xf8400aafc0, 0xf8400c3440, 0x100000000000000, 0x7f0a00000002, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/expr.go:411 +0x52b
llgo.(*compiler).VisitCallExpr(0xf8400be120, 0xf84007f990, 0xf84007f990, 0xf84007f990, 0x7f0a941f0100, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/expr.go:105 +0x24d
----- stack segment boundary -----
llgo.(*compiler).VisitExpr(0xf8400be120, 0xf8400aadc0, 0xf84007f990, 0xf840237480, 0x200000000, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/expr.go:407 +0x3bf
llgo.(*compiler).VisitPrintln(0xf8400be120, 0xf84007f9c0, 0x60e944, 0x6e69727000000007, 0xf800000000, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/println.go:72 +0x171
llgo.(*compiler).VisitCallExpr(0xf8400be120, 0xf84007f9c0, 0xf84007f9c0, 0xf84007f9c0, 0xf8400aa901, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/expr.go:96 +0x111e
llgo.(*compiler).VisitExpr(0xf8400be120, 0xf8400aadc0, 0xf84007f9c0, 0xf840096900, 0x1, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/expr.go:407 +0x3bf
llgo.(*compiler).VisitStmt(0xf8400be120, 0xf8400c6000, 0xf840096900, 0x600000003)
    /home/prattmic/programming/opensource/golang/src/llgo/stmt.go:387 +0x6cd
llgo.(*compiler).VisitBlockStmt(0xf8400be120, 0xf8400c3520, 0x72746e6500000005, 0x7f0a8c009c80)
    /home/prattmic/programming/opensource/golang/src/llgo/stmt.go:58 +0xab
llgo.(*compiler).VisitFuncDecl(0xf8400be120, 0xf84007fa80, 0xf84007fa80, 0xf84007fa80, 0x7f0a8c000b01, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:119 +0x672
llgo.(*compiler).VisitDecl(0xf8400be120, 0xf8400aacc0, 0xf84007fa80, 0x0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:369 +0x243
llgo.(*compiler).Compile(0xf8400be120, 0xf8400aa800, 0xf84007fab0, 0xf8400c35e0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/compiler.go:313 +0x7bb
main.compilePackage(0xf8400aa800, 0xf84007db00, 0x100000001, 0xf84007db00, 0x0, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:151 +0x2c9
main.compileFiles(0xf84007f290, 0x100000001, 0x4, 0x60ad8c, 0x7fff00000005, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:125 +0x233
main.main()
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:190 +0x9c

goroutine 2 [syscall]:
created by runtime.main
    /build/buildd/golang-1/src/pkg/runtime/proc.c:221
rax     0x0
rbx     0x7f0a938d36f0
rcx     0xffffffffffffffff
rdx     0x6
rdi     0xbfb
rsi     0xbfc
rbp     0x7f0a938d5980
rsp     0x7f0a916a9be8
r8      0xcccccccccccccccd
r9      0x1000
r10     0x8
r11     0x202
r12     0x56b
r13     0x7f0a916a9d90
r14     0x0
r15     0x3
rip     0x7f0a920f5445
rflags  0x202
cs      0x33
fs      0x0
gs      0x0
  • interface_i2i.go:

panic: Failed to locate method: Name [recovered]
    panic: interface_i2i.go:24:5: Failed to locate method: Name [recovered]
    panic: interface_i2i.go:21:1: interface_i2i.go:24:5: Failed to locate method: Name [recovered]
    panic: interface_i2i.go:21:1: interface_i2i.go:24:5: Failed to locate method: Name

goroutine 1 [running]:
llgo._func_001(0x7fbf62fa7dd0, 0x7fbf62e87100, 0x7fbf62e87c00, 0x7fbf62e87ad0)
    /home/prattmic/programming/opensource/golang/src/llgo/compiler.go:296 +0x7d
----- stack segment boundary -----
llgo._func_003(0x7fbf62fa7b18, 0x7fbf62fa7b20, 0x7fbf62e87100, 0x7fbf62e87d78, 0x7fbf62e87c48, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:363 +0x25f
----- stack segment boundary -----
llgo._func_003(0x7fbf62fa76e0, 0x7fbf62fa76e8, 0x7fbf62e87100, 0x7fbf62e87fb8, 0x7fbf62e87dc0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:363 +0x25f
----- stack segment boundary -----
llgo.(*LLVMValue).convertI2I(0xf8402a5a50, 0xf840096960, 0xf840096960, 0xf840096960, 0x7fbf62fa7100, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/interfaces.go:159 +0x814
----- stack segment boundary -----
llgo.(*LLVMValue).Convert(0xf8402a5a50, 0xf84007ccc0, 0xf840096960, 0xf84007fa80, 0xf84007fa50, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/value.go:329 +0x34f
llgo.(*compiler).VisitTypeAssertExpr(0xf8400be120, 0xf8400c34a0, 0xf8400c34a0, 0xf8400c34a0, 0x406901, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/expr.go:389 +0xd7
llgo.(*compiler).VisitExpr(0xf8400be120, 0xf8400aaf00, 0xf8400c34a0, 0x0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/expr.go:417 +0x42e
llgo.(*compiler).VisitValueSpec(0xf8400be120, 0xf8400aaf40, 0xf8400aaf00, 0xf8400aaf40, 0x407a01, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:260 +0x4a9
llgo.(*compiler).VisitGenDecl(0xf8400be120, 0xf84007f8d0, 0xf84007f8d0, 0xf84007f8d0)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:349 +0x2b5
llgo.(*compiler).VisitDecl(0xf8400be120, 0xf8400aaa40, 0xf84007f8d0, 0x0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:371 +0x2c6
llgo.(*compiler).VisitStmt(0xf8400be120, 0xf8400aae40, 0xf840096860, 0x500000002)
    /home/prattmic/programming/opensource/golang/src/llgo/stmt.go:391 +0x4c1
llgo.(*compiler).VisitBlockStmt(0xf8400be120, 0xf8400c35c0, 0x72746e6500000005, 0x7fbf58015e80)
    /home/prattmic/programming/opensource/golang/src/llgo/stmt.go:58 +0xab
llgo.(*compiler).VisitFuncDecl(0xf8400be120, 0xf84007f9c0, 0xf84007f9c0, 0xf84007f9c0, 0x7fbf58000b01, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:119 +0x672
llgo.(*compiler).VisitDecl(0xf8400be120, 0xf8400aad00, 0xf84007f9c0, 0x0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:369 +0x243
llgo.(*compiler).Compile(0xf8400be120, 0xf8400aa800, 0xf84007f9f0, 0xf8400c3680, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/compiler.go:313 +0x7bb
main.compilePackage(0xf8400aa800, 0xf84007db20, 0x100000001, 0xf84007db20, 0x0, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:151 +0x2c9
main.compileFiles(0xf84007f290, 0x100000001, 0x4, 0x60ad8c, 0x7fff00000005, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:125 +0x233
main.main()
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:190 +0x9c

goroutine 2 [syscall]:
created by runtime.main
    /build/buildd/golang-1/src/pkg/runtime/proc.c:221
  • literals/slice.go: works
  • literals/struct.go:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x38 pc=0x486cf3]

goroutine 1 [running]:
llgo/types._func_002(0x7f4bb4a69f98, 0x7f4bb4a69fa8, 0xf840521370, 0xf8400d0120)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:170 +0x3a
llgo/types.(*checker).checkExpr(0xf8405c5120, 0xf8400aadc0, 0xf8400c5420, 0xf8404d9888, 0x100000001, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:159 +0xa2
----- stack segment boundary -----
llgo/types.(*checker).checkStmt(0xf8405c5120, 0xf8400aae00, 0xf84007f990, 0xf8400c5440)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:804 +0x14dc
llgo/types.(*checker).checkStmt(0xf8405c5120, 0xf840277680, 0xf8400c5440, 0xf840277680)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:819 +0x1831
llgo/types.(*checker).checkObj(0xf8405c5120, 0xf8400b1dc0, 0x7f4b00000000, 0xf8400b1dc0, 0x8, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:1043 +0xd44
llgo/types.Check(0xf8400aa800, 0xf84007f9f0, 0x47fab1, 0x0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:1069 +0x1bf
main.compilePackage(0xf8400aa800, 0xf84007db20, 0x100000001, 0xf84007db20, 0x0, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:136 +0xd8
main.compileFiles(0xf84007f290, 0x100000001, 0x4, 0x60ad8c, 0x7fff00000005, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:125 +0x233
main.main()
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:190 +0x9c

goroutine 2 [syscall]:
created by runtime.main
    /build/buildd/golang-1/src/pkg/runtime/proc.c:221
  • multi.go: works
  • new.go: works
  • nil.go: works
  • strings/add.go:
panic: unhandled (*types.Basic, Basic(string))

goroutine 1 [running]:
llgo/types.untypedPriority(0xf84007ec30, 0xf8400970e8, 0xf8400970e8, 0xf8400970e8, 0x1, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:150 +0x274
llgo/types.(*checker).checkExpr(0xf84007f900, 0xf8400aa980, 0xf84007f750, 0xf8400972e0, 0x100000001, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:247 +0x2d9b
----- stack segment boundary -----
llgo/types.(*checker).checkStmt(0xf84007f900, 0xf8400aa940, 0xf84007f780, 0xf84007dea0)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:804 +0x14dc
llgo/types.(*checker).checkStmt(0xf84007f900, 0xf8400aac40, 0xf84007dea0, 0xf8400aac40)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:819 +0x1831
llgo/types.(*checker).checkObj(0xf84007f900, 0xf8400b1be0, 0x7f1d00000000, 0xf8400b1be0, 0x8, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:1043 +0xd44
llgo/types.Check(0xf8400aa800, 0xf84007f8d0, 0x47fab1, 0x0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/types/check.go:1069 +0x1bf
main.compilePackage(0xf8400aa800, 0xf84007db00, 0x100000001, 0xf84007db00, 0x0, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:136 +0xd8
main.compileFiles(0xf84007f290, 0x100000001, 0x4, 0x60ad8c, 0x7fff00000005, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:125 +0x233
main.main()
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:190 +0x9c

goroutine 2 [syscall]:
created by runtime.main
    /build/buildd/golang-1/src/pkg/runtime/proc.c:221
  • strings/compare.go: works
  • structs/embed.go: works
  • switch/empty.go: works
  • switch/scope.go: works
  • unsafe/pointer.go: works
  • varargs.go:
panic: Failed to create LLVM type for: Bad(unresolved identifier) [recovered]
    panic: varargs.go:3:1: Failed to create LLVM type for: Bad(unresolved identifier) [recovered]
    panic: varargs.go:3:1: Failed to create LLVM type for: Bad(unresolved identifier)

goroutine 1 [running]:
llgo._func_001(0x7f80b694bdd0, 0x7f80b682b100, 0x7f80b682bfb8, 0x7f80b682bf68)
    /home/prattmic/programming/opensource/golang/src/llgo/compiler.go:296 +0x7d
----- stack segment boundary -----
----- stack segment boundary -----
llgo._func_003(0x7f80b694bb18, 0x7f80b694bb20, 0x7f80b694b100, 0x7f80b694bfb8, 0x7f80b694b1f0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:363 +0x25f
----- stack segment boundary -----
llgo.(*TypeMap).ToLLVM(0xf8400c9000, 0xf84007f960, 0xf840096880, 0x5cea40, 0x7f80b694b328, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/llvmtypes.go:109 +0x1f6
llgo.(*TypeMap).sliceLLVMType(0xf8400c9000, 0xf840096890, 0xf840096890, 0xf840096890, 0x7f80b694b301, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/llvmtypes.go:199 +0x33
llgo.(*TypeMap).makeLLVMType(0xf8400c9000, 0xf84007f990, 0xf840096890, 0xf840096890, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/llvmtypes.go:138 +0xb9
llgo.(*TypeMap).ToLLVM(0xf8400c9000, 0xf84007f990, 0xf840096890, 0xf84007f990, 0xf840096890, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/llvmtypes.go:107 +0xc5
llgo.(*TypeMap).funcLLVMType(0xf8400c9000, 0xf84007f9c0, 0xf84007f9c0, 0xf84007f9c0, 0x7f80b694b501, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/llvmtypes.go:239 +0x287
llgo.(*TypeMap).makeLLVMType(0xf8400c9000, 0xf84007f9f0, 0xf84007f9c0, 0xf84007f9c0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/llvmtypes.go:144 +0x439
llgo.(*TypeMap).ToLLVM(0xf8400c9000, 0xf84007f9f0, 0xf84007f9c0, 0xf84007f9f0, 0xf84007f9c0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/llvmtypes.go:107 +0xc5
llgo.(*compiler).VisitFuncProtoDecl(0xf8400be120, 0xf84007f750, 0xf84007f750, 0xf84007f750, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:58 +0x20e
llgo.(*compiler).Resolve(0xf8400be120, 0xf8400b1b90, 0x7f8000000000, 0x43fb81a94f7e6000, 0xf84012ffa0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/compiler.go:127 +0x969
llgo.(*compiler).VisitFuncDecl(0xf8400be120, 0xf84007f750, 0xf84007f750, 0xf84007f750, 0x7f80ac000b01, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:75 +0x74
llgo.(*compiler).VisitDecl(0xf8400be120, 0xf8400aac00, 0xf84007f750, 0x0, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/decl.go:369 +0x243
llgo.(*compiler).Compile(0xf8400be120, 0xf8400aa800, 0xf84007f900, 0xf8400c4200, 0x0, ...)
    /home/prattmic/programming/opensource/golang/src/llgo/compiler.go:313 +0x7bb
main.compilePackage(0xf8400aa800, 0xf84007db00, 0x100000001, 0xf84007db00, 0x0, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:151 +0x2c9
main.compileFiles(0xf84007f290, 0x100000001, 0x4, 0x60ad8c, 0x7fff00000005, ...)
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:125 +0x233
main.main()
    /mnt/share/Programming/opensource/golang/src/llgo/llgo/llgo.go:190 +0x9c

goroutine 2 [syscall]:
created by runtime.main
    /build/buildd/golang-1/src/pkg/runtime/proc.c:221
  • var.go: works

Wrong package used by parser?

I'm trying to build targeting pnacl using my MBP laptop, but running into some issues. (Pull request fixing some issues will come later as they are ironed out.)

One of the issues is that Mtim appears to be Mtime + Mtimensec, and Atim is Atime + Atimensec so stat_pnacl.go have to be changed to reflect this, no biggie.

12:20 ~/code/go/src/github.com/axw/llgo/cmd/llgo-dist $ strings ../../pkg/syscall/ztypes_pnacl.go | grep Mtim
Mtime
Mtimensec
12:21 ~/code/go/src/github.com/axw/llgo/cmd/llgo-dist $ strings $GOPATH/pkg/llgo/pnacl/syscall.bc | grep Mtim
struct{Dev int64; Ino uint64; Mode uint32; Nlink uint32; Uid uint32; Gid uint32; Rdev int64; Size int64; Blksize int32; Blocks int32; Atime int64; Atimensec int64; Mtime int64; Mtimensec int64; Ctime int64; Ctimensec int64}T)aa
12:21 ~/code/go/src/github.com/axw/llgo/cmd/llgo-dist $

However, llgo's parsing now complains that there is no Mtime in the syscall.Stat_t structure which obviously isn't the case: /Users/quarnster/code/go/src/github.com/axw/llgo/pkg/os/stat_pnacl.go:24:22: invalid operation: st (variable of type *syscall.Stat_t) has no field or method Mtime

This makes me believe that the parser is picking up the standard go syscall package rather than the llgo compiled pnacl one.

No automated tests

I have a bunch of Go source files which I manually compile with llgo for testing. This should be automated using Go's built-in test package/tool. Ideally these would be run after every commit using a continuous integration framework, via web hooks (or otherwise on a regular basis).

encoding/json build asserts

2013/09/26 16:34:44 building encoding/json
Assertion failed: (getOperand(0)->getType() == cast(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"), function AssertOK, file /Users/quarnster/code/3rdparty/llvm-3.3.src/lib/IR/Instructions.cpp, line 1084.
SIGABRT: abort
PC=0x7fff8605c212
signal arrived during cgo execution

runtime.cgocall(0x4003050, 0x87e8820)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:149 +0x11b fp=0x87e8808
github.com/axw/gollvm/llvm._Cfunc_LLVMBuildStore(0xa000250, 0xa1bd1a0, 0xa1bc628, 0xffffffffffffffff)
github.com/axw/gollvm/llvm/_obj/_cgo_defun.c:1322 +0x31 fp=0x87e8820
github.com/axw/gollvm/llvm.Builder.CreateStore(0xa000250, 0xa1bd1a0, 0xa1bc628, 0x0)
/Users/quarnster/code/go/src/github.com/axw/gollvm/llvm/core.go:1467 +0x44 fp=0x87e8848
github.com/axw/llgo.(_Builder).CreateStore(0xc210768610, 0xa1bd1a0, 0xa1bc628)
/Users/quarnster/code/go/src/github.com/axw/llgo/builder.go:45 +0x128 fp=0x87e8898
github.com/axw/llgo.(_compiler).createGlobals(0xc210049160, 0xc2100eabd0, 0x1, 0x1, 0xc2100f3b60, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:316 +0xd46 fp=0x87e8a38
github.com/axw/llgo.(_compiler).VisitValueSpec(0xc210049160, 0xc2100f45f0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:349 +0x4b9 fp=0x87e8b58
github.com/axw/llgo.(_compiler).Resolve(0xc210049160, 0xc2100e9240, 0xc2100e9240, 0xc2100e9240)
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:106 +0x629 fp=0x87e8c90
github.com/axw/llgo.(_compiler).VisitExpr(0xc210049160, 0x8910888, 0xc2100e9240, 0xc21083fa50, 0x1)
/Users/quarnster/code/go/src/github.com/axw/llgo/expr.go:568 +0x1e9 fp=0x87e8d40
github.com/axw/llgo.(_compiler).VisitReturnStmt(0xc210049160, 0xc2100e9260)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:133 +0xf37 fp=0x87e8f90
----- stack segment boundary -----
github.com/axw/llgo.(_compiler).VisitStmt(0xc210049160, 0x8910b28, 0xc2100e9260)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:896 +0x7f1 fp=0x87db2b8
github.com/axw/llgo.(_compiler).VisitSwitchStmt(0xc210049160, 0xc2100e6570)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:534 +0xf12 fp=0x87db4a0
github.com/axw/llgo.(_compiler).VisitStmt(0xc210049160, 0x8910ee0, 0xc2100e6570)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:914 +0x6b6 fp=0x87db5b0
github.com/axw/llgo.(_compiler).VisitBlockStmt(0xc210049160, 0xc2100e65a0, 0x8916200)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:73 +0x2b4 fp=0x87db618
github.com/axw/llgo.(_compiler).buildFunction(0xc210049160, 0xc2109e4a50, 0x0, 0xc2109e19c0, 0xc2102651a0, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:184 +0x1132 fp=0x87db958
github.com/axw/llgo.(_compiler).VisitFuncDecl(0xc210049160, 0xc2100e65d0, 0xc2100e65d0, 0xc2100e65d0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:230 +0x425 fp=0x87dba60
github.com/axw/llgo.(_compiler).VisitDecl(0xc210049160, 0x8910850, 0xc2100e65d0, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:443 +0x283 fp=0x87dbb98
github.com/axw/llgo.(_compiler).Compile(0xc210049160, 0xc210046ec0, 0xc210176b00, 0x6, 0x8, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:291 +0x71d fp=0x87dbd40
main.compileFiles(0x8910738, 0xc210049160, 0xc21000a080, 0x6, 0x6, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:116 +0x32e fp=0x87dbe10
main.main()
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:272 +0x3b4 fp=0x87dbf48
runtime.main()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:222 +0x11f fp=0x87dbfa0
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396 fp=0x87dbfa8

goroutine 3 [syscall]:
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396

rax 0x0
rbx 0x6
rcx 0x7fff5fbff358
rdx 0x0
rdi 0x303
rsi 0x6
rbp 0x7fff5fbff380
rsp 0x7fff5fbff358
r8 0x7fff74d60278
r9 0x43c
r10 0x20000000
r11 0x206
r12 0x83e53f2
r13 0x83e5042
r14 0x7fff74d61180
r15 0x83e4b16
rip 0x7fff8605c212
rflags 0x206
cs 0x7
fs 0x0
gs 0x0
2013/09/26 16:34:44 exit status 2

Calling a function pointer generates two call instructions.

When you call a function pointer in Go, llgo currently generates two call instructions: one for the case that the function pointer is a closure, and one for the case it's not (selecting between them at runtime based on whether the context pointer is null). This causes unnecessary branching and code bloat.

I believe this can be avoided by marking the context parameter of closures with the nest attribute, and always treating calls to function pointers as calls to closures are currently treated, passing in the context pointer.
Because the nest parameter should effectively be ignored by functions that don't actually have a nest parameter (it's put into a register they don't consider a parameter register), this should work for regular functions that don't declare a nest attribute as well as for closures that do.
And even if this doesn't work because LLVM optimization passes don't like it, it would probably be easy enough to add an unused 'nest' parameter to each function type. It wouldn't cost anything at runtime as long as an 'undef' value is always passed to it when called directly.

a wiki article about TODO and unimplemented features

TODO:

  1. int should be 64-bit on 64-bit platforms, fix hardcoded uint typed len/cap in slice header definitions.
    (should introduce intgo like the gc runtime).
  2. Go 1.1 runtime type representation compatibility (WIP)
  3. defer
  4. goroutines
  5. ???

for {...} at the end of a function = no terminating instructions

As reported in #26.

If for{...} comes last in a function, then llgo doesn't generate any terminator instructions. We currently check for terminating instructions in buildFunction, but only for functions with no results. This should be revised to cater for functions with results, for which we'll emit "unreachable" instructions.

Signals are not handled

Signal handling is required so that we get panics instead of cores, e.g. in the event of divide by zero (SIGFPE).

update to use new go/types package from tip

with https://code.google.com/p/go/source/detail?r=8ea98ec93704, exp/types is moved
to go/types, and scheduled for Go 1.1 release (yey!).

Although gri noted that the API is not stable yet, i think we'd better consider migration
to that package as I don't think the API will change dramatically; at least we can sort
out the differences between go/types and our internal types package.

I just log this issue at the tracker, and we can continue discussion on llgo-dev.

database/sql build fails

16:39 ~/code/go/src/github.com/axw/llgo/pkg/crypto $ llgo-build database/sql
2013/09/26 16:40:46 building database/sql
panic: unreachable [recovered]
panic: /Users/quarnster/code/3rdparty/go/src/pkg/database/sql/sql.go:566:1: unreachable [recovered]
panic: /Users/quarnster/code/3rdparty/go/src/pkg/database/sql/sql.go:566:1: unreachable

goroutine 1 [running]:
runtime.panic(0x42a6ea0, 0xc21078cac0)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/axw/llgo.func·004()
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:274 +0x87
runtime.panic(0x42a6ea0, 0xc21078cac0)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.func·006()
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:437 +0x2a0
runtime.panic(0x42108c0, 0xc210806280)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.(_compiler).VisitRangeStmt(0xc210049160, 0xc2100b4d70)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:641 +0x1ca0
github.com/axw/llgo.(_compiler).VisitStmt(0xc210049160, 0x8910c40, 0xc2100b4d70)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:916 +0x727
github.com/axw/llgo.(_compiler).VisitBlockStmt(0xc210049160, 0xc2100b0f60, 0x8916100)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:73 +0x2b4
github.com/axw/llgo.(_compiler).buildFunction(0xc210049160, 0xc21080e600, 0x0, 0xc21078ca60, 0x0, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:184 +0x1132
github.com/axw/llgo.(_compiler).VisitFuncDecl(0xc210049160, 0xc2100b0fc0, 0xc2100b0fc0, 0xc2100b0fc0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:230 +0x425
github.com/axw/llgo.(_compiler).VisitDecl(0xc210049160, 0x8910968, 0xc2100b0fc0, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:443 +0x283
github.com/axw/llgo.(*compiler).Compile(0xc210049160, 0xc210045ec0, 0xc210113ce0, 0x2, 0x2, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:291 +0x71d
main.compileFiles(0x8910738, 0xc210049160, 0xc21000a080, 0x2, 0x2, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:116 +0x32e
main.main()
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:272 +0x3b4

goroutine 3 [syscall]:
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396
2013/09/26 16:40:46 exit status 2

install error, "NewFieldVar" has changed

Hello,

$ go get github.com/axw/llgo/llgo
# github.com/axw/llgo
(gopath)/src/github.com/axw/llgo/literals.go:79: undefined: types.NewFieldVar

Above error happened when installing llgo.
The function name has maybe changed recently.

...I recognize that the change happened in the past 2 hours :)
https://code.google.com/p/go/source/diff?spec=svn.tools.73ce43ee19e587d837f19c94171c9d48869d618a&repo=tools&r=73ce43ee19e587d837f19c94171c9d48869d618a&format=side&path=/go/types/objects.go&old_path=/go/types/objects.go&old=8f2c714c6d97eff5544e11097ea2e24572018e40

Implement pure Go LLVM IR writer

This needs some exploration, but I think it should be pretty straight forward to implement a pure Go LLVM IR builder/writer for use in llgo. This would:

  • Enable us to work around deficiencies in the LLVM C API (e.g. no support for cyclic metadata)
  • Speed up builds, and vastly cut down the size of llgo's binaries (no huge libraries to statically link in)
  • Potentially better runtime performance, since there's no need to call through cgo.
  • No need for LD_LIBRARY_PATH shenanigans when only dynamic libraries are available.
  • No need for unsafe code (so llgo could used inside a web application)
  • I'm sure there's more.

Constant return values are not type coerced

Constants aren't being coerced when used as return values. Example:

package main

func foo() float32 {
    return 0
}

(I realize your target scope for llgo is rather narrow at the moment, but I figured it might still be worth creating an issue for it.)

Don't Panic

There are numerous places in llgo where panics are being used. They should be removed in favour of errors, with source location (i.e. using scanner error lists).

attempt on mac OS X 10.8, probably my fault

I've not been able to get past this (last) part of the test sequence. I don't think I know enough about LLVM to know how to help here beyond giving the assertion failure and the stacktrace.

If I can help in some other way, let me know.

Notes:

  1. The tuple for mac OS appears to be :

llgo --print-triple
x86_64-unknown-darwin

  1. I built llvm 3.2 from source and used the flag in configure as recommended.

  2. I'm running on the pre-built go 1.0.3 for OS X.

ian

=== RUN TestArrayRange
Assertion failed: (ExtractValueInst::getIndexedType(Agg->getType(), Idxs) == Val->getType() && "insertvalue indices invalid!"), function getInsertValue, file Constants.cpp, line 1906.
SIGABRT: abort
pc: 0x7fff93370212

goroutine 1 [chan receive]:
testing.RunTests(0x2000, 0x41fcc8, 0x4600000046, 0xf800000001, 0x948f2, ...)
/usr/local/go/src/pkg/testing/testing.go:369 +0x7b8
testing.Main(0x2000, 0x41fcc8, 0x4600000046, 0x421ab8, 0x0, ...)
/usr/local/go/src/pkg/testing/testing.go:304 +0x7a
main.main()
github.com/axw/llgo/llgo/_test/_testmain.go:181 +0x91

goroutine 2 [syscall]:
created by runtime.main
/usr/local/go/src/pkg/runtime/proc.c:221

goroutine 3 [syscall]:
github.com/axw/gollvm/llvm._Cfunc_LLVMConstInsertValue(0x300c360, 0x300c6e8)
github.com/axw/gollvm/llvm/_obj/_cgo_defun.c:1402 +0x2f
github.com/axw/gollvm/llvm.ConstInsertValue(0x300c360, 0x300c6e8, 0xf84039e510, 0x100000001, 0x0, ...)
github.com/axw/gollvm/llvm/_obj/analysis.cgo1.go:1114 +0x96
github.com/axw/llgo.(_TypeMap).makeCommonType(0xf8400e5460, 0xf8400e8780, 0xf8403a0200, 0xf800000017, 0xf8403a0200, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llvmtypes.go:488 +0x6a2
github.com/axw/llgo.(_TypeMap).sliceRuntimeType(0xf8400e5460, 0xf8403a0200, 0x0, 0x0, 0x1, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llvmtypes.go:517 +0x7b
github.com/axw/llgo.(_TypeMap).makeRuntimeType(0xf8400e5460, 0xf8400e8780, 0xf8403a0200, 0x0, 0x0, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llvmtypes.go:376 +0xfa
github.com/axw/llgo.(_TypeMap).toRuntime(0xf8400e5460, 0xf8400e8780, 0xf8403a0200, 0x0, 0x0, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llvmtypes.go:162 +0xd8
github.com/axw/llgo.(_TypeMap).ToRuntime(0xf8400e5460, 0xf8400e8780, 0xf8403a0200, 0xf8400e8780, 0xf8403a0200, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llvmtypes.go:154 +0x3b
github.com/axw/llgo.(_compiler).VisitSliceExpr(0xf84009d0f0, 0xf84035c180, 0xf84035c180, 0xf84035c180, 0x7e01, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/slice.go:189 +0xbc4
github.com/axw/llgo.(_compiler).VisitExpr(0xf84009d0f0, 0xf84017cf80, 0xf84035c180, 0xf8402917b0, 0xf8400c59c0, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/expr.go:538 +0x784
github.com/axw/llgo.(_compiler).VisitCallExpr(0xf84009d0f0, 0xf8402917b0, 0xf8402917b0, 0xf8402917b0, 0x1, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/expr.go:201 +0x6fc
github.com/axw/llgo.(_compiler).VisitExpr(0xf84009d0f0, 0xf8400bef40, 0xf8402917b0, 0xf8403a0070, 0x100000001, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/expr.go:526 +0x3bf
github.com/axw/llgo.(_compiler).VisitReturnStmt(0xf84009d0f0, 0xf840263120, 0x24b6100, 0x24b6fb8)
/Users/iansmith/oder/go/src/github.com/axw/llgo/stmt.go:133 +0x8cb
----- stack segment boundary -----
github.com/axw/llgo.(_compiler).VisitStmt(0xf84009d0f0, 0xf8400bea80, 0xf840263120, 0x24b6360)
/Users/iansmith/oder/go/src/github.com/axw/llgo/stmt.go:939 +0x7c8
github.com/axw/llgo.(_compiler).VisitBlockStmt(0xf84009d0f0, 0xf840263140, 0x257b00, 0xf84039c1c0, 0xf84050d9c0, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/stmt.go:90 +0x3ba
github.com/axw/llgo.(_compiler).buildFunction(0xf84009d0f0, 0xf84039c140, 0xf84041d018, 0x100000001, 0xf840263140, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/decl.go:143 +0x7c8
github.com/axw/llgo.(_compiler).VisitFuncDecl(0xf84009d0f0, 0xf8402917e0, 0xf8402917e0, 0xf8402917e0, 0x2804901, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/decl.go:191 +0x2f9
github.com/axw/llgo.(_compiler).VisitDecl(0xf84009d0f0, 0xf8400df000, 0xf8402917e0, 0x0, 0x0, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/decl.go:401 +0x240
github.com/axw/llgo.(_compiler).Compile(0xf84009d0f0, 0xf840471bc0, 0xf8402398a0, 0x2824b4, 0xf800000007, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/compiler.go:363 +0x530
github.com/axw/llgo/llgo.compilePackage(0xf8400be940, 0xf84009d0f0, 0xf840471bc0, 0xf8400d16c0, 0x2824b4, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llgo/llgo.go:161 +0x2cd
github.com/axw/llgo/llgo.compileFiles(0xf8400be940, 0xf84009d0f0, 0xf840126c40, 0x1900000019, 0x2824b4, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llgo/llgo.go:134 +0x283
github.com/axw/llgo/llgo.getRuntimeModule(0x0, 0x0)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llgo/utils_test.go:80 +0x131
github.com/axw/llgo/llgo.addRuntime(0xf8400de360, 0x0, 0x0, 0xf8400c5900)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llgo/utils_test.go:121 +0x2e
github.com/axw/llgo/llgo.runMainFunction(0xf8400de360, 0x0, 0x0, 0x0, 0x0, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llgo/utils_test.go:131 +0x7b
github.com/axw/llgo/llgo.runAndCheckMain(0x2a12d, 0xf84009c720, 0x100000001, 0x0, 0x0, ...)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llgo/utils_test.go:248 +0x3fd
github.com/axw/llgo/llgo.checkOutputEqual(0xf8400b7800, 0xf84009c720, 0x100000001, 0x23ac5)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llgo/utils_test.go:258 +0x5f
github.com/axw/llgo/llgo.TestArrayRange(0xf8400b7800, 0x2b52938)
/Users/iansmith/oder/go/src/github.com/axw/llgo/llgo/array_test.go:7 +0x61
testing.tRunner(0xf8400b7800, 0x41fcc8, 0x0, 0x0)
/usr/local/go/src/pkg/testing/testing.go:292 +0x6f
created by testing.RunTests
/usr/local/go/src/pkg/testing/testing.go:368 +0x795

goroutine 5 [finalizer wait]:
created by runtime.gc
/usr/local/go/src/pkg/runtime/mgc0.c:882
rax 0x0
rbx 0x6
rcx 0x7fff5fbff708
rdx 0x0
rdi 0x303
rsi 0x6
rbp 0x7fff5fbff730
rsp 0x7fff5fbff708
r8 0x7fff78f4d278
r9 0x7fff5fbff070
r10 0x0
r11 0x287
r12 0x300c6e8
r13 0xf840562db0
r14 0x7fff78f4e180
r15 0xf84039e510
rip 0x7fff93370212
rflags 0x286
cs 0x7
fs 0x0
gs 0x0
exit status 2

Update copyright notices

Given that there are now substantial contributions from others, the copyright notice should be updated to say "llgo authors" rather than "Andrew Wilkins". Also, change all copyright headers to the abbreviated form as is done in newer files.

LLVM Types must be computed once and only once

LLVM performs type equality comparison by comparing pointers. Llgo computes LLVM Type's every time you invoke types.Type.LLVMType(), each one yielding a new LLVM Type.

So instead we need to cache the computed LLVM Type's. I'd also like to move the LLVM logic out of llgo/types, so I can submit fixes/enhancements to the types package back upstream.

llgo/testdata/structs/embed.go

Go 1.2 changes the use of nil, so this test can no longer run with go run.

Nil receivers as such aren't disallowed, it's just when accessing member that it fails I think.

    var a *A
    a.testA() // Ok, pointer receiver
    a.testA2() // Not ok, non-pointer receiver
    a.test() // Not ok, while using a pointer receiver it accesses a.aval

The tests use of c.testA() then fails as it turns into something like (&B.A).testA(). I'm not sure how you want to fix it, we could set c.B = &b or "overload" testA with a *B receiver which would work.

go/parser build asserts

16:41 ~/code/go/src/github.com/axw/llgo/pkg/crypto $ llgo-build go/parser
2013/09/26 16:42:29 building go/parser
Assertion failed: (NumBits >= MIN_INT_BITS && "bitwidth too small"), function get, file /Users/quarnster/code/3rdparty/llvm-3.3.src/lib/IR/Type.cpp, line 306.
SIGABRT: abort
PC=0x7fff8605c212
signal arrived during cgo execution

runtime.cgocall(0x4004b80, 0x87fb790)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:149 +0x11b fp=0x87fb778
github.com/axw/gollvm/llvm._Cfunc_LLVMIntType(0x0, 0x0)
github.com/axw/gollvm/llvm/_obj/_cgo_defun.c:3518 +0x31 fp=0x87fb790
github.com/axw/gollvm/llvm.IntType(0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/gollvm/llvm/core.go:451 +0x31 fp=0x87fb7a8
github.com/axw/llgo.(_LLVMValue).loadI2V(0xc210a339c0, 0x8911318, 0xc2102bd000, 0x881a7d0)
/Users/quarnster/code/go/src/github.com/axw/llgo/interfaces.go:273 +0x4de fp=0x87fb878
github.com/axw/llgo.(_LLVMValue).convertI2V(0xc210a339c0, 0x8911318, 0xc2102bd000, 0x0, 0x0, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/interfaces.go:191 +0x22e fp=0x87fb9d0
github.com/axw/llgo.(_LLVMValue).mustConvertI2V(0xc210a339c0, 0x8911318, 0xc2102bd000, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/interfaces.go:215 +0x4c fp=0x87fbaa8
github.com/axw/llgo.(_LLVMValue).Convert(0xc210a339c0, 0x8916c68, 0xc21022b540, 0x8a605c8, 0xc210a339c0)
/Users/quarnster/code/go/src/github.com/axw/llgo/value.go:524 +0x4bd fp=0x87fbf78
----- stack segment boundary -----
github.com/axw/llgo.(_compiler).VisitTypeAssertExpr(0xc210049160, 0xc210076690, 0xc210076690, 0xc210076690)
/Users/quarnster/code/go/src/github.com/axw/llgo/expr.go:533 +0xbe fp=0x87ec418
github.com/axw/llgo.(_compiler).VisitExpr(0xc210049160, 0x89118d8, 0xc210076690, 0x42a0520, 0xc210077c60)
/Users/quarnster/code/go/src/github.com/axw/llgo/expr.go:564 +0x5a0 fp=0x87ec4c8
github.com/axw/llgo.(_compiler).VisitAssignStmt(0xc210049160, 0xc210070cc0)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:251 +0x839 fp=0x87ec5d8
github.com/axw/llgo.(_compiler).VisitStmt(0xc210049160, 0x8911910, 0xc210070cc0)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:898 +0x84c fp=0x87ec6e8
github.com/axw/llgo.(_compiler).VisitBlockStmt(0xc210049160, 0xc2100766f0, 0x8817e00)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:73 +0x2b4 fp=0x87ec750
github.com/axw/llgo.(_compiler).VisitIfStmt(0xc210049160, 0xc210070d00)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:345 +0x242 fp=0x87ec7a0
github.com/axw/llgo.(_compiler).VisitStmt(0xc210049160, 0x8911830, 0xc210070d00)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:902 +0x9d8 fp=0x87ec8b0
github.com/axw/llgo.(_compiler).VisitBlockStmt(0xc210049160, 0xc210076870, 0x8916b00)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:73 +0x2b4 fp=0x87ec918
github.com/axw/llgo.(_compiler).buildFunction(0xc210049160, 0xc210a40ae0, 0xc2105b0520, 0x0, 0x0, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:184 +0x1132 fp=0x87ecc58
github.com/axw/llgo.(_compiler).VisitFuncLit(0xc210049160, 0xc210043f20, 0xc210043f20, 0xc210043f20)
/Users/quarnster/code/go/src/github.com/axw/llgo/literals.go:99 +0xe75 fp=0x87ecf80
----- stack segment boundary -----
github.com/axw/llgo.(_compiler).VisitExpr(0xc210049160, 0x8911c20, 0xc210043f20, 0x401a4bb, 0x4062911)
/Users/quarnster/code/go/src/github.com/axw/llgo/expr.go:548 +0x80b fp=0x87db3f8
github.com/axw/llgo.(_compiler).VisitDeferStmt(0xc210049160, 0xc210043f40)
/Users/quarnster/code/go/src/github.com/axw/llgo/defer.go:138 +0x54 fp=0x87db4a0
github.com/axw/llgo.(_compiler).VisitStmt(0xc210049160, 0x8911c58, 0xc210043f40)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:924 +0xa33 fp=0x87db5b0
github.com/axw/llgo.(_compiler).VisitBlockStmt(0xc210049160, 0xc2100768a0, 0xc210076800)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:73 +0x2b4 fp=0x87db618
github.com/axw/llgo.(_compiler).buildFunction(0xc210049160, 0xc210a80a50, 0x0, 0xc21051db00, 0xc2102465a0, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:184 +0x1132 fp=0x87db958
github.com/axw/llgo.(_compiler).VisitFuncDecl(0xc210049160, 0xc210076930, 0xc210076930, 0xc210076930)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:230 +0x425 fp=0x87dba60
github.com/axw/llgo.(_compiler).VisitDecl(0xc210049160, 0x8911750, 0xc210076930, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:443 +0x283 fp=0x87dbb98
github.com/axw/llgo.(_compiler).Compile(0xc210049160, 0xc210045ec0, 0xc2101659f0, 0x2, 0x2, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:291 +0x71d fp=0x87dbd40
main.compileFiles(0x8911638, 0xc210049160, 0xc21000a080, 0x2, 0x2, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:116 +0x32e fp=0x87dbe10
main.main()
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:272 +0x3b4 fp=0x87dbf48
runtime.main()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:222 +0x11f fp=0x87dbfa0
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396 fp=0x87dbfa8

goroutine 3 [syscall]:
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396

rax 0x0
rbx 0x6
rcx 0xb0186cf8
rdx 0x0
rdi 0x1a03
rsi 0x6
rbp 0xb0186d20
rsp 0xb0186cf8
r8 0x7fff74d60278
r9 0x132
r10 0x20000000
r11 0x206
r12 0x83ea984
r13 0x83c8bd1
r14 0xb0187000
r15 0x83ea8d2
rip 0x7fff8605c212
rflags 0x206
cs 0x7
fs 0x0
gs 0x0
2013/09/26 16:42:30 exit status 2

Tracking issue: debug information

Would be really cool to have binaries compiled with llgo correctly resolve variable info, function arguments, source code lines etc when running through a debugger.

llgo-build hash panics

$ llgo-build hash
2013/09/25 17:38:00 building hash
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: /Users/quarnster/code/3rdparty/go/src/pkg/hash/hash.go:11:1: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: /Users/quarnster/code/3rdparty/go/src/pkg/hash/hash.go:11:1: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0x40a7640]

goroutine 1 [running]:
runtime.panic(0x42a6ea0, 0xc210855bc0)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/axw/llgo.func·004()
    /Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:274 +0x87
runtime.panic(0x42a6ea0, 0xc210855bc0)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.func·006()
    /Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:437 +0x2a0
runtime.panic(0x4286ea0, 0x462b939)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.(*TypeMap).nameRuntimeType(0xc21006e180, 0xc2100382a0, 0x0, 0x0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:872 +0xa0
github.com/axw/llgo.(*TypeMap).makeRuntimeType(0xc21006e180, 0xc210855ba0, 0x12, 0x8910418, 0xc2100382a0, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:495 +0x6e7
github.com/axw/llgo.(*TypeMap).toRuntime(0xc21006e180, 0x8910418, 0xc2100382a0, 0x0, 0x0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:165 +0x117
github.com/axw/llgo.(*TypeMap).ToRuntime(0xc21006e180, 0x8910418, 0xc2100382a0, 0x8806238)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:157 +0x3b
github.com/axw/llgo.(*TypeMap).rtypeSlice(0xc21006e180, 0xc210052e00, 0xc2108570b0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:727 +0xd6
github.com/axw/llgo.(*TypeMap).funcRuntimeType(0xc21006e180, 0xc2101643f0, 0x27, 0xc2100727e0, 0x880b5a8, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:748 +0x367
github.com/axw/llgo.(*TypeMap).makeRuntimeType(0xc21006e180, 0xc2101643f0, 0x27, 0x89103a8, 0xc2100727e0, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:487 +0x4f2
github.com/axw/llgo.(*TypeMap).toRuntime(0xc21006e180, 0x89103a8, 0xc2100727e0, 0x0, 0x0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:165 +0x117
github.com/axw/llgo.(*TypeMap).ToRuntime(0xc21006e180, 0x89103a8, 0xc2100727e0, 0x3)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:157 +0x3b
github.com/axw/llgo.(*TypeMap).interfaceRuntimeType(0xc21006e180, 0xc2107eec40, 0x6f, 0xc210083200, 0x8804c98, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:769 +0x3b4
github.com/axw/llgo.(*TypeMap).makeRuntimeType(0xc21006e180, 0xc2107eec40, 0x6f, 0x89103e0, 0xc210083200, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:489 +0x584
github.com/axw/llgo.(*TypeMap).toRuntime(0xc21006e180, 0x89103e0, 0xc210083200, 0x0, 0x0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:165 +0x117
github.com/axw/llgo.(*TypeMap).nameRuntimeType(0xc21006e180, 0xc21007f2a0, 0x0, 0x0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:892 +0x755
github.com/axw/llgo.(*TypeMap).makeRuntimeType(0xc21006e180, 0xc2104d3d80, 0x16, 0x8910418, 0xc21007f2a0, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:495 +0x6e7
github.com/axw/llgo.(*TypeMap).toRuntime(0xc21006e180, 0x8910418, 0xc21007f2a0, 0x0, 0x0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:165 +0x117
github.com/axw/llgo.(*TypeMap).ToRuntime(0xc21006e180, 0x8910418, 0xc21007f2a0, 0xc210744490)
    /Users/quarnster/code/go/src/github.com/axw/llgo/typemap.go:157 +0x3b
github.com/axw/llgo.(*compiler).VisitGenDecl(0xc21004b160, 0xc21006c500)
    /Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:405 +0x111
github.com/axw/llgo.(*compiler).VisitDecl(0xc21004b160, 0x8910818, 0xc21006c500, 0x0, 0x0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:445 +0x2fa
github.com/axw/llgo.(*compiler).Compile(0xc21004b160, 0xc210046ec0, 0xc2100002e0, 0x1, 0x1, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:291 +0x71d
main.compileFiles(0x8910738, 0xc21004b160, 0xc21000a080, 0x1, 0x1, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:116 +0x32e
main.main()
    /Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:272 +0x3b4

goroutine 3 [syscall]:
runtime.goexit()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396
2013/09/25 17:38:01 exit status 2

crypto/tls build asserts

16:39 ~/code/go/src/github.com/axw/llgo/pkg/crypto $ llgo-build crypto/tls
2013/09/26 16:39:32 building crypto/tls
Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"), function init, file /Users/quarnster/code/3rdparty/llvm-3.3.src/lib/IR/Instructions.cpp, line 281.
SIGABRT: abort
PC=0x7fff8605c212
signal arrived during cgo execution

runtime.cgocall(0x40024d0, 0x87e8bb8)
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/cgocall.c:149 +0x11b fp=0x87e8ba0
github.com/axw/gollvm/llvm._Cfunc_LLVMBuildCall(0x88042c0, 0xa2223d8, 0xc210825b60, 0xc200000002, 0xa2200c0, ...)
github.com/axw/gollvm/llvm/_obj/_cgo_defun.c:764 +0x31 fp=0x87e8bb8
github.com/axw/gollvm/llvm.Builder.CreateCall(0x88042c0, 0xa2223d8, 0xc210825b60, 0x2, 0x2, ...)
/Users/quarnster/code/go/src/github.com/axw/gollvm/llvm/core.go:1647 +0x9f fp=0x87e8bf8
github.com/axw/gollvm/llvm.Builder.CreateCall·fm(0xa2223d8, 0xc210825b60, 0x2, 0x2, 0x42cfb10, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/expr.go:270 +0x7e fp=0x87e8c40
github.com/axw/llgo.(_compiler).createCall(0xc21004a160, 0xc210aec5a0, 0xc210825b00, 0x1, 0x1, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/expr.go:338 +0xfb9 fp=0x87e8f68
----- stack segment boundary -----
github.com/axw/llgo.(_compiler).VisitCallExpr(0xc21004a160, 0xc2101afe00, 0xc2101afe00, 0xc2101afe00)
/Users/quarnster/code/go/src/github.com/axw/llgo/expr.go:221 +0x615 fp=0x87db3f0
github.com/axw/llgo.(_compiler).VisitExpr(0xc21004a160, 0x8910b60, 0xc2101afe00, 0xc2101adda0, 0x400c101)
/Users/quarnster/code/go/src/github.com/axw/llgo/expr.go:554 +0x532 fp=0x87db4a0
github.com/axw/llgo.(_compiler).VisitStmt(0xc21004a160, 0x8910ab8, 0xc2101adda0)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:906 +0x97d fp=0x87db5b0
github.com/axw/llgo.(_compiler).VisitBlockStmt(0xc21004a160, 0xc2101bc7e0, 0x891eb00)
/Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:73 +0x2b4 fp=0x87db618
github.com/axw/llgo.(_compiler).buildFunction(0xc21004a160, 0xc210673000, 0x0, 0xc210b021e0, 0xc210445720, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:184 +0x1132 fp=0x87db958
github.com/axw/llgo.(_compiler).VisitFuncDecl(0xc21004a160, 0xc2101bc840, 0xc2101bc840, 0xc2101bc840)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:230 +0x425 fp=0x87dba60
github.com/axw/llgo.(_compiler).VisitDecl(0xc21004a160, 0x89109d8, 0xc2101bc840, 0x0, 0x0)
/Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:443 +0x283 fp=0x87dbb98
github.com/axw/llgo.(*compiler).Compile(0xc21004a160, 0xc210069000, 0xc210130b80, 0xb, 0x10, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:291 +0x71d fp=0x87dbd40
main.compileFiles(0x8910738, 0xc21004a160, 0xc21000a080, 0xb, 0xb, ...)
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:116 +0x32e fp=0x87dbe10
main.main()
/Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:272 +0x3b4 fp=0x87dbf48
runtime.main()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:222 +0x11f fp=0x87dbfa0
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396 fp=0x87dbfa8

goroutine 3 [syscall]:
runtime.goexit()
/Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396

rax 0x0
rbx 0x6
rcx 0x7fff5fbff068
rdx 0x0
rdi 0x303
rsi 0x6
rbp 0x7fff5fbff090
rsp 0x7fff5fbff068
r8 0x7fff74d60278
r9 0x119
r10 0x20000000
r11 0x206
r12 0x83e4cb8
r13 0x83ce73c
r14 0x7fff74d61180
r15 0x83e4b16
rip 0x7fff8605c212
rflags 0x206
cs 0x7
fs 0x0
gs 0x0
2013/09/26 16:39:33 exit status 2

Implement basic goroutine support

As an initial step, implement goroutines one-to-one with threads.
Later replace with M-N implementation with user-land scheduler.

Compilation broken

Hello

I have some compilation error:

[zert@mtreskin]:Go $>> export CGO_CFLAGS="`llvm-config --cflags`"
[zert@mtreskin]:Go $>> export CGO_LDFLAGS="`llvm-config --ldflags` -Wl,-L`llvm-config --libdir` -lLLVM-`llvm-config --version`"
[zert@mtreskin]:Go $>> go get github.com/axw/llgo/llgo
package github.com/axw/llgo/llgo: mkdir /usr/lib/go/src/pkg/github.com: permission denied
[zert@mtreskin]:Go $>> export GOPATH=`pwd`
[zert@mtreskin]:Go $>> go get github.com/axw/llgo/llgo
# github.com/axw/gollvm/llvm
1: error: 'LLVMInitializeXCoreTarget' undeclared (first use in this function)
1: note: each undeclared identifier is reported only once for each function it appears in
1: error: 'LLVMInitializeMipsTarget' undeclared (first use in this function)
1: error: 'LLVMInitializeMSP430Target' undeclared (first use in this function)
1: error: 'LLVMInitializeMBlazeTarget' undeclared (first use in this function)
1: error: 'LLVMInitializePowerPCTargetInfo' undeclared (first use in this function)
1: error: 'LLVMInitializeCellSPUTarget' undeclared (first use in this function)
1: error: 'LLVMInitializeARMTarget' undeclared (first use in this function)
1: error: 'LLVMInitializeSparcTarget' undeclared (first use in this function)
1: error: 'LLVMInitializeARMTargetInfo' undeclared (first use in this function)
1: error: 'LLVMInitializeCellSPUTargetInfo' undeclared (first use in this function)
1: error: 'LLVMInitializePowerPCTarget' undeclared (first use in this function)
1: error: 'LLVMInitializeSparcTargetInfo' undeclared (first use in this function)
1: error: 'LLVMInitializeMBlazeTargetInfo' undeclared (first use in this function)
1: error: 'LLVMInitializeMSP430TargetInfo' undeclared (first use in this function)
1: error: 'LLVMInitializeMipsTargetInfo' undeclared (first use in this function)
1: error: 'LLVMInitializeXCoreTargetInfo' undeclared (first use in this function)
[zert@mtreskin]:Go $>> echo $CGO_CFLAGS 
-I/usr/include  -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS   -fPIC
[zert@mtreskin]:Go $>> echo $CGO_LDFLAGS 
-L/usr/lib64/llvm  -lpthread -lffi -ldl -lm  -Wl,-L/usr/lib64/llvm -lLLVM-3.1

How I can fix it?

Thank you

Met `No matching .ll file` error while running llgo-dist on MacOS

I was following post http://blog.awilkins.id.au/2012/12/go-in-browser-llgo-does-pnacl.html to install llgo on my Mac for writing PNaCl code, but I have met this problem:

2013/05/24 15:41:30 - syscall
No matching .ll file for "asm_darwin_amd64.s"

I have checked the syscall directory but only find asm_linux_amd64.ll and asm_linux_arm.ll. Could you please tell me how to get the .ll file for MacOS?

Here are some information of my dev env:

  • llvm: Version 3.3svn, which is shipped with pepper_canary
  • llgo-dist: Fetched via go get github.com/axw/llgo/cmd/llgo-dist
  • MacOS: 10.7.5

Thanks.

By the way, I have met some error while running llgo-dist in pkg/runtime/panic.c, the reason is because of thread-local variable is not supported by compiler on MacOS, I have made some changes in my local version and will submit a pull request if needed.

llgo-build testing fails

17:38 ~/code/go/src/github.com/axw/llgo/cmd/llgo-dist $ llgo-build testing
2013/09/25 17:39:52 building testing
Verification failed: Referring to a basic block in another function!
  %0 = invoke { i8*, i64 }* @flag.String({ i8*, i64 } { i8* getelementptr inbounds ([17 x i8]* @137, i32 0, i32 0), i64 17 }, { i8*, i64 } zeroinitializer, { i8*, i64 } { i8* getelementptr inbounds ([58 x i8]* @138, i32 0, i32 0), i64 58 })
          to label %1 unwind label %unwind
Referring to a basic block in another function!
  %0 = invoke { i8*, i64 }* @flag.String({ i8*, i64 } { i8* getelementptr inbounds ([17 x i8]* @137, i32 0, i32 0), i64 17 }, { i8*, i64 } zeroinitializer, { i8*, i64 } { i8* getelementptr inbounds ([58 x i8]* @138, i32 0, i32 0), i64 58 })
          to label %1 unwind label %unwind
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Referring to a basic block in another function!
  %0 = invoke i1* @flag.Bool({ i8*, i64 } { i8* getelementptr inbounds ([6 x i8]* @173, i32 0, i32 0), i64 6 }, i1 false, { i8*, i64 } { i8* getelementptr inbounds ([32 x i8]* @174, i32 0, i32 0), i64 32 })
          to label %1 unwind label %unwind
Referring to a basic block in another function!
  %0 = invoke i1* @flag.Bool({ i8*, i64 } { i8* getelementptr inbounds ([6 x i8]* @173, i32 0, i32 0), i64 6 }, i1 false, { i8*, i64 } { i8* getelementptr inbounds ([32 x i8]* @174, i32 0, i32 0), i64 32 })
          to label %1 unwind label %unwind
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.

llgo behaves badly when calling SetInsertPointAtEnd with nil basic block

In parts of llgo we defer a call to SetInsertPointAtEnd with the current basic block. LLVM doesn't check that it's non-nil and behaviour is unpredictable (unless building with debug/asserts, in which case it will segfault).

We should check the basic block is nil before deferring the call.

database/sql/driver build fails

16:40 ~/code/go/src/github.com/axw/llgo/pkg/crypto $ llgo-build database/sql/driver
2013/09/26 16:41:33 building database/sql/driver
Basic Block in function '__llgo.ctor.database/sql/driver.0' does not have terminator!
label %entry
LLVM ERROR: Broken module, no Basic Block terminator!
2013/09/26 16:41:33 exit status 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.