tinygo/compiler/testdata
Ayke van Laethem 8bbfb1ee68 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.
2022-09-08 08:25:27 +02:00
..
basic.go compiler: properly implement div and rem operations 2021-10-28 15:55:02 +02:00
basic.ll Set internal linkage and keeping default visibility for anonymous functions 2022-08-01 10:53:48 +02:00
channel.go compiler: avoid zero-sized alloca in channel operations 2021-09-09 11:24:52 +02:00
channel.ll compiler: update tests after adding new wasm features 2022-06-22 07:50:40 +02:00
defer-cortex-m-qemu.ll Set internal linkage and keeping default visibility for anonymous functions 2022-08-01 10:53:48 +02:00
defer.go compiler: insert basic blocks at an appropriate location 2022-06-16 07:59:21 +02:00
float.go compiler: test float to int conversions and fix upper-bound calculation 2021-01-19 14:02:32 +01:00
float.ll compiler: update tests after adding new wasm features 2022-06-22 07:50:40 +02:00
func.go compiler: add func tests 2021-04-12 12:07:42 +02:00
func.ll compiler: update tests after adding new wasm features 2022-06-22 07:50:40 +02:00
gc.go transform: remove switched func lowering 2022-01-19 14:42:02 -05:00
gc.ll compiler: update tests after adding new wasm features 2022-06-22 07:50:40 +02:00
generics.go compiler: implement unsafe.Alignof and unsafe.Sizeof for generic code 2022-07-28 15:43:51 +02:00
generics.ll compiler: implement unsafe.Alignof and unsafe.Sizeof for generic code 2022-07-28 15:43:51 +02:00
goroutine-cortex-m-qemu-tasks.ll Set internal linkage and keeping default visibility for anonymous functions 2022-08-01 10:53:48 +02:00
goroutine-wasm-asyncify.ll Set internal linkage and keeping default visibility for anonymous functions 2022-08-01 10:53:48 +02:00
goroutine.go compiler: add support for the go keyword on interface methods 2021-10-31 14:17:25 +01:00
interface.go compiler: simplify interface lowering 2021-10-31 14:17:25 +01:00
interface.ll compiler: update tests after adding new wasm features 2022-06-22 07:50:40 +02:00
pointer.go compiler: refactor and add tests 2021-01-15 14:43:43 +01:00
pointer.ll compiler: update tests after adding new wasm features 2022-06-22 07:50:40 +02:00
pragma.go all: format code according to Go 1.19 rules 2022-08-04 12:18:32 +02:00
pragma.ll wasm: do not allow undefined symbols 2022-09-08 08:25:27 +02:00
slice.go all: drop support for Go 1.16 and Go 1.17 2022-08-30 12:38:06 +02:00
slice.ll all: drop support for Go 1.16 and Go 1.17 2022-08-30 12:38:06 +02:00
string.go compiler: fix indices into strings and arrays 2021-11-13 11:04:24 +01:00
string.ll compiler: update tests after adding new wasm features 2022-06-22 07:50:40 +02:00