Skip to content

compiler: add debug info to synthetic wrapper functions - #5747

Merged
deadprogram merged 1 commit into
devfrom
compiler-wrapper-dwarf
Sep 28, 2026
Merged

deadprogram merged 1 commit into
devfrom
compiler-wrapper-dwarf

Conversation

@deadprogram

Copy link
Copy Markdown
Member

This PR adds debug info to synthetic wrapper functions such as $bound, $thunk, and pointer receiver wrappers.

These functions have no syntax in Go SSA, so createFunction did not attach a subprogram to them. The wrapped method is often inlined into the wrapper, and that code then had no line table rows. Go SSA sets the position of these wrappers to the wrapped method, so this change uses that.

Test program using encoding/json and fmt, -target=wasm -opt=1 -scheduler=none, before wasm-opt:

before after
line coverage 97.7% 99.7%

The $typeassert, $invoke, and hashmapKey* functions still have no line info. They are generated without a source position and need a separate change.

For #5736

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Size difference with the dev branch:

Binary size difference
 flash                          ram
 before   after   diff          before   after   diff
  19884   19884      0   0.00%    7060    7060      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/adafruit4650
  63316   63316      0   0.00%    6860    6860      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adt7410/main.go
  11300   11300      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adxl345/main.go
  15460   15460      0   0.00%    7468    7468      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/amg88xx
  10516   10516      0   0.00%    5372    5372      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/main.go
  13188   13188      0   0.00%    7204    7204      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/apds9960/proximity/main.go
  12720   12720      0   0.00%    5384    5384      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/itsybitsy-m0/main.go
   8840    8840      0   0.00%    2320    2320      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/at24cx/main.go
  10004   10004      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bh1750/main.go
   9300    9300      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/blinkm/main.go
  71856   71856      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=pinetime     ./examples/bma42x/main.go
  67940   67940      0   0.00%    6828    6828      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmi160/main.go
  29140   29140      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp180/main.go
  66596   66596      0   0.00%    6860    6860      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp280/main.go
  13700   13700      0   0.00%    5444    5444      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bmp388/main.go
  24540   24540      0   0.00%    6300    6300      0   0.00% tinygo build -size short -o ./build/test.hex -target=metro-rp2350 ./examples/bno08x/i2c/main.go
   9256    9256      0   0.00%    3360    3360      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go
  22868   22868      0   0.00%    3592    3592      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go
  31248   31248      0   0.00%    5644    5644      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/alarms/main.go
  45136   45136      0   0.00%    5644    5644      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/basic/main.go
   4760    4760      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/main.go
   6976    6976      0   0.00%    2344    2344      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/async/main.go
  72952   72952      0   0.00%    7688    7688      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/flash/console/spi
  68808   68808      0   0.00%    9728    9728      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/flash/console/qspi
   7540    7540      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/gc9a01/main.go
  23684   23684      0   0.00%    8588    8588      0   0.00% tinygo build -size short -o ./build/test.bin -target=esp32-coreboard-v2 ./examples/gdew0154m09/main.go
  69800   69800      0   0.00%    7060    7060      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/i2c/main.go
  70304   70304      0   0.00%    7164    7164      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/uart/main.go
  10076   10076      0   0.00%    5436    5436      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/hcsr04/main.go
   5880    5880      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/customchar/main.go
   5960    5960      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/text/main.go
  12036   12036      0   0.00%    5396    5396      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/hd44780i2c/main.go
  16068   16068      0   0.00%    7204    7204      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/hts221/main.go
  16564   16564      0   0.00%    2428    2428      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go
  11620   11620      0   0.00%    7612    7612      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic
  14100   14100      0   0.00%    5572    5572      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/basic
  30972   30972      0   0.00%   38772   38772      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing
  11596   11596      0   0.00%    7612    7612      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll
  14124   14124      0   0.00%    5572    5572      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/scroll
 265908  265908      0   0.00%   47456   47456      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/slideshow
  12340   12340      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go
  15476   15476      0   0.00%    7204    7204      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/lps22hb/main.go
  26600   26600      0   0.00%    2328    2328      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/lsm303agr/main.go
  29748   29748      0   0.00%    7460    7460      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/lsm303dlhc/main.go
  13988   13988      0   0.00%    5420    5420      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/lsm6ds3/main.go
  12580   12580      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mag3110/main.go
  11356   11356      0   0.00%    5404    5404      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017/main.go
  11772   11772      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017-multiple/main.go
  11716   11716      0   0.00%    5372    5372      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp3008/main.go
  74380   74380      0   0.00%    6940    6940      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp2515/main.go
  30376   30376      0   0.00%    4152    4152      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/microbitmatrix/main.go
  30328   30328      0   0.00%    6196    6196      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit-v2 ./examples/microbitmatrix/main.go
  10052   10052      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mma8653/main.go
  10004   10004      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mpu6050/main.go
  79540   79540      0   0.00%    8092    8092      0   0.00% tinygo build -size short -o ./build/test.hex -target=p1am-100 ./examples/p1am/main.go
  15632   15632      0   0.00%    6240    6240      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/pca9685/main.go
   6676    6676      0   0.00%    3292    3292      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setbuffer/main.go
   5076    5076      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setpixel/main.go
  15376   15376      0   0.00%    6224    6224      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/seesaw/soil-sensor
  14992   14992      0   0.00%    6224    6224      0   0.00% tinygo build -size short -o ./build/test.hex -target=qtpy-rp2040 ./examples/seesaw/rotary-encoder
   2899    2899      0   0.00%     560     560      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/servo
  17208   17208      0   0.00%    6304    6304      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico     ./examples/sgp30
   9412    9412      0   0.00%    7412    7412      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/shifter/main.go
  58624   58624      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht3x/main.go
  58576   58576      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht4x/main.go
  58640   58640      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/shtc3/main.go
  14268   14268      0   0.00%    9092    9092      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao-ble ./examples/ssd1306/
  15072   15072      0   0.00%    6264    6264      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao-rp2040 ./examples/ssd1306/
  15008   15008      0   0.00%    6256    6256      0   0.00% tinygo build -size short -o ./build/test.hex -target=thumby ./examples/ssd1306/
   6372    6372      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1331/main.go
   7220    7220      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7735/main.go
   6916    6916      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7789/main.go
  18692   18692      0   0.00%    5364    5364      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/thermistor/main.go
  11956   11956      0   0.00%    5180    5180      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-bluefruit ./examples/tone
  11956   11956      0   0.00%    5364    5364      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/tm1637/main.go
  14212   14212      0   0.00%    6236    6236      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/touch/capacitive
  10764   10764      0   0.00%    7404    7404      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/fourwire/main.go
  13800   13800      0   0.00%    7672    7672      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/pyportal_touchpaint/main.go
  17132   17132      0   0.00%    5484    5484      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl53l1x/main.go
  15804   15804      0   0.00%    5484    5484      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl6180x/main.go
  26416   26416      0   0.00%   14368   14368      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840-sense ./examples/waveshare-epd/epd1in54/main.go
   6788    6788      0   0.00%    2324    2324      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13/main.go
   6468    6468      0   0.00%    2316    2316      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13x/main.go
   6660    6660      0   0.00%    2324    2324      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd4in2/main.go
  31024   31024      0   0.00%   19304   19304      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/waveshare-epd/epd2in66b/main.go
   8628    8628      0   0.00%    5404    5404      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/ws2812
   6122    6122      0   0.00%    8464    8464      0   0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-c3          ./examples/ws2812
  64636   64636      0   0.00%    6580    6580      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/is31fl3731/main.go
   1799    1799      0   0.00%     600     600      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino   ./examples/ws2812
   1280    1280      0   0.00%     182     182      0   0.00% tinygo build -size short -o ./build/test.hex -target=digispark ./examples/ws2812
   7776    7776      0   0.00%    8744    8744      0   0.00% tinygo build -size short -o ./build/test.bin -target=xiao-esp32c3 ./examples/ws2812
  33364   33364      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bme280/main.go
  18204   18204      0   0.00%    5348    5348      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/microphone/main.go
  12964   12964      0   0.00%    5364    5364      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/buzzer/main.go
  13924   13924      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/veml6070/main.go
   8388    8388      0   0.00%    5364    5364      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/simple/main.go
  10340   10340      0   0.00%    5364    5364      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/speed/main.go
   8372    8372      0   0.00%    5364    5364      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/simple/main.go
  10756   10756      0   0.00%    5364    5364      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/speed/main.go
   8180    8180      0   0.00%    3324    3324      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-f103rb ./examples/shiftregister/main.go
   7596    7596      0   0.00%    2288    2288      0   0.00% tinygo build -size short -o ./build/test.hex -target=hifive1b ./examples/ssd1351/main.go
  15156   15156      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis2mdl/main.go
  12852   12852      0   0.00%    5388    5388      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/max72xx/main.go
  79812   79812      0   0.00%    7008    7008      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/dht/main.go
  40012   40012      0   0.00%    6812    6812      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8523/
  72980   72980      0   0.00%    7048    7048      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/alarm/
   8980    8980      0   0.00%    5404    5404      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/clkout/
  67680   67680      0   0.00%    7044    7044      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/time/
  72820   72820      0   0.00%    7048    7048      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/timer/
  15584   15584      0   0.00%    6232    6232      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/qmi8658c/main.go
  14656   14656      0   0.00%    6224    6224      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8591/
  10500   10500      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina260/main.go
  14676   14676      0   0.00%    5412    5412      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina219/main.go
  10600   10600      0   0.00%    5280    5280      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-l432kc ./examples/aht20/main.go
  76268   76268      0   0.00%   11484   11484      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/sdcard/console/
  62788   62788      0   0.00%    8868    8868      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/i2csoft/adt7410/
  11620   11620      0   0.00%    7420    7420      0   0.00% tinygo build -size short -o ./build/test.elf -target=wioterminal ./examples/axp192/m5stack-core2-blinky/
  12332   12332      0   0.00%    6164    6164      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/xpt2046/main.go
  12464   12464      0   0.00%    4696    4696      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stack-core2 ./examples/ft6336/basic/
  20044   20044      0   0.00%    4964    4964      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stack-core2 ./examples/ft6336/touchpaint/
  14416   14416      0   0.00%    5060    5060      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/sx126x/lora_rxtx/
  46784   46784      0   0.00%    9584    9584      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/sx127x/lora_rxtx/
  37160   37160      0   0.00%    7944    7944      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/ssd1289/main.go
  15088   15088      0   0.00%    7216    7216      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/irremote/main.go
  15352   15352      0   0.00%    6248    6248      0   0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/uc8151/main.go
  15752   15752      0   0.00%    6684    6684      0   0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/waveshare-epd/epd2in9v2/main.go
  17364   17364      0   0.00%    6276    6276      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd30/main.go
  13680   13680      0   0.00%    6252    6252      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd4x/main.go
   9532    9532      0   0.00%    5364    5364      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=circuitplay-express ./examples/makeybutton/main.go
  11236   11236      0   0.00%    5388    5388      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ds18b20/main.go
 125236  125236      0   0.00%    8448    8448      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/lora/lorawan/atcmd/
  19932   19932      0   0.00%    7820    7820      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/as560x/main.go
  15328   15328      0   0.00%    6224    6224      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu6886/main.go
   9412    9412      0   0.00%    5364    5364      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ttp229/main.go
  70928   70928      0   0.00%    7712    7712      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ndir/main_ndir.go
  63272   63272      0   0.00%    3792    3792      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ndir/main_ndir.go
  67652   67652      0   0.00%    6900    6900      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ndir/main_ndir.go
  13136   13136      0   0.00%    6216    6216      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu9150/main.go
  15036   15036      0   0.00%    6284    6284      0   0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/sh1106/macropad_spi
  11752   11752      0   0.00%    6664    6664      0   0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/encoders/quadrature-interrupt
  69328   69328      0   0.00%    7672    7672      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mcp9808/main.go
  46856   46856      0   0.00%    8328    8328      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/tmc2209/main.go
  15196   15196      0   0.00%    6172    6172      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/tmc5160/main.go
  13912   13912      0   0.00%    5168    5168      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=nicenano ./examples/sharpmem/main.go
  63648   63648      0   0.00%    6608    6608      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/max6675/main.go
  15968   15968      0   0.00%    6232    6232      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ens160/main.go
  19864   19864      0   0.00%    6336    6336      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/si5351/main.go
  24904   24904      0   0.00%    7584    7584      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/w5500/main.go
  92048   92048      0   0.00%    7964    7964      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/sd
  90996   90996      0   0.00%    8116    8116      0   0.00% tinygo build -size short -o ./build/test.hex -target=challenger-rp2040 ./examples/net/ntpclient/
 378472  378472      0   0.00%   14856   14856      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal -stack-size 8kb ./examples/net/http-get/
 126236  126236      0   0.00%    9056    9056      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 -stack-size 8kb ./examples/net/tcpclient/
 358188  358188      0   0.00%   13552   13552      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/websocket/dial/
 108192  108192      0   0.00%   11036   11036      0   0.00% tinygo build -size short -o ./build/test.hex -target=metro-m4-airlift -stack-size 8kb ./examples/net/socket/
 426000  426000      0   0.00%   17532   17532      0   0.00% tinygo build -size short -o ./build/test.hex -target=matrixportal-m4 -stack-size 8kb ./examples/net/webstatic/
 172168  172168      0   0.00%    9216    9216      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-mkrwifi1010 -stack-size 8kb ./examples/net/tlsclient/
 163516  163516      0   0.00%   10020   10020      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/mqttclient/natiu/
 122252  122252      0   0.00%   14348   14348      0   0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webclient/
 374444  374444      0   0.00%   19996   19996      0   0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webserver/
 373068  373068      0   0.00%   19056   19056      0   0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/mqttclient/paho/
 180256  180256      0   0.00%   12496   12496      0   0.00% tinygo build -size short -o ./build/test.hex -target=elecrow-rp2040 -stack-size 8kb ./examples/net/tlsclient/
 126540  126540      0   0.00%   12332   12332      0   0.00% tinygo build -size short -o ./build/test.hex -target=elecrow-rp2350 -stack-size 8kb ./examples/net/ntpclient/
7020684 7020684      0   0.00% 1115126 1115126      0   0.00%

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new debug metadata behavior needs regression tests for each supported wrapper type.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds debug metadata to synthetic Go SSA wrappers, improving DWARF line coverage for issue #5736.

Changes:

  • Creates subprogram metadata for positioned synthetic wrappers.
  • Uses the wrapped method’s source file and line.
File Description
compiler/​compiler.go Attaches debug information to synthetic wrapper functions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread compiler/compiler.go
@soypat

soypat commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I fired a netbird build with this commit, so around 3 hours until I have before/after results of this

@soypat

soypat commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Ended up compiling with -gc=leaking which seems to compile faster. I have the following diff:

bindiff -kind package diff ./wasm/netbird-debug-dev.wasm ./wasm/netbird-leaking.wasm 
KIND     NAME                  OLD        NEW      DELTA         
package  [unattributed]   30861115   31740582    +879467    +2.8%
TOTAL                     44139249   45018716    +879467    +2.0%

The binary grew compared with dev, specifically the unattributed part?

Edit: bindiff from this PR

@deadprogram

Copy link
Copy Markdown
Member Author

The binary grew compared with dev, specifically the unattributed part?

I think that is correct. This PR is only for the synthetic functions. The missing debug data for the "normal" functions you had reported was handled in PR #5746

@deadprogram

Copy link
Copy Markdown
Member Author

Any other feedback or comment on this PR?

@deadprogram

deadprogram commented Sep 28, 2026 •

Copy link
Copy Markdown
Member Author

@soypat are we good on this one? (after squashing the commits)

@soypat

soypat commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

I don't think I'm the person to review this. I don't understand the code additions and my way of testing it yielded worse coverage 🤷

@deadprogram
deadprogram force-pushed the compiler-wrapper-dwarf branch from 0bc6b06 to 57c5162 Compare September 28, 2026 13:09
@deadprogram

Copy link
Copy Markdown
Member Author

@soypat thanks for testing. Here is an edited version of my latest automated testing.

I think the -kind package diff makes this look worse than it is.

  1. Seems like your test ran on 2026-09-25, before builder: add debug info to runtime.initAll #5746 was merged, so it did not include the runtime.initAll fix. I have now rebased this branch onto current dev and squashed it into one commit.

  2. -kind package groups bytes by function name, not by line table. The .debug_* sections have no symbols, so they all go to [unattributed]. This PR adds line table rows, so those sections get bigger and [unattributed] grows. That is expected. The code section size is the same.

On my local machine I rebuilt a small encoding/json + fmt program with current dev, with and without this PR (-target=wasm -opt=1 -gc=leaking, wasm-opt left on), and ran it through your bindiff from soypat/tinyboot#5.

bindiff -kind section diff, -scheduler=asyncify:

section  .debug_line         486966     500741     +13775    +2.8%
section  .debug_info         519719     532736     +13017    +2.5%
section  .debug_loc          464794     476470     +11676    +2.5%
section  .debug_pubnames     233783     237696      +3913    +1.7%
section  .debug_str          174694     178298      +3604    +2.1%
section  .debug_ranges        43888      45568      +1680    +3.8%
section  .debug_abbrev         4334       4402        +68    +1.6%
section  .debug_pubtypes      10261      10279        +18    +0.2%
TOTAL                       3088461    3136212     +47751    +1.5%

[unattributed] code from bindiff -kind file profile, meaning code bytes with no line info:

scheduler code size dev this PR
asyncify 1019649 265049 (26.0%) 233414 (22.9%)
none 483187 61024 (12.6%) 35438 (7.3%)

So -kind file is the one to use for line table coverage. The rest of the asyncify gap comes from Binaryen, as noted above.

In summary, it does seem to improve the debug info for the part that this PR is intended to.

Wrappers like $bound, $thunk, and pointer receiver wrappers have no
syntax, so they got no subprogram. Code inlined into them then had no
line info. Use the position of the wrapped method instead.

For #5736
@deadprogram
deadprogram force-pushed the compiler-wrapper-dwarf branch from 57c5162 to 291fb11 Compare September 28, 2026 13:19
@deadprogram

Copy link
Copy Markdown
Member Author

@soypat soypat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, given those numbers looks like a welcome addition!

@deadprogram

Copy link
Copy Markdown
Member Author

Thank you @soypat now merging.

@deadprogram
deadprogram merged commit ce8e1ee into dev Sep 28, 2026
39 checks passed
@deadprogram
deadprogram deleted the compiler-wrapper-dwarf branch September 28, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants