-
Notifications
You must be signed in to change notification settings - Fork 22
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
Embedded Devices / Nim Memory Management #96
Comments
A) Futhark on embedded is definitely possible. I'm using it for developing embedded software at work. The errors you face is Nim not quite understanding that the host OS and target OS (or lack thereof) are not the same. So a lot of the features Futhark needs which is available on the host OS are disabled when compiling for an embedded target. This of course isn't actually an issue since Futhark runs completely on compile-time, but Nim still fights you. The trick is to create a small dummy file in Nim, with all the needed flags and options to the Clang compiler you would use to compile your libraries. Then compile this dummy file and copy the Futhark cache from the cache folder, or use the B) There is a section in the README about adding destructors. I also added them in my MAPM wrapper (linked in the README) if you want a practical example. Thank you for the kind words, it means a lot to me that people find my work useful! |
Ha! Yes, all I needed to do was run Futhark on host completely dethatched from the embedded project. Thank you! On destructors, since I have no background in memory management, I don't even know where to start with when/why/how to add destructors. Are there any resources that would help someone like me with no experience? PS. Your welcome! You truly deserve it! |
Hmm, it's quite a complicated topic. I'm not aware of any simple resources for learning this stuff. But generally speaking most libraries tend to have create/free function pairs for each of its types. So it's mostly a matter of adding destructors to call the free functions, and of course wrapping the create functions in something more ergonomic. Of course it can be hard to get right, so learning how to use a memory tracking tool like Valgrind can be of great help. If you do come across some easy resources I'd be interested in looking at them out of curiosity. |
I am working on a project to get Nim with Arduino libs running on an ESP32 and have had a few minor successes, though successes nonetheless. I am looking to further the project with Arduino/C/C++ libraries such as LVGL and TFT_ESPI because of the support and density of the Arduino catalogue. The ability to auto-generate wrappers for these libraries and add destructors for Nim-managed memory really enticed me toward Futhark, as I, coming from years of Python, have never managed memory in my life, and would like to keep it that way. So my questions are:
A) Is Futhark on embedded possible? I get nasty errors like "Error: OS module not ported to your operating system!" or "Error: Port memory manager to your platform."
B) If so, how would one go about incorporating destructors with generated wrappers to keep memory management in the hands of Nim?
Thank you PMunch for this project and your endless contributions to Nim. I can't google a query about Nim without your name showing up lol.
The text was updated successfully, but these errors were encountered: