Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: unknown struct {}{}:{} #3842

Closed
stalecu opened this issue Jul 25, 2023 · 3 comments
Closed

panic: unknown struct {}{}:{} #3842

stalecu opened this issue Jul 25, 2023 · 3 comments

Comments

@stalecu
Copy link

stalecu commented Jul 25, 2023

Hello! I am new to TinyGo, so I decided to try it on my trusty RP2040. I cloned the repo on the release branch (which I suppose means I am on 0.28.1) to a separate repository, built LLVM myself (it didn't want to comply with my system LLVM-15 on openSUSE Tumbleweed, but oh well) and then symlinked tinygo to /usr/bin. Then I created a new project (module?) and this is the contents of hello.mod:

package main

import (
    "machine"
    "time"
)

func main() {
    led := machine.LED
    config := machine.PinConfig{
        Mode: machine.PinOutput,
    }

    led.Configure(config)
    for {
        led.Low()
        time.Sleep(time.Millisecond * 500)

        led.High()
        time.Sleep(time.Millisecond * 500)
    }
}

and this is what I get when building with tinygo build -o blink -target="pico" ./hello.go (to simplify the output a bit, I replaced my actual tinygo path with $TINYGO_PATH:

panic: unknown constant: struct{}{}:struct{}

goroutine 55 [running]:
github.com/tinygo-org/tinygo/compiler.(*compilerContext).createConst(0xc008a34000, 0xc008a60340, 0xc0059c7310?)
	$TINYGO_PATH/compiler/compiler.go:2972 +0xd74
github.com/tinygo-org/tinygo/compiler.(*builder).getValue(0xc00acdb680, {0x59c41b0?, 0xc008a60340?}, 0xc0059c74e0?)
	$TINYGO_PATH/compiler/compiler.go:1901 +0xcf
github.com/tinygo-org/tinygo/compiler.(*builder).createInstruction(0xc00acdb680, {0x59c4af8?, 0xc008a429c0?})
	$TINYGO_PATH/compiler/compiler.go:1494 +0x368
github.com/tinygo-org/tinygo/compiler.(*builder).createFunction(0xc00acdb680)
	$TINYGO_PATH/compiler/compiler.go:1349 +0xaa5
github.com/tinygo-org/tinygo/compiler.(*compilerContext).createPackage(0xc008a34000, {0xc008974480?}, 0xc003c13e00)
	$TINYGO_PATH/compiler/compiler.go:865 +0x345
github.com/tinygo-org/tinygo/compiler.CompilePackage({0xc00002b467?, 0x5a?}, 0xc00042e960, 0xc003c13e00, {0xcea4cdf91292f0e3?}, 0x593cb42?, 0xea?)
	$TINYGO_PATH/compiler/compiler.go:312 +0x459
github.com/tinygo-org/tinygo/builder.Build.func3(0xc00601e780)
	$TINYGO_PATH/builder/build.go:357 +0x20e
github.com/tinygo-org/tinygo/builder.runJob(0xc00601e780, 0x0?)
	/home/a13cui/code/tinygo/builder/jobs.go:222 +0x4f
created by github.com/tinygo-org/tinygo/builder.runJobs
	/home/a13cui/code/tinygo/builder/jobs.go:123 +0x5be

Is there something I'm missing? And perhaps a way to reinstall everything from the tarball if that might be the culprit. Thank you for your attention.

@stalecu
Copy link
Author

stalecu commented Jul 25, 2023

Edit: I nuked everything and tried installing it from the tarball... maybe LLVM was acting weird? I don't know.

@stalecu stalecu closed this as completed Jul 25, 2023
@QuLogic
Copy link
Contributor

QuLogic commented Aug 15, 2023

panic: unknown constant: struct{}{}:struct{}

It seems like you may have compiled against golang.org/x/tools >= 0.9.0. This version started lifting struct and array constants since golang/tools@71ea8f1 and the compiler doesn't handle that in createConst yet.

@QuLogic
Copy link
Contributor

QuLogic commented Sep 23, 2023

This would be fixed by #3883.

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

No branches or pull requests

2 participants