tinygo/compiler
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
..
ircheck Fix incorrect formatting arguments 2022-04-10 22:58:16 +02:00
llvmutil builder: free LLVM objects after use 2022-05-30 07:53:28 +02:00
testdata wasm: do not allow undefined symbols 2022-09-08 08:25:27 +02:00
alias.go compiler: replace math aliases with intrinsics 2022-08-30 17:33:16 +02:00
asserts.go compiler: insert basic blocks at an appropriate location 2022-06-16 07:59:21 +02:00
atomic.go compiler: define atomic intrinsic functions directly 2022-06-24 11:10:24 +02:00
calls.go compiler: implement recover() built-in function 2022-06-16 07:59:21 +02:00
channel.go compiler: avoid zero-sized alloca in channel operations 2021-09-09 11:24:52 +02:00
compiler.go compiler: replace math aliases with intrinsics 2022-08-30 17:33:16 +02:00
compiler_test.go compiler: replace some math operation bodies with fast intrinsics 2022-08-30 17:33:16 +02:00
defer.go darwin: don't clobber X18 and FP registers 2022-07-26 09:02:06 +02:00
errors.go all: fix staticcheck warnings 2021-09-27 15:47:12 +02:00
func.go compiler: remove parentHandle from calling convention 2022-01-19 14:42:02 -05:00
gc.go compiler: track the result of string concatenation 2020-04-02 14:04:25 +02:00
goroutine.go all: format code according to Go 1.19 rules 2022-08-04 12:18:32 +02:00
inlineasm.go all: format code according to Go 1.19 rules 2022-08-04 12:18:32 +02:00
interface.go all: format code according to Go 1.19 rules 2022-08-04 12:18:32 +02:00
interrupt.go transform: refactor interrupt lowering 2021-11-06 09:40:15 +01:00
intrinsics.go compiler: replace math aliases with intrinsics 2022-08-30 17:33:16 +02:00
llvm.go archFamily(): arm64 is aarch64, not arm; fixes #2985 2022-07-15 17:41:39 +02:00
map.go src/runtime: first darft of map growth code 2022-04-28 09:14:45 +02:00
sizes.go compiler: fix unsafe.Sizeof for chan and map values 2022-09-01 03:53:27 +02:00
symbol.go wasm: do not allow undefined symbols 2022-09-08 08:25:27 +02:00
syscall.go compiler: drop support for macos syscalls via inline assembly 2022-06-24 12:51:18 +02:00
volatile.go compiler: replace some math operation bodies with fast intrinsics 2022-08-30 17:33:16 +02:00