Skip to content

Commit 05495c4

Browse files
aykevldeadprogram
authored andcommitted
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.
1 parent d606315 commit 05495c4

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ endif
335335
@$(MD5SUM) test.hex
336336
$(TINYGO) build -o wasm.wasm -target=wasm examples/wasm/export
337337
$(TINYGO) build -o wasm.wasm -target=wasm examples/wasm/main
338+
# test various compiler flags
339+
$(TINYGO) build -size short -o test.hex -target=pca10040 -gc=none -scheduler=none examples/blinky1
340+
@$(MD5SUM) test.hex
341+
$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=1 examples/blinky1
342+
@$(MD5SUM) test.hex
338343

339344
wasmtest:
340345
$(GO) test ./tests/wasm

interp/scan.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ func (e *evalPackage) hasSideEffects(fn llvm.Value) (*sideEffectResult, *Error)
122122
// External function call. Assume only limited side effects
123123
// (no affected globals, etc.).
124124
switch child.Name() {
125+
case "runtime.alloc":
126+
continue
125127
case "runtime.typeAssert":
126128
continue // implemented in interp
127129
case "runtime.interfaceImplements":

transform/optimizer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i
158158
// After TinyGo-specific transforms have finished, undo exporting these functions.
159159
for _, name := range getFunctionsUsedInTransforms(config) {
160160
fn := mod.NamedFunction(name)
161-
if fn.IsNil() {
161+
if fn.IsNil() || fn.IsDeclaration() {
162162
continue
163163
}
164164
fn.SetLinkage(llvm.InternalLinkage)

0 commit comments

Comments
 (0)