tinygo/builder
Ayke van Laethem 5792f3a1cf builder: improve accuracy of the -size=full flag
This commit improves accuracy of the -size=full flag in a big way.
Instead of relying on symbol names to figure out by which package
symbols belong, it will instead mostly use DWARF debug information
(specifically, debug line tables and debug information for global
variables) relying on symbols only for some specific things. This is
much more accurate: it also accounts for inlined functions.

For example, here is how it looked previously when compiling a personal
project:

     code  rodata    data     bss |   flash     ram | package
     1902     333       0       0 |    2235       0 | (bootstrap)
       46     256       0       0 |     302       0 | github
        0     454       0       0 |     454       0 | handleHardFault$string
      154      24       4       4 |     182       8 | internal/task
     2498      83       5    2054 |    2586    2059 | machine
        0      16      24     130 |      40     154 | machine$alloc
     1664      32      12       8 |    1708      20 | main
        0       0       0     200 |       0     200 | main$alloc
     2476      79       0      36 |    2555      36 | runtime
      576       0       0       0 |     576       0 | tinygo
     9316    1277      45    2432 |   10638    2477 | (sum)
    11208       -      48    6548 |   11256    6596 | (all)

And here is how it looks now:

     code  rodata    data     bss |   flash     ram | package
  ------------------------------- | --------------- | -------
     1509       0      12      23 |    1521      35 | (unknown)
      660       0       0       0 |     660       0 | C compiler-rt
       58       0       0       0 |      58       0 | C picolibc
        0       0       0    4096 |       0    4096 | C stack
      174       0       0       0 |     174       0 | device/arm
        6       0       0       0 |       6       0 | device/sam
      598     256       0       0 |     854       0 | github.com/aykevl/ledsgo
      320      24       0       4 |     344       4 | internal/task
     1414      99      24    2181 |    1537    2205 | machine
      726     352      12     208 |    1090     220 | main
     3002     542       0      36 |    3544      36 | runtime
      848       0       0       0 |     848       0 | runtime/volatile
       70       0       0       0 |      70       0 | time
      550       0       0       0 |     550       0 | tinygo.org/x/drivers/ws2812
  ------------------------------- | --------------- | -------
     9935    1273      48    6548 |   11256    6596 | total

There are some notable differences:

  * Odd packages like main$alloc and handleHardFault$string are gone,
    instead their code is put in the correct package.
  * C libraries and the stack are now included in the list, they were
    previously part of the (bootstrap) pseudo-package.
  * Unknown bytes are slightly reduced. It should be possible to reduce
    it significantly more in the future: most of it is now caused by
    interface invoke wrappers.
  * Inlined functions are now correctly attributed. For example, the
    runtime/volatile package is normally entirely inlined.
  * There is no difference between (sum) and (all) anymore. A better
    code size algorithm now counts the code/data sizes correctly.
  * And last (but not least) there is a stylistic change: the table now
    looks more like a table. Especially the summary should be clearer
    now.

Future goals:

  * Improve debug information so that the (unknown) pseudo-package is
    reduced in size or even eliminated altogether.
  * Add support for other file formats, most importantly WebAssembly.
  * Perhaps provide a way to expand this report per file, or in a
    machine-readable format like JSON or CSV.
2021-11-03 16:28:04 +01:00
..
ar.go cgo: add support for stdio in picolibc and wasi-libc 2021-10-26 17:08:30 +02:00
build.go builder: improve accuracy of the -size=full flag 2021-11-03 16:28:04 +01:00
buildcache.go builder: remove unused cacheKey parameter 2021-02-11 10:50:29 +01:00
builtins.go builder: make sure -fshort-enums is used consistently 2020-04-07 16:17:10 +02:00
cc.go builder: add missing error check for ioutil.TempFile() 2021-09-08 15:21:31 +02:00
cc1as.cpp all: switch to LLVM 11 for static builds 2020-12-10 07:01:32 +01:00
cc1as.h main: switch to LLVM 10 2020-04-09 20:23:51 +02:00
cc_test.go builder: cache C and assembly file outputs 2021-04-05 20:52:04 +02:00
clang.cpp all: switch to LLVM 11 for static builds 2020-12-10 07:01:32 +01:00
commands.go main: implement tinygo lldb subcommand 2021-10-05 06:26:21 +02:00
config.go main: test other architectures by specifying a different GOARCH 2021-10-04 18:22:55 +02:00
elfpatch.go rp2040: patch elf to checksum 2nd stage boot 2021-06-17 12:10:04 +02:00
env.go Make lib64 clang include path check more robust. 2020-11-04 00:04:33 +01:00
error.go compiler: add location information to the IR checker 2019-12-21 20:49:51 +01:00
esp.go esp32c3: add support for this chip 2021-09-16 20:13:04 +02:00
jobs.go builder: simplify running of jobs 2021-09-17 22:22:27 +02:00
library.go builder: simplify running of jobs 2021-09-17 22:22:27 +02:00
lld.cpp main: switch to LLVM 10 2020-04-09 20:23:51 +02:00
nrfutil.go support flashing pca10059 from windows 2021-06-08 14:17:04 +02:00
objcopy.go main: add initial support for (in-development) LLVM 11 2020-10-13 20:23:50 +02:00
picolibc.go cgo: add support for stdio in picolibc and wasi-libc 2021-10-26 17:08:30 +02:00
sizes.go builder: improve accuracy of the -size=full flag 2021-11-03 16:28:04 +01:00
tools-builtin.go builder: run tools (clang, ...) as separate processes 2020-04-03 12:41:44 +02:00
tools-external.go builder: run tools (clang, ...) as separate processes 2020-04-03 12:41:44 +02:00
tools.go main: implement tinygo lldb subcommand 2021-10-05 06:26:21 +02:00
uf2.go all: fix staticcheck warnings 2021-09-27 15:47:12 +02:00