Code Monkey home page Code Monkey logo

Comments (6)

aykevl avatar aykevl commented on May 22, 2024

I have seen the second error more often. It is due to a limitation in the AVR backend (it cannot deal with struct parameters, and []byte is really a {ptr, len, cap} struct). See #20 for details. A temporary (ugly) workaround is to make the inliner more likely to run by increasing the value of the third parameter to Optmize(opt, size, inliner) in main.go.

I haven't seen the first error before but it also looks like an unimplemented feature.

from tinygo.

deadprogram avatar deadprogram commented on May 22, 2024

Boosted Optimize() 3 param as you suggested. the value 300 compiles (both errors go away) but does not execute as desired.

You are probably not surprised. Digging here to figure out more.

from tinygo.

aykevl avatar aykevl commented on May 22, 2024

You could try again now. The second problem is probably fixed with fdfa810. The first problem should really be fixed in upstream LLVM, but might also be fixed as a side effect (who knows).

A trick that might fix the first problem (again, a dirty workaround) is to sleep the same time everywhere. The optimizer will recognize the pattern and do the expensive int64 calculation at compile time.

from tinygo.

aykevl avatar aykevl commented on May 22, 2024

Ah now I see. The trouble with the second uncommented line might be related to the memory allocator, which I have never tested on AVR (as it wasn't able to run any significant programs).

from tinygo.

deadprogram avatar deadprogram commented on May 22, 2024

You were correct that changing all of the calls to time.Sleep() to use the same value let the compiler run without errors and without changing the value of the inliner param to Optimize(). That is probably not a practical long-term solution, of course.

The latest version of master lets the compiler run using various different time values like my original code, with the inline param set to the lower value 50.

from tinygo.

deadprogram avatar deadprogram commented on May 22, 2024

The latest version of master now is able to run the AVR I2C code with no change to the Optimize() function. I am going to close this issue as the original problem has been addressed. Thank you!

from tinygo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.