Open thegrumpylion opened 4 years ago
$ uname -a
Linux nikolas-ThinkPad-T470p 5.0.0-36-generic #39~18.04.1-Ubuntu SMP Tue Nov 12 11:09:50 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ tinygo -version
tinygo version 0.10.0-dev linux/amd64 (using go version go1.13.1)
I tried to build it but got the following error:
panic: interp: unknown GEP
Note that your fork of gopher-lua has not adjusted all import paths, maybe that's the issue? I made a symlink from github.com/yuin/gopher-lua (with your fork) to github.com/thegrumpylion/gopher-lua and then it compiled.
Have you built master of my fork? I forgot to mention that i am using another branch (https://github.com/thegrumpylion/gopher-lua/tree/tinygo)
I've pushed another commit to that branch that i have replaced all import paths to point to my fork, rebased the current dev
of tinygo to the lua
branch and i get the same error as above.
If it compiles for you, have you tried to run the example? It should print something over serial.
Ok, now also master is the same
What I did:
tinygo build -target=pca10056 -o lua.hex lua.go
Result:
panic: interp: unknown GEP
In order to get the above example working on tinygo, I need a small patch to reflect
and another to runtime
. Note that I didn't need to modify gopher-lua
at all.
~/go/src/github.com/tinygo-org/tinygo/src/reflect $ cat chan.go
package reflect
type SelectDir int
const (
_ SelectDir = iota
SelectSend // case Chan <- Send
SelectRecv // case <-Chan:
SelectDefault // default
)
type SelectCase struct {
Dir SelectDir // direction of case
Chan Value // channel to use (for send or receive)
Send Value // value to send (for send)
}
func Select(cases []SelectCase) (chosen int, recv Value, recvOK bool) {
panic("reflect.Select: unimplemented")
}
func (v Value) Send(x Value) {
panic("reflect.Value.Send(): unimplemented")
}
func (v Value) Close() {
panic("reflect.Value.Close(): unimplemented")
}
~/go/src/github.com/tinygo-org/tinygo/src/reflect $ git diff
diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go
index 2699e08b..7a6f8e63 100644
--- a/src/runtime/mstats.go
+++ b/src/runtime/mstats.go
@@ -9,6 +9,11 @@ package runtime
type MemStats struct {
// General statistics.
+ // Alloc is bytes of allocated heap objects.
+ //
+ // This is the same as HeapAlloc (see below).
+ Alloc uint64
+
// Sys is the total bytes of memory obtained from the OS.
//
// Sys is the sum of the XSys fields below. Sys measures the
@@ -18,6 +23,19 @@ type MemStats struct {
// Heap memory statistics.
+ // HeapAlloc is bytes of allocated heap objects.
+ //
+ // "Allocated" heap objects include all reachable objects, as
+ // well as unreachable objects that the garbage collector has
+ // not yet freed. Specifically, HeapAlloc increases as heap
+ // objects are allocated and decreases as the heap is swept
+ // and unreachable objects are freed. Sweeping occurs
+ // incrementally between GC cycles, so these two processes
+ // occur simultaneously, and as a result HeapAlloc tends to
+ // change smoothly (in contrast with the sawtooth that is
+ // typical of stop-the-world garbage collectors).
+ HeapAlloc uint64
+
// HeapSys is bytes of heap memory, total.
//
// In TinyGo unlike upstream Go, we make no distinction between
~/go/src/github.com/tinygo-org/tinygo/src/reflect $
I will come up with a PR to add these stubs.
I have forked and striped of any "os" dependencies this package https://github.com/yuin/gopher-lua (my fork https://github.com/thegrumpylion/gopher-lua) and i am trying to build this example https://github.com/thegrumpylion/tinygo/blob/lua/src/examples/lua/lua.go
tinygo build -target=pca10056 -o lua.hex ./src/examples/lua
But i hit this wall:
Any ideas what am i doing wrong?