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
llvmutil
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
atomic.go compiler: define atomic intrinsic functions directly 2022-06-24 11:10:24 +02:00
calls.go
channel.go
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
func.go
gc.go
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
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
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