diff options
author | Ayke van Laethem <[email protected]> | 2022-09-04 14:44:28 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-09-08 08:25:27 +0200 |
commit | 8bbfb1ee68245a967081165c7161cd3421f97823 (patch) | |
tree | fc4c025370c81aecfa73b4d9878ff46b438d299d /.github/workflows/windows.yml | |
parent | 07cdcc61f772ad6d9ec88b6b9fd877316b579fca (diff) | |
download | tinygo-8bbfb1ee68245a967081165c7161cd3421f97823.tar.gz tinygo-8bbfb1ee68245a967081165c7161cd3421f97823.zip |
wasm: do not allow undefined symbols
--allow-undefined can be a problem: it allows compiling code that will
fail when loaded. This change makes sure that if some symbols are
undefined, they are reported as an error by the linker.
Previously, people could get away with importing a function that was not
defined, like this:
func add(int a, int b) int
func test() {
println(add(3, 5))
}
This was always unintended but mostly worked. With this change, it isn't
possible anymore. Now every function needs to be marked with //export
explicitly:
//export add
func add(int a, int b) int
func test() {
println(add(3, 5))
}
As before, functions will be placed in the `env` module with the name
set from the `//export` tag. This can be overridden with
`//go:import-module`:
//go:import-module math
//export add
func add(int a, int b) int
func test() {
println(add(3, 5))
}
For the syscall/js package, I needed to give a list of symbols that are
undefined. This list is based on the JavaScript functions defined in
targets/wasm_exec.js.
Diffstat (limited to '.github/workflows/windows.yml')
0 files changed, 0 insertions, 0 deletions