Cette semaine, j'ai upgradé mon système ArchLinux (et donc je suis passé de llvm18 à llvm19).

J'ai donc du recompiler mon tinygo pour prendre en compte cette montée de version llvm.

En retournant sur mon projet tinygo, j'ai rencontré des erreurs avec la compilation llvm.

C'est donc l'occasion d'écrire quelques lignes sur la résolution du problème.

Quand ca compile plus..

Voilà l'erreur rencontrée lors de la compilation de mon projet :

$ tinygo build --target=pico
panic: unknown type: any

goroutine 70 [running]:
github.com/tinygo-org/tinygo/compiler.(*compilerContext).makeLLVMType(0xc0001ce000?, {0xa9e4c8?, 0xc000114200?})
	/opt/tinygo/compiler/compiler.go:468 +0x539
github.com/tinygo-org/tinygo/compiler.(*compilerContext).getLLVMType(0xc0001ce000, {0xa9e4c8, 0xc000114200})
	/opt/tinygo/compiler/compiler.go:383 +0x65
github.com/tinygo-org/tinygo/compiler.(*compilerContext).makeLLVMType(0xc0001ce000, {0xa9e400?, 0xc0055c39e0})
	/opt/tinygo/compiler/compiler.go:456 +0x64e
github.com/tinygo-org/tinygo/compiler.(*compilerContext).getLLVMType(0xc0001ce000, {0xa9e400, 0xc0055c39e0})
	/opt/tinygo/compiler/compiler.go:383 +0x65
github.com/tinygo-org/tinygo/compiler.(*compilerContext).makeLLVMType(0xc0001ce000, {0xa9dea0, 0xc0055cddc0})
	/opt/tinygo/compiler/compiler.go:439 +0x487
github.com/tinygo-org/tinygo/compiler.(*compilerContext).getLLVMType(0xc0001ce000, {0xa9dea0, 0xc0055cddc0})
	/opt/tinygo/compiler/compiler.go:383 +0x65
github.com/tinygo-org/tinygo/compiler.(*compilerContext).getParamInfo(0xc0001ce000, {0xa9e428?}, {0xab33d0?, 0x0?}, {0xa9e428?, 0xc0029e1930?})
	/opt/tinygo/compiler/calls.go:205 +0xe5
github.com/tinygo-org/tinygo/compiler.(*compilerContext).expandFormalParamType(0xc0001ce000, {0xa9e428?}, {0xab33d0, 0x1}, {0xa9e428, 0xc0029e1930})
	/opt/tinygo/compiler/calls.go:104 +0xc5
github.com/tinygo-org/tinygo/compiler.(*compilerContext).getFunction(0xc0001ce000, 0xc003830600)
	/opt/tinygo/compiler/symbol.go:96 +0x3c6
github.com/tinygo-org/tinygo/compiler.newBuilder(0xc0001ce000, {0xc00a6d52d0?}, 0xc003830600)
	/opt/tinygo/compiler/compiler.go:179 +0x3d
github.com/tinygo-org/tinygo/compiler.(*compilerContext).createPackage(0xc0001ce000, {0xc003632200?}, 0xc00a013400)
	/opt/tinygo/compiler/compiler.go:890 +0x9dd
github.com/tinygo-org/tinygo/compiler.CompilePackage({0xc000451520?, 0x5b?}, 0xc0004e01e0, 0xc00a013400, {0x7af4da0c88a0?}, 0x9d62f3?, 0x8?)
	/opt/tinygo/compiler/compiler.go:314 +0x405
github.com/tinygo-org/tinygo/builder.Build.func3(0xc004d5afc0)
	/opt/tinygo/builder/build.go:389 +0x1f4
github.com/tinygo-org/tinygo/builder.runJob(0xc004d5afc0, 0xc002e72cb0)
	/opt/tinygo/builder/jobs.go:212 +0x4d
created by github.com/tinygo-org/tinygo/builder.runJobs in goroutine 1
	/opt/tinygo/builder/jobs.go:113 +0x5d8

Heureusement, il y a un workaround:

$ GODEBUG=gotypesalias=0  tinygo  flash -target=pico

Pour plus d'informations, vous pouvez consulter l'issue github associée:

TinyGo Panics on Generic Type Aliases · Issue #4819 · tinygo-org/tinygo
TinyGo crashes when compiling a generic type alias, even when using GODEBUG=gotypesalias=1. Though I am not sure whether TinyGo supports generic type aliases correctly. $ cat test.go package main i…