From 05495c42820e56b384cc5e92ae0ea26354fe1667 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 12 Jul 2020 19:25:36 +0200 Subject: [PATCH] all: fix -gc=none This option was broken for a long time, in part because we didn't test for it. This commit fixes that and adds a test to make sure it won't break again unnoticed. --- Makefile | 5 +++++ interp/scan.go | 2 ++ transform/optimizer.go | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0e033dfb..b59b9ce6 100644 --- a/Makefile +++ b/Makefile @@ -335,6 +335,11 @@ endif @$(MD5SUM) test.hex $(TINYGO) build -o wasm.wasm -target=wasm examples/wasm/export $(TINYGO) build -o wasm.wasm -target=wasm examples/wasm/main + # test various compiler flags + $(TINYGO) build -size short -o test.hex -target=pca10040 -gc=none -scheduler=none examples/blinky1 + @$(MD5SUM) test.hex + $(TINYGO) build -size short -o test.hex -target=pca10040 -opt=1 examples/blinky1 + @$(MD5SUM) test.hex wasmtest: $(GO) test ./tests/wasm diff --git a/interp/scan.go b/interp/scan.go index adeb8f43..d8c764d8 100644 --- a/interp/scan.go +++ b/interp/scan.go @@ -122,6 +122,8 @@ func (e *evalPackage) hasSideEffects(fn llvm.Value) (*sideEffectResult, *Error) // External function call. Assume only limited side effects // (no affected globals, etc.). switch child.Name() { + case "runtime.alloc": + continue case "runtime.typeAssert": continue // implemented in interp case "runtime.interfaceImplements": diff --git a/transform/optimizer.go b/transform/optimizer.go index 9c77c312..917083ce 100644 --- a/transform/optimizer.go +++ b/transform/optimizer.go @@ -158,7 +158,7 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i // After TinyGo-specific transforms have finished, undo exporting these functions. for _, name := range getFunctionsUsedInTransforms(config) { fn := mod.NamedFunction(name) - if fn.IsNil() { + if fn.IsNil() || fn.IsDeclaration() { continue } fn.SetLinkage(llvm.InternalLinkage)