Skip to content

compiler: implement method-set based AssignableTo and Implements#5304

Merged
deadprogram merged 15 commits intotinygo-org:devfrom
jakebailey:reflect-assignableto
Apr 17, 2026
Merged

compiler: implement method-set based AssignableTo and Implements#5304
deadprogram merged 15 commits intotinygo-org:devfrom
jakebailey:reflect-assignableto

Conversation

@jakebailey
Copy link
Copy Markdown
Member

@jakebailey jakebailey commented Apr 14, 2026

Fixes #4277
Fixes #3580
Fixes #4873
Closes #4375
Closes #4376
Updates #4894

Based on the design from #4375/#4376 by @aykevl; I've Co-authored-by it since it's obviously based on those changes. There were just a couple of bugs in it that I found, e.g. offsetting in structType as its length is actually dynamic.

In my testing, this increases binary sizes by about 2%; I did not see the 4% as in the other PR, but perhaps its down to which binary is being used? More like 1-1.5%ish (it depends). Even less! See #5304 (comment)

But it does enable full AssignableTo/Implements and eliminates OptimizeReflectImplements.

This allows typescript-go to work with go-json-experiment.

I believe that this can also be used to implement #3862.

Based on the design from tinygo-org#4376 by aykevl.
Fixes tinygo-org#4277, fixes tinygo-org#3580.

Co-authored-by: Ayke van Laethem <aykevanlaethem@gmail.com>
@deadprogram
Copy link
Copy Markdown
Member

From one of my more intensive programs in the upcoming release:

Current dev branch:

$ tinygo flash -target xiao-esp32c3 -ldflags="-X main.ssid=ssid -X main.password=passwordy" -monitor -size short ./webserver
   code    data     bss |   flash     ram
 955276   37396  364258 |  992672  401654

With this PR:

$ tinygo flash -target xiao-esp32c3 -ldflags="-X main.ssid=ssid -X main.password=passwordy" -monitor -size short ./webserver
   code    data     bss |   flash     ram
 976848   37404  390550 | 1014252  427954

So code size 976848 vs 955276 and ram usage 427954 vs 401654

That is a considerable increase for an embedded device!

@jakebailey
Copy link
Copy Markdown
Member Author

Hm, that is about the 2% I was quoting (2.26%).

@dgryski had suggested a mode that disables some of this information. But in my testing, the method lists are only half the cost, the other half being borne by adding the method pointers to the types.

I'm not sure what the right tradeoff is here. This number seems pretty worth it to me given what it unbreaks?

I can brainstorm reintroducing sort of DCE or something, not emitting this if reflect is not imported, maybe? Or if certain methods are unused? I don't have an example where these criteria would be met, so having a test case would be helpful.

@jakebailey
Copy link
Copy Markdown
Member Author

I have a more complicated optimization on top of this PR which eliminates typeImplementsMethodSet for non-reflect uses, copying $invoke's pattern. Doing that allows DCEing typeImplementsMethodSet and therefore we can drop all of the new data if typeImplementsMethodSet becomes unreferenced.

For these examples:

"minimal"
package main

type Stringer interface {
	String() string
}

type MyType struct{ Name string }

func (m MyType) String() string { return m.Name }

func main() {
	var x interface{} = MyType{Name: "hello"}
	if s, ok := x.(Stringer); ok {
		println("yes:", s.String())
	} else {
		println("no")
	}
}
"fmt.Println"
package main

import "fmt"

type Stringer interface {
	String() string
}

type MyType struct {
	Name string
}

func (m MyType) String() string {
	return m.Name
}

func main() {
	var x interface{} = MyType{Name: "hello"}
	if s, ok := x.(Stringer); ok {
		fmt.Println("implements Stringer:", s.String())
	} else {
		fmt.Println("does not implement Stringer")
	}

	var y interface{} = 42
	if _, ok := y.(Stringer); ok {
		fmt.Println("int implements Stringer")
	} else {
		fmt.Println("int does not implement Stringer")
	}
}
"encoding/json"
package main

import (
	"encoding/json"
	"fmt"
)

type Person struct {
	Name string `json:"name"`
	Age  int    `json:"age"`
}

func main() {
	data := []byte(`{"name":"Alice","age":30}`)
	var p Person
	err := json.Unmarshal(data, &p)
	if err != nil {
		fmt.Println("error:", err)
		return
	}
	fmt.Println(p.Name, p.Age)
}

With Wasm, measuring bytes:

minimal fmt.Println encoding/json
dev baseline 20,698 163,698 471,299
PR 21,067 (+1.8%) 168,867 (+3.2%) 481,681 (+2.2%)
PR + opt 20,463 (-1.1%) 167,839 (+2.5%) 481,413 (+2.1%)

So, I end up actually getting smaller.

I'll push this up, but I still need some sort of test case to look at if this is not helping your case.

@deadprogram
Copy link
Copy Markdown
Member

Pulled the latest commit in this PR:

$ tinygo flash -target xiao-esp32c3 -ldflags="-X main.ssid=ssid -X main.password=passwordy" -monitor -size short ./webserver
   code    data     bss |   flash     ram
 982066   37396  390442 | 1019462  427838

So it got a bit bigger.

@jakebailey
Copy link
Copy Markdown
Member Author

That... doesn't make any sense 😄

Do you have some code I can test?

@deadprogram
Copy link
Copy Markdown
Member

This is the code I am building:
https://github.com/tinygo-org/tinygo-xiao-examples/tree/main/webserver

Using dev branch:

$ tinygo build -o webserver.bin -target xiao-esp32c3 -size full ./webserver
   code  rodata    data     bss |   flash     ram | package
------------------------------- | --------------- | -------
      0     111       7      14 |     118      21 | (padding)
  20772   22996    1426  181908 |   45194  183334 | (unknown)
    282      49       0       0 |     331       0 | /home/ron/.gvm/go/src/crypto
   3128     804       0      12 |    3932      12 | /home/ron/.gvm/go/src/crypto/x509
   1038     512       0       0 |    1550       0 | /home/ron/.gvm/go/src/unicode
   1536    4256       0       0 |    5792       0 | C picolibc
      0       0       0    4096 |       0    4096 | C stack
   5866       0       0       0 |    5866       0 | Go interface assert
  16986       0       0       0 |   16986       0 | Go interface method
      0   28488       0       0 |   28488       0 | Go types
   2738     225      32       0 |    2995      32 | bufio
   3670     198       8       0 |    3876       8 | bytes
    500       0       0       0 |     500       0 | cmp
    290      40       0       0 |     330       0 | context
      0      41       0       0 |      41       0 | crypto
      0       6       0       0 |       6       0 | crypto/ecdh
     20      11      24       1 |      55      25 | crypto/fips140
     24      77       0       0 |     101       0 | crypto/internal/entropy/v1.0.0
    404     242       0       2 |     646       2 | crypto/internal/fips140
   8174    8918       0       0 |   17092       0 | crypto/internal/fips140/aes
   3262      10       0       0 |    3272       0 | crypto/internal/fips140/aes/gcm
    104       0       0       0 |     104       0 | crypto/internal/fips140/alias
      0       9       0       0 |       9       0 | crypto/internal/fips140/check
   2630       8      20       4 |    2658      24 | crypto/internal/fips140/drbg
   1860     135       0       0 |    1995       0 | crypto/internal/fips140/hmac
      0      84     389     688 |     473    1077 | crypto/internal/fips140/rsa
   2760     354       0       0 |    3114       0 | crypto/internal/fips140/sha256
  15614     389       0       0 |   16003       0 | crypto/internal/fips140/sha3
   4626     783       0       0 |    5409       0 | crypto/internal/fips140/sha512
    242      78       0       0 |     320       0 | crypto/internal/fips140/subtle
    748       0       0       0 |     748       0 | crypto/internal/fips140deps/byteorder
     28       0       0       0 |      28       0 | crypto/internal/fips140deps/godebug
     40       0       0       0 |      40       0 | crypto/internal/fips140only
    506     165       0      16 |     671      16 | crypto/internal/sysrand
   3812     147       0       0 |    3959       0 | crypto/md5
   2126     169       0       0 |    2295       0 | crypto/sha1
    226       0       0       0 |     226       0 | crypto/sha3
      0    2317     602       0 |    2919     602 | crypto/x509
   2960     105     256     280 |    3321     536 | crypto/x509/pkix
    504       0       0       0 |     504       0 | device/esp
    586       0       0       0 |     586       0 | device/riscv
   8870    1028      20       0 |    9918      20 | encoding/asn1
    386     362       0       0 |     748       0 | encoding/base64
     46       0       0       0 |      46       0 | encoding/binary
     98       0       0       0 |      98       0 | encoding/hex
  21290    1165      20      28 |   22475      48 | encoding/json
    774      21       8       0 |     803       8 | errors
  14590     219      20       0 |   14829      20 | fmt
    216     372       0       0 |     588       0 | github.com/soypat/lneto
    118      86       0       0 |     204       0 | github.com/soypat/lneto/dhcpv4
   1734     267       0       0 |    2001       0 | github.com/soypat/lneto/dns
    100     352      40     736 |     492     776 | github.com/soypat/lneto/ethernet
   1580     221      24       0 |    1825      24 | github.com/soypat/lneto/internal
     88      41       0      24 |     129      24 | github.com/soypat/lneto/ntp
   7072     488      24       0 |    7584      24 | github.com/soypat/lneto/tcp
   2200      67       0       0 |    2267       0 | github.com/soypat/lneto/udp
   1052      70       0       0 |    1122       0 | github.com/soypat/lneto/x/xnet
    134       0      20      25 |     154      45 | hash/crc32
   1076      30       0       0 |    1106       0 | internal/bytealg
    958       0       0       0 |     958       0 | internal/byteorder
   1006      21       0       0 |    1027       0 | internal/fmtsort
    550     125       0      16 |     675      16 | internal/godebug
     84     915    1728       0 |    2727    1728 | internal/godebugs
    188       0       0       0 |     188       0 | internal/itoa
      0      38      16       0 |      54      16 | internal/oserror
  13878    1293      48       0 |   15219      48 | internal/reflectlite
   9728   14131       0       0 |   23859       0 | internal/strconv
    820       0       0       0 |     820       0 | internal/stringslite
    782      86       0       4 |     868       4 | internal/task
   2476      83      60       0 |    2619      60 | io
     50       0       0       0 |      50       0 | io/fs
   2676       3      20      36 |    2699      56 | log
  11194     592      40       0 |   11826      40 | log/slog
    464       0      20       0 |     484      20 | log/slog/internal/buffer
   3172      29     196     131 |    3397     327 | machine
    178      21       0       4 |     199       4 | main
     64       0       0       0 |      64       0 | maps
    118       0       0       0 |     118       0 | math
  21196     415       4    1308 |   21615    1312 | math/big
   4946       0       0       0 |    4946       0 | math/bits
      0    1075     552    2240 |    1627    2792 | mime
    978      75       0      72 |    1053      72 | mime/multipart
   1008     138       4       0 |    1150       4 | mime/quotedprintable
   2628      94       8       0 |    2730       8 | net
  13286    3128    1885     584 |   18299    2469 | net/http
   1798     242       9       0 |    2049       9 | net/http/internal
     44       0       0       0 |      44       0 | net/http/internal/ascii
   7102     808       0       8 |    7910       8 | net/netip
   4270     453      10      16 |    4733      26 | net/textproto
   4764     555      24       0 |    5343      24 | net/url
   1460     100      48       0 |    1608      48 | os
      0       0       0       0 |       0       0 | path
    610       0       0       0 |     610       0 | reflect
  12172     350       4      62 |   12526      66 | runtime
    778     177       0       0 |     955       0 | runtime/interrupt
    898       0       0       0 |     898       0 | runtime/volatile
  24304      18       0       0 |   24322       0 | slices
   3500    2116    1354       0 |    6970    1354 | strconv
   4802     247       0       0 |    5049       0 | strings
   2204       0       0       0 |    2204       0 | sync
    512       0       0       1 |     512       1 | sync/atomic
     58       6       0       0 |      64       0 | syscall
  20754    1015      72      88 |   21841     160 | time
      0      17       8       0 |      25       8 | tinygo.org/x/drivers/netlink
   1184       0       0       0 |    1184       0 | tinygo.org/x/drivers/ssd1306
    504     527       0     384 |    1031     384 | tinygo.org/x/espradio
     24       0       0       0 |      24       0 | tinygo.org/x/espradio/esp32c3
     20       0       0       0 |      20       0 | tinygo.org/x/espradio/netlink
    524       0       0       1 |     524       1 | tinygo.org/x/tinyfont
      0       0    2712       1 |    2712    2713 | tinygo.org/x/tinyfont/proggy
   1492    1080       0       0 |    2572       0 | tinygo.org/x/tinyterm
      0     372   19338       0 |   19710   19338 | unicode
   1958     288       0       0 |    2246       0 | unicode/utf8
    386       0       0      12 |     386      12 | unique
    398     413     208     336 |    1019     544 | vendor/golang.org/x/net/http/httpguts
     72      22       0       0 |      94       0 | vendor/golang.org/x/net/idna
------------------------------- | --------------- | -------
 358506  107584   31308  193138 |  497398  224446 | total

Using this branch:

$ tinygo build -o webserver.bin -target xiao-esp32c3 -size full ./webserver
   code  rodata    data     bss |   flash     ram | package
------------------------------- | --------------- | -------
      0      88       7      14 |      95      21 | (padding)
  20820   43665    1426  207728 |   65911  209154 | (unknown)
   5910       0       0       0 |    5910       0 | .
    282      85       0       0 |     367       0 | /home/ron/.gvm/go/src/crypto
   3128     898       0      12 |    4026      12 | /home/ron/.gvm/go/src/crypto/x509
   1038     512       0       0 |    1550       0 | /home/ron/.gvm/go/src/unicode
   1536    4256       0       0 |    5792       0 | C picolibc
      0       0       0    4096 |       0    4096 | C stack
  17136       0       0       0 |   17136       0 | Go interface method
      0   33668       0       0 |   33668       0 | Go types
   2738     225      32       0 |    2995      32 | bufio
   3606     198       8       0 |    3812       8 | bytes
    500       0       0       0 |     500       0 | cmp
    290      40       0       0 |     330       0 | context
      0      14       0       0 |      14       0 | crypto
      0       6       0       0 |       6       0 | crypto/ecdh
     20       7      24       1 |      51      25 | crypto/fips140
     24      77       0       0 |     101       0 | crypto/internal/entropy/v1.0.0
    404     246       0       2 |     650       2 | crypto/internal/fips140
   8174    8935       0       0 |   17109       0 | crypto/internal/fips140/aes
   3262      10       0       0 |    3272       0 | crypto/internal/fips140/aes/gcm
    104       0       0       0 |     104       0 | crypto/internal/fips140/alias
      0       9       0       0 |       9       0 | crypto/internal/fips140/check
   2630       8      20       4 |    2658      24 | crypto/internal/fips140/drbg
   1860     135       0       0 |    1995       0 | crypto/internal/fips140/hmac
      0      75     389     688 |     464    1077 | crypto/internal/fips140/rsa
   2760     354       0       0 |    3114       0 | crypto/internal/fips140/sha256
  15614     389       0       0 |   16003       0 | crypto/internal/fips140/sha3
   4626     775       0       0 |    5401       0 | crypto/internal/fips140/sha512
    242      78       0       0 |     320       0 | crypto/internal/fips140/subtle
    748       0       0       0 |     748       0 | crypto/internal/fips140deps/byteorder
     28       0       0       0 |      28       0 | crypto/internal/fips140deps/godebug
     40       0       0       0 |      40       0 | crypto/internal/fips140only
    506     165       0      16 |     671      16 | crypto/internal/sysrand
   3812     147       0       0 |    3959       0 | crypto/md5
   2126     160       0       0 |    2286       0 | crypto/sha1
    226       0       0       0 |     226       0 | crypto/sha3
      0    2226     602       0 |    2828     602 | crypto/x509
   2960     106     256     280 |    3322     536 | crypto/x509/pkix
    504       0       0       0 |     504       0 | device/esp
    586       0       0       0 |     586       0 | device/riscv
   8870    1028      20       0 |    9918      20 | encoding/asn1
    386     362       0       0 |     748       0 | encoding/base64
     46       0       0       0 |      46       0 | encoding/binary
     98       0       0       0 |      98       0 | encoding/hex
  21488    1292      20      28 |   22800      48 | encoding/json
    774      21       8       0 |     803       8 | errors
  14590     226      20       0 |   14836      20 | fmt
    216     372       0       0 |     588       0 | github.com/soypat/lneto
    118      86       0       0 |     204       0 | github.com/soypat/lneto/dhcpv4
   1734     263       0       0 |    1997       0 | github.com/soypat/lneto/dns
    100     357      40     736 |     497     776 | github.com/soypat/lneto/ethernet
   1580     221      24       0 |    1825      24 | github.com/soypat/lneto/internal
     88      48       0      24 |     136      24 | github.com/soypat/lneto/ntp
   7072     489      24       0 |    7585      24 | github.com/soypat/lneto/tcp
   2200      67       0       0 |    2267       0 | github.com/soypat/lneto/udp
   1052      70       0       0 |    1122       0 | github.com/soypat/lneto/x/xnet
    134       0      20      25 |     154      45 | hash/crc32
   1076      30       0       0 |    1106       0 | internal/bytealg
    958       0       0       0 |     958       0 | internal/byteorder
   1006      21       0       0 |    1027       0 | internal/fmtsort
    550     125       0      16 |     675      16 | internal/godebug
     84     900    1728       0 |    2712    1728 | internal/godebugs
    188       0       0       0 |     188       0 | internal/itoa
      0      38      16       0 |      54      16 | internal/oserror
  14202    1206      48       0 |   15456      48 | internal/reflectlite
   9728   14106       0       0 |   23834       0 | internal/strconv
    820       0       0       0 |     820       0 | internal/stringslite
    782      86       0       4 |     868       4 | internal/task
   2476      83      60       0 |    2619      60 | io
     50       0       0       0 |      50       0 | io/fs
   2676       3      20      36 |    2699      56 | log
  11194     634      40       0 |   11868      40 | log/slog
    464       0      20       0 |     484      20 | log/slog/internal/buffer
   3172      29     196     131 |    3397     327 | machine
    178      22       0       4 |     200       4 | main
     64       0       0       0 |      64       0 | maps
    118       0       0       0 |     118       0 | math
  21196     418       4    1308 |   21618    1312 | math/big
   4946       0       0       0 |    4946       0 | math/bits
      0    1075     552    2240 |    1627    2792 | mime
    978      76       0      72 |    1054      72 | mime/multipart
   1008     138       4       0 |    1150       4 | mime/quotedprintable
   2628      92       8       0 |    2728       8 | net
  13288    3083    1885     592 |   18256    2477 | net/http
   1804     242       9       0 |    2055       9 | net/http/internal
     44       0       0       0 |      44       0 | net/http/internal/ascii
   7102     792       0       8 |    7894       8 | net/netip
   4270     473      10      16 |    4753      26 | net/textproto
   4764     572      24       0 |    5360      24 | net/url
   1460     100      48       0 |    1608      48 | os
      0       0       0       0 |       0       0 | path
    614       0       0       0 |     614       0 | reflect
  12172     346       4      62 |   12522      66 | runtime
    778     177       0       0 |     955       0 | runtime/interrupt
    898       0       0       0 |     898       0 | runtime/volatile
  24304       0       0       0 |   24304       0 | slices
   3500    2116    1354       0 |    6970    1354 | strconv
   4796     247       0       0 |    5043       0 | strings
   2204       0       0       0 |    2204       0 | sync
    514       0       0       1 |     514       1 | sync/atomic
     58       6       0       0 |      64       0 | syscall
  20754     977      72      88 |   21803     160 | time
      0      17       8       0 |      25       8 | tinygo.org/x/drivers/netlink
   1184       0       0       0 |    1184       0 | tinygo.org/x/drivers/ssd1306
    504     527       0     384 |    1031     384 | tinygo.org/x/espradio
     24       0       0       0 |      24       0 | tinygo.org/x/espradio/esp32c3
     20       0       0       0 |      20       0 | tinygo.org/x/espradio/netlink
    524       0       0       1 |     524       1 | tinygo.org/x/tinyfont
      0       0    2712       1 |    2712    2713 | tinygo.org/x/tinyfont/proggy
   1492    1079       0       0 |    2571       0 | tinygo.org/x/tinyterm
      0     372   19338       0 |   19710   19338 | unicode
   1958     288       0       0 |    2246       0 | unicode/utf8
    386       0       0      12 |     386      12 | unique
    398     435     208     336 |    1041     544 | vendor/golang.org/x/net/http/httpguts
     72      22       0       0 |      94       0 | vendor/golang.org/x/net/idna
------------------------------- | --------------- | -------
 359214  133412   31308  218966 |  523934  250274 | total

@jakebailey jakebailey force-pushed the reflect-assignableto branch from 33b58a0 to 1b13c9f Compare April 15, 2026 21:15
@jakebailey
Copy link
Copy Markdown
Member Author

on your example, I think it's now at:

        code    data     bss |   flash     ram
 dev: 466090   31308  193138 |  497398  224446
 PR:  477010   31308  203414 |  508318  234722

@deadprogram
Copy link
Copy Markdown
Member

Interestingly, if I include the needed vars it increases the RAM size which is the number I am thinking about overall, not specific to this PR. The optimizer eliminated a bunch of code that is needed for the device to function. I added them back into the build command:

dev:

$ tinygo build -o webserver.bin -target xiao-esp32c3 -ldflags="-X main.ssid=rems -X main.password=Salvador1" -size short ./webserver
   code    data     bss |   flash     ram
 955276   37396  364258 |  992672  401654

Current PR branch:

$ tinygo build -o webserver.bin -target xiao-esp32c3 -ldflags="-X main.ssid=ssid -X main.password=passwordy" -size short ./webserver
   code    data     bss |   flash     ram
 966450   37396  374786 | 1003846  412182

On this example, an increase of 10528 bytes eg around 2.6%.

@jakebailey
Copy link
Copy Markdown
Member Author

I have another very tricky change I that omits this info entirely from types without methods; I'll have numbers on that once I finish testing 😄

@jakebailey
Copy link
Copy Markdown
Member Author

jakebailey commented Apr 16, 2026

My trick shaves off about 3.8K in flash, 3.6K in RAM (so far), though it's a bit sketchy given it means these type objects differ in their actual size depending on whether or not they have methods (using the high bit on numMethods to indicate whether methods exists).

I'm not sure what bar you have for this.

@jakebailey
Copy link
Copy Markdown
Member Author

jakebailey commented Apr 16, 2026

I was able to shave a bit more off. I have other ideas to go further but it's getting increasingly complex.

@deadprogram
Copy link
Copy Markdown
Member

Current size:

$ tinygo build -o webserver.bin -target xiao-esp32c3 -ldflags="-X main.ssid=ssid -X main.password=passwordy" -size short ./webserver
   code    data     bss |   flash     ram
 961646   37396  369862 |  999042  407258

That is down to a 1.4% memory size increase for what unlocks a lot of code compatibility. IMO we're now in range of "worth it". I have not actually looked at the code changes yet @jakebailey but given the value of this addition vs. the memory cost seems like we should probably do it.

I do not want to dissuade you from seeking further optimizations, of course. 😸

@deadprogram
Copy link
Copy Markdown
Member

@jakebailey
Copy link
Copy Markdown
Member Author

Yeah, I keep forgetting to fix these committed ll files; will fix that in the morning (and see what else is left)

@dgryski
Copy link
Copy Markdown
Member

dgryski commented Apr 16, 2026

I'll review this tomorrow.

@jakebailey
Copy link
Copy Markdown
Member Author

Couldn't help myself, so, got it passing now before I fall asleep 😅

Comment thread GNUmakefile
@jakebailey
Copy link
Copy Markdown
Member Author

Going through the rest of my ideas, they are all pretty invasive or have other bad effects. I think what's here is probably enough.

I of course had to slap a lot of stuff on top of my original change to make this acceptable, so hopefully those changes are alright.

Comment thread compiler/interface.go Outdated
Copy link
Copy Markdown
Member

@deadprogram deadprogram left a comment

Choose a reason for hiding this comment

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

I am not the real expert in this part of the code, but have looked it over a few times, and tested it out. IMO we can squash/merge.

@dgryski I will of course defer to your expertise here. @aykevl as well, if either one of you wish to comment.

Copy link
Copy Markdown
Member

@dgryski dgryski left a comment

Choose a reason for hiding this comment

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

LGTM

🎉

@dgryski
Copy link
Copy Markdown
Member

dgryski commented Apr 16, 2026

@aykevl Unless you have some objections, I think we should merge this.

@deadprogram
Copy link
Copy Markdown
Member

Last call for feedback before squash/merge!

@deadprogram deadprogram added this to the 0.41.0 milestone Apr 17, 2026
@aykevl
Copy link
Copy Markdown
Member

aykevl commented Apr 17, 2026

I'll try to take a look soon!

@deadprogram
Copy link
Copy Markdown
Member

I ran the imports script to test the difference between this branch and the current dev branch:

Package Importable (dev) Tests (dev) Importable (PR) Tests (PR)
errors ✔ yes ✗ no ✔ yes ✔ yes
go/token ✔ yes ✗ no ✔ yes ✔ yes
net/url ✔ yes ✗ no ✔ yes ✔ yes

Three more packages in the stdlib are now passing tests! 🥳

@jakebailey
Copy link
Copy Markdown
Member Author

Ah, I will add errors to the list!

Copy link
Copy Markdown
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

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

Read through the PR, and looks good to me!
The binary size increase is unfortunate, but considering that this feature is kinda important for a lot of people I think it's worth it.

Comment thread compiler/interface.go
Comment on lines +893 to +897
value = llvm.AddGlobal(c.mod, c.ctx.Int8Type(), globalName)
value.SetInitializer(llvm.ConstNull(c.ctx.Int8Type()))
value.SetGlobalConstant(true)
value.SetLinkage(llvm.LinkOnceODRLinkage)
value.SetAlignment(1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There might be ways to optimize this, since all it really needs is unique IDs.
Also, might be worth adding debug info for this (can be done in the future) so that -size=full correctly attributes the data used for this.

Anyway, just ideas for the future it looks good enough for now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, so I did think about using IDs, but there were some challenges that made me not do that. Namely that I wasn't sure that it would be easy to DCE because with the pointers, at least I think the LLVM stack knows when something is unused, but with the IDs, not so much?

For the debug info, I think I could try and do that quick, but if you don't mind it later I'm happy to wait (not sure if there's any rebasing or something needed for this PR or if it's going to just get squashed).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, adding the debug info is acutally very easy, it's effectively just copy-paste from getTypeCode

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@aykevl
Copy link
Copy Markdown
Member

aykevl commented Apr 17, 2026

Since the sizediff CI test couldn't make a comment here, I've copied over the text myself. See below. Binary size is either the same as before, or about 0.3-0.5% increase which I consider entirely acceptable. The overall difference over all tests is 0.22% which is not bad at all!

Thanks for working on these optimizations! This is indeed roughly what I had in mind, but it's a bit tricky to implement correctly.

Size difference
 flash                          ram
 before   after   diff          before   after   diff
   8764    8764      0   0.00%    5088    5088      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adxl345/main.go
  13636   13636      0   0.00%    7136    7136      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/amg88xx
   8924    8924      0   0.00%    5088    5088      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/main.go
  11372   11372      0   0.00%    6928    6928      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/apds9960/proximity/main.go
   9828    9828      0   0.00%    5108    5108      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/itsybitsy-m0/main.go
   7356    7356      0   0.00%    2296    2296      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/at24cx/main.go
   8008    8008      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bh1750/main.go
   7368    7368      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/blinkm/main.go
  27664   27664      0   0.00%    5120    5120      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp180/main.go
  11816   11816      0   0.00%    5152    5152      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bmp388/main.go
   7712    7712      0   0.00%    3336    3336      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go
   4400    4400      0   0.00%    2256    2256      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/main.go
   7068    7068      0   0.00%    2260    2260      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/gc9a01/main.go
   8420    8420      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/hcsr04/main.go
   5528    5528      0   0.00%    2256    2256      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/customchar/main.go
   5568    5568      0   0.00%    2256    2256      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/text/main.go
  10376   10376      0   0.00%    5088    5088      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/hd44780i2c/main.go
  14248   14248      0   0.00%    6928    6928      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/hts221/main.go
  15980   15980      0   0.00%    2340    2340      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go
  10156   10156      0   0.00%    7264    7264      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic
  11144   11144      0   0.00%    5224    5224      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/basic
  29436   29436      0   0.00%   38424   38424      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing
  10188   10188      0   0.00%    7256    7256      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll
  11224   11224      0   0.00%    5216    5216      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/scroll
  10472   10472      0   0.00%    5120    5120      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go
  13632   13632      0   0.00%    6928    6928      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/lps22hb/main.go
  26188   26188      0   0.00%    2304    2304      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/lsm303agr/main.go
  27860   27860      0   0.00%    7168    7168      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/lsm303dlhc/main.go
  12312   12312      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/lsm6ds3/main.go
  10020   10020      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mag3110/main.go
   8984    8984      0   0.00%    5120    5120      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017/main.go
   9416    9416      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017-multiple/main.go
   9440    9440      0   0.00%    5088    5088      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp3008/main.go
   7464    7464      0   0.00%    5088    5088      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mma8653/main.go
   7368    7368      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mpu6050/main.go
  12312   12312      0   0.00%    5756    5756      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/pca9685/main.go
   6244    6244      0   0.00%    3268    3268      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setbuffer/main.go
   4628    4628      0   0.00%    2260    2260      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setpixel/main.go
  10604   10604      0   0.00%    5732    5732      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/seesaw/soil-sensor
  11916   11916      0   0.00%    5740    5740      0   0.00% tinygo build -size short -o ./build/test.hex -target=qtpy-rp2040 ./examples/seesaw/rotary-encoder
   3113    3113      0   0.00%     560     560      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/servo
  13896   13896      0   0.00%    5804    5804      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico     ./examples/sgp30
   7988    7988      0   0.00%    7128    7128      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/shifter/main.go
   5896    5896      0   0.00%    2260    2260      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1331/main.go
   6808    6808      0   0.00%    2260    2260      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7735/main.go
   6488    6488      0   0.00%    2260    2260      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7789/main.go
  16784   16784      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/thermistor/main.go
   9640    9640      0   0.00%    4880    4880      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-bluefruit ./examples/tone
  10136   10136      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/tm1637/main.go
  10924   10924      0   0.00%    5744    5744      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/touch/capacitive
   8816    8816      0   0.00%    7128    7128      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/fourwire/main.go
  12348   12348      0   0.00%    7324    7324      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/pyportal_touchpaint/main.go
  15772   15772      0   0.00%    5088    5088      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl53l1x/main.go
  14328   14328      0   0.00%    5088    5088      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl6180x/main.go
   6356    6356      0   0.00%    2300    2300      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13/main.go
   5944    5944      0   0.00%    2292    2292      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13x/main.go
   6248    6248      0   0.00%    2300    2300      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd4in2/main.go
   7096    7096      0   0.00%    5120    5120      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/ws2812
   5506    5506      0   0.00%    8918    8918      0   0.00% '-xesppie' is not a recognized feature for this target (ignoring feature)
   1997    1997      0   0.00%     600     600      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino   ./examples/ws2812
   1488    1488      0   0.00%     182     182      0   0.00% tinygo build -size short -o ./build/test.hex -target=digispark ./examples/ws2812
  32068   32068      0   0.00%    5120    5120      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bme280/main.go
  16392   16392      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/microphone/main.go
  11740   11740      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/buzzer/main.go
  12268   12268      0   0.00%    5120    5120      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/veml6070/main.go
   6796    6796      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/simple/main.go
   8716    8716      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/speed/main.go
   6772    6772      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/simple/main.go
   9120    9120      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/speed/main.go
   7272    7272      0   0.00%    3308    3308      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-f103rb ./examples/shiftregister/main.go
   7032    7032      0   0.00%    2256    2256      0   0.00% '-xesppie' is not a recognized feature for this target (ignoring feature)
  13280   13280      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis2mdl/main.go
  11248   11248      0   0.00%    5104    5104      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/max72xx/main.go
   7176    7176      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/clkout/
  12196   12196      0   0.00%    5708    5708      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/qmi8658c/main.go
  10876   10876      0   0.00%    5692    5692      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8591/
   8732    8732      0   0.00%    5088    5088      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina260/main.go
  12176   12176      0   0.00%    5120    5120      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina219/main.go
   9300    9300      0   0.00%    5232    5232      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-l432kc ./examples/aht20/main.go
  10160   10160      0   0.00%    7128    7128      0   0.00% tinygo build -size short -o ./build/test.elf -target=wioterminal ./examples/axp192/m5stack-core2-blinky/
   9020    9020      0   0.00%    5680    5680      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/xpt2046/main.go
  13128   13128      0   0.00%    4924    4924      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/sx126x/lora_rxtx/
  11300   11300      0   0.00%    6656    6656      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/irremote/main.go
  12292   12292      0   0.00%    5756    5756      0   0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/uc8151/main.go
  12296   12296      0   0.00%    6200    6200      0   0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/waveshare-epd/epd2in9v2/main.go
  10516   10516      0   0.00%    5752    5752      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd4x/main.go
   7984    7984      0   0.00%    5088    5088      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=circuitplay-express ./examples/makeybutton/main.go
   9448    9448      0   0.00%    5104    5104      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ds18b20/main.go
  16100   16100      0   0.00%    7348    7348      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/as560x/main.go
   9912    9912      0   0.00%    5700    5700      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu6886/main.go
   7764    7764      0   0.00%    5080    5080      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ttp229/main.go
   9364    9364      0   0.00%    5692    5692      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu9150/main.go
   8508    8508      0   0.00%    6156    6156      0   0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/encoders/quadrature-interrupt
  13220   13220      0   0.00%    5688    5688      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/tmc5160/main.go
  12004   12004      0   0.00%    4900    4900      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=nicenano ./examples/sharpmem/main.go
  12856   12856      0   0.00%    5748    5748      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ens160/main.go
  16108   16108      0   0.00%    5764    5764      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/si5351/main.go
  42964   42980     16   0.04%    5316    5316      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/basic/main.go
  27420   27436     16   0.06%    3808    3808      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/microbitmatrix/main.go
  29088   29108     20   0.07%    5316    5316      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/alarms/main.go
  36232   36252     20   0.06%    6388    6388      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8523/
  21592   21616     24   0.11%    3532    3532      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go
  27300   27324     24   0.09%    5852    5852      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit-v2 ./examples/microbitmatrix/main.go
  12320   12344     24   0.19%    8712    8712      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao-ble ./examples/ssd1306/
  42172   42196     24   0.06%    8964    8964      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/sx127x/lora_rxtx/
  23312   23340     28   0.12%    5744    5744      0   0.00% tinygo build -size short -o ./build/test.hex -target=metro-rp2350 ./examples/bno08x/i2c/main.go
  11692   11728     36   0.31%    5684    5684      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao-rp2040 ./examples/ssd1306/
  11780   11816     36   0.31%    5684    5684      0   0.00% tinygo build -size short -o ./build/test.hex -target=thumby ./examples/ssd1306/
  11572   11612     40   0.35%    5728    5728      0   0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/sh1106/macropad_spi
  57568   57612     44   0.08%    3672    3672      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht3x/main.go
  57560   57604     44   0.08%    3680    3680      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht4x/main.go
  57568   57612     44   0.08%    3672    3672      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/shtc3/main.go
  31788   31848     60   0.19%    7200    7200      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/ssd1289/main.go
  24568   24636     68   0.28%   14076   14076      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840-sense ./examples/waveshare-epd/epd1in54/main.go
  17016   17112     96   0.56%    6576    6576      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/adafruit4650
  62852   62948     96   0.15%    6296    6296      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/is31fl3731/main.go
  67560   67660    100   0.15%    6704    6704      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/i2c/main.go
  68260   68360    100   0.15%    6852    6852      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/uart/main.go
  26380   26484    104   0.39%   18816   18816      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/waveshare-epd/epd2in66b/main.go
  62124   62228    104   0.17%    3768    3768      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ndir/main_ndir.go
  65468   65572    104   0.16%    6600    6600      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ndir/main_ndir.go
  67344   67464    120   0.18%    7212    7212      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ndir/main_ndir.go
  71412   71676    264   0.37%    3640    3640      0   0.00% tinygo build -size short -o ./build/test.hex -target=pinetime     ./examples/bma42x/main.go
  61996   62264    268   0.43%    8576    8576      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/i2csoft/adt7410/
  62424   62696    272   0.44%    6332    6332      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/max6675/main.go
  61744   62024    280   0.45%    6528    6528      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adt7410/main.go
  65628   65908    280   0.43%    6544    6544      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmi160/main.go
  64300   64580    280   0.44%    6568    6568      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp280/main.go
  66712   67004    292   0.44%    9356    9356      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/flash/console/qspi
  76256   76548    292   0.38%    7788    7788      0   0.00% tinygo build -size short -o ./build/test.hex -target=p1am-100 ./examples/p1am/main.go
  42144   42436    292   0.69%    7536    7536      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/tmc2209/main.go
  71812   72108    296   0.41%    6544    6544      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp2515/main.go
  71312   71608    296   0.42%    6688    6688      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/alarm/
  70748   71044    296   0.42%    6688    6688      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/time/
  71144   71440    296   0.42%    6688    6688      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/timer/
  73760   74056    296   0.40%   11092   11092      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/sdcard/console/
  66840   67136    296   0.44%    7180    7180      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mcp9808/main.go
  70312   70612    300   0.43%    7316    7316      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/flash/console/spi
  76924   77244    320   0.42%    6680    6680      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/dht/main.go
 122140  122768    628   0.51%    8112    8112      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/lora/lorawan/atcmd/
 263644  264552    908   0.34%   47108   47108      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/slideshow
3532508 3540352   7844   0.00%  850212  850212      0   0.00%

@jakebailey
Copy link
Copy Markdown
Member Author

Pushed the debug info plus removed an unreferenced function I missed; shouldn't affect the size comparison (which I am very excited to see, that's a lot better than I thought it was going to be).

Copy link
Copy Markdown
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

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

Still looks good to me :)

@deadprogram
Copy link
Copy Markdown
Member

Great work everyone! Thanks for getting it done, now squash/merging.

@deadprogram deadprogram merged commit 5ba8766 into tinygo-org:dev Apr 17, 2026
19 checks passed
@jakebailey jakebailey deleted the reflect-assignableto branch April 17, 2026 19:58
@jakebailey
Copy link
Copy Markdown
Member Author

Awesome!

I realized just now that I had not added to the test suite errors, which you noted on slack also now works. I'll send a PR for that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants