Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Go and append() make the cartridge fail at runtime #790

Open
matm opened this issue Dec 16, 2024 · 2 comments
Open

Using Go and append() make the cartridge fail at runtime #790

matm opened this issue Dec 16, 2024 · 2 comments

Comments

@matm
Copy link
Contributor

matm commented Dec 16, 2024

Adding this code snippet into the main.go just after a w4 init

var s = []int{1}

//go:export start
func start() {
        s = append(s, 2)
}

compiles fine but fails at runtime with the blue screen error

The cartridge has tried to import a missing function. See console for more details.

Unfortunately there is nothing in the console.

We recently merged this target.json for games written in Go, maybe we're missing something there, I don't know:

{
    "llvm-target": "wasm32-unknown-unknown",
    "cpu": "generic",
    "features": "+mutable-globals,+nontrapping-fptoint,+sign-ext,+bulk-memory",
    "build-tags": [
        "tinygo.wasm",
        "wasm_unknown"
    ],
    "goos": "linux",
    "goarch": "arm",
    "linker": "wasm-ld",
    "rtlib": "compiler-rt",
    "scheduler": "none",
    "cflags": [
        "-mno-bulk-memory",
        "-mnontrapping-fptoint",
        "-msign-ext"
    ],
    "ldflags": [
        "--allow-undefined",
        "--no-demangle",
        "--import-memory",
        "--initial-memory=65536",
        "--max-memory=65536",
        "--stack-first",
        "--no-entry",
        "-zstack-size=14752"
    ]
}

So for now, append() can't be used at all, which is very annoying :(

Using

$ tinygo version
tinygo version 0.34.0 linux/amd64 (using go version go1.23.3 and LLVM version 18.1.2)
@matm
Copy link
Contributor Author

matm commented Dec 16, 2024

That means the current snake tutorial in Go fails at runtime.

@matm
Copy link
Contributor Author

matm commented Dec 17, 2024

Okay, I think the current settings in target.json lead to missing features. I mean, some function calls don't work, append() can't be used without having a blue screen of the death. Same for the rand package which can be imported by raises runtime errors.

The current setup has to be wrong. I don't know tinygo much, maybe some of you can help guys? There is no way to make the current Snake tutorial work at all with these target.json parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant