From 906e061e379d3c46cd494e2aa9f6445724bd9fa2 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 30 Aug 2018 05:58:54 +0200 Subject: [PATCH] Replace own dummy syscall with standard library syscall This makes it easier to support other standard library packages. --- README.markdown | 5 ++--- compiler.go | 5 +++++ interpreter.go | 10 ++++++++++ src/syscall/syscall.go | 5 ----- 4 files changed, 17 insertions(+), 8 deletions(-) delete mode 100644 src/syscall/syscall.go diff --git a/README.markdown b/README.markdown index f57c403e..7a28203f 100644 --- a/README.markdown +++ b/README.markdown @@ -97,10 +97,9 @@ Implemented compiler passes: Requirements: - * Go 1.10+ (Go 1.9 has a - [known bug](https://github.com/aykevl/tinygo/issues/2)). + * Go 1.11+ * LLVM dependencies, see the Software section in the - [LLVM build guide](https://llvm.org/docs/GettingStarted.html#software). + [LLVM build guide](https://llvm.org/docs/GettingStarted.html#software) First download the sources (this takes a while): diff --git a/compiler.go b/compiler.go index 6622248d..f50945f4 100644 --- a/compiler.go +++ b/compiler.go @@ -1321,6 +1321,11 @@ func (c *Compiler) parseBuiltin(frame *Frame, args []ssa.Value, callName string) } func (c *Compiler) parseFunctionCall(frame *Frame, args []ssa.Value, llvmFn llvm.Value, blocking bool, parentHandle llvm.Value) (llvm.Value, error) { + if llvmFn.Name() == "sync.runtime_registerPoolCleanup" || llvmFn.Name() == "sync.runtime_notifyListCheck" { + // Ignore these functions calls for now, as a hack. + // TODO: implement //go:linkname. + return llvm.Value{}, nil + } var params []llvm.Value if blocking { if parentHandle.IsNil() { diff --git a/interpreter.go b/interpreter.go index f137f530..6cf34e59 100644 --- a/interpreter.go +++ b/interpreter.go @@ -67,6 +67,16 @@ func (p *Program) interpret(instrs []ssa.Instruction, paramKeys []*ssa.Parameter if callee == nil { return i, nil // don't understand dynamic dispatch } + if callee.String() == "syscall.runtime_envs" { + // TODO: replace this with some //go:linkname magic. + // For now, do as if it returned a zero-length slice. + var err error + locals[instr], err = p.getZeroValue(callee.Signature.Results().At(0).Type()) + if err != nil { + return i, err + } + continue + } if canInterpret(callee) { params := make([]Value, len(common.Args)) for i, arg := range common.Args { diff --git a/src/syscall/syscall.go b/src/syscall/syscall.go deleted file mode 100644 index d7ebaf3a..00000000 --- a/src/syscall/syscall.go +++ /dev/null @@ -1,5 +0,0 @@ -package syscall - -// dummy - -type Errno uintptr