diff options
author | Ayke van Laethem <[email protected]> | 2024-07-10 13:42:21 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2024-08-11 01:48:11 -0700 |
commit | 2e76cd3687df0f6a4ea8d042589ced1d22f4ea78 (patch) | |
tree | 0dca13e2a3642f2986e6ee341c24cea963f7c5dc /testdata | |
parent | 2eb39785fe9d0188e444fd1eb29f1ce2c7a89419 (diff) | |
download | tinygo-2e76cd3687df0f6a4ea8d042589ced1d22f4ea78.tar.gz tinygo-2e76cd3687df0f6a4ea8d042589ced1d22f4ea78.zip |
builder: interpret linker error messages
This shows nicely formatted error messages for missing symbol names and
for out-of-flash, out-of-RAM conditions (on microcontrollers with
limited flash/RAM).
Unfortunately the missing symbol name errors aren't available on Windows
and WebAssembly because the linker doesn't report source locations yet.
This is something that I could perhaps improve in LLD.
Diffstat (limited to 'testdata')
-rw-r--r-- | testdata/errors/linker-flashoverflow.go | 21 | ||||
-rw-r--r-- | testdata/errors/linker-ramoverflow.go | 9 | ||||
-rw-r--r-- | testdata/errors/linker-undefined.go | 11 |
3 files changed, 41 insertions, 0 deletions
diff --git a/testdata/errors/linker-flashoverflow.go b/testdata/errors/linker-flashoverflow.go new file mode 100644 index 000000000..46e7d9858 --- /dev/null +++ b/testdata/errors/linker-flashoverflow.go @@ -0,0 +1,21 @@ +package main + +import "unsafe" + +const ( + a = "0123456789abcdef" // 16 bytes + b = a + a + a + a + a + a + a + a // 128 bytes + c = b + b + b + b + b + b + b + b // 1024 bytes + d = c + c + c + c + c + c + c + c // 8192 bytes + e = d + d + d + d + d + d + d + d // 65536 bytes + f = e + e + e + e + e + e + e + e // 524288 bytes +) + +var s = f + +func main() { + println(unsafe.StringData(s)) +} + +// ERROR: program too large for this chip (flash overflowed by {{[0-9]+}} bytes) +// ERROR: optimization guide: https://tinygo.org/docs/guides/optimizing-binaries/ diff --git a/testdata/errors/linker-ramoverflow.go b/testdata/errors/linker-ramoverflow.go new file mode 100644 index 000000000..866f984ad --- /dev/null +++ b/testdata/errors/linker-ramoverflow.go @@ -0,0 +1,9 @@ +package main + +var b [64 << 10]byte // 64kB + +func main() { + println("ptr:", &b[0]) +} + +// ERROR: program uses too much static RAM on this chip (RAM overflowed by {{[0-9]+}} bytes) diff --git a/testdata/errors/linker-undefined.go b/testdata/errors/linker-undefined.go new file mode 100644 index 000000000..fda2b623d --- /dev/null +++ b/testdata/errors/linker-undefined.go @@ -0,0 +1,11 @@ +package main + +func foo() + +func main() { + foo() + foo() +} + +// ERROR: linker-undefined.go:6: linker could not find symbol {{_?}}main.foo +// ERROR: linker-undefined.go:7: linker could not find symbol {{_?}}main.foo |