Skip to content

avm-based adruino target "ptrtoint integer size" error, affects fmt package, 0.22.0 #2732

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

Closed
stevegt opened this issue Mar 22, 2022 · 8 comments
Labels
avr AVR (Arduino Uno, etc.)

Comments

@stevegt
Copy link

stevegt commented Mar 22, 2022

Getting "error: interp: ptrtoint integer size does not equal pointer size" from fmt.Sprintf, Println, Printf, etc. Possibly related to #2389.

package main

import (
        "fmt"
        "time"
)

func main() {
        for {
                a := fmt.Sprintf("hello")
                _ = a
                time.Sleep(1 * time.Second)
        }
}

tinygo version 0.22.0 linux/amd64 (using go version go1.16.3 and LLVM version 13.0.0)

@dankegel
Copy link
Contributor

Yeah, it's almost certainly a dup of #2389

@stevegt
Copy link
Author

stevegt commented Mar 22, 2022

I'd recommend keeping this issue open until fmt works again in a released version, even if it does turn out to be a dup of #2389 -- new folks (and potential contributors) need to be able to figure this out quickly; workarounds can be posted here.

The 0.22.0 println() function also does not work on the Uno -- I can't tell if this, too, is a known bug. It seems to be causing timing problems or crashes which I haven't tracked down, so I finally wound up using machine.Serial.Write() to get any USB output at all.

I'm also an open-source maintainer, so know far too well how this feels. In the spirit of constructive feedback, this was to be my first use of tinygo for a project, and I was looking forward to it, but lost an evening still trying to get things to work even after finding #2389. Took me a while to figure out that I was getting that compile-time error because I was importing a third-party sensor library that uses fmt.Sprintf internally pretty extensively. I wasn't importing fmt myself.

Since most articles and blog posts about tinygo assume that either fmt.Println() or println() just work, and https://tinygo.org/docs/reference/lang-support/stdlib/ also confirms that fmt should work, that was a bizarre several hours.

For this project at least, all of this added together means I'm having to switch to FreeRTOS, which is of course going to distract me from being able to help with #2389, so vicious circle. I'd say something like "y'all really need to prioritize fixing fmt so potential contributors don't run away screaming at first contact", but again, I know how this feels.

Let me know if there's anything I can do to help, even if it's just being a testing monkey. I want tinygo to work.

@dkegel-fastly
Copy link
Contributor

Making tests fail until this is fixed seems a bit much, but I did tag this with the 0.23 milestone to give it more visibility.

@dkegel-fastly dkegel-fastly added this to the v0.23.0 milestone Mar 22, 2022
@aykevl
Copy link
Member

aykevl commented Mar 23, 2022

The fmt package mostly works. The problem is not fmt, but the AVR backend (used for Arduino) that is unstable (but slowly improving). If you use a board with a Cortex-M chip (micro:bit, newer "Zero", "M0" or "M4" brander boards) then it should work.

@dkegel-fastly dkegel-fastly changed the title fmt package unusable, arduino target, 0.22.0 AVR bug makes fmt package unusable on arduino target, 0.22.0 Mar 23, 2022
@dkegel-fastly dkegel-fastly changed the title AVR bug makes fmt package unusable on arduino target, 0.22.0 avm-based adruino target "ptrtoint integer size" error, affects fmt package, 0.22.0 Mar 23, 2022
@dankegel
Copy link
Contributor

For the record, there is a minimal reporoducer at #2389 (comment)

@dkegel-fastly
Copy link
Contributor

Closing as dup of #2389

@dkegel-fastly dkegel-fastly removed this from the v0.23.0 milestone Apr 7, 2022
@deadprogram deadprogram added the avr AVR (Arduino Uno, etc.) label Apr 16, 2022
@dan-dekel
Copy link

getting the same error when running tinygo test -target=arduino-nano

@aykevl
Copy link
Member

aykevl commented Jan 9, 2023

Duplicate of #2389 so closing.

@aykevl aykevl closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
avr AVR (Arduino Uno, etc.)
Projects
None yet
Development

No branches or pull requests

6 participants