Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Missing compiler_rt functions #1290
I was playing around with the latest version of Zig (https://ci.appveyor.com/project/andrewrk/zig-d3l86/build/0.2.0+95f45cfc) on ARM Cortex-M0 and I had a lot of issues with missing compiler_rt functions.
It was missing '__aeabi_memcpy'
It was complaining about missing '__aeabi_uldivmod', which I fixed by commenting out
After that it complained about
This is the command I used
Is it possible to get a more permanent/robust solution to compiler_rt related problems? Some kind of automated testing that everything is there somehow?
(Btw, good news is that linking with Zig (rather than GCC or LLD) seems to work just fine for me now)
So far, I haven't tried to make sure we have all the compiler_rt functions. I've just been adding the ones that were missing when I personally tried something and got these errors. So I've never tried to make sure that we have all of them.
So the first step to getting a permanent/robust solution to compiler_rt related problems is to go ahead and port all the rest of compiler_rt. I thought we had an issue open for that but I'm unable to find it, so this will be that issue.
Thanks to @winksaville we now have these functions:
Next steps toward solving this issue is to compile a checklist of all the functions from llvm's compiler-rt builtins/ directory and then start porting them one by one.
This list is derived from the following README file.
There are some platform-specific functions that need to be added here, for
Integral bit manipulation
// Integral arithmetic with trapping overflow
Integral arithmetic which returns if overflow
Integral / floating point conversion
Floating point raised to integer power
Following are not required since we do not have language-level complex number support.
I had the same problem. It turns out you need to compile for gnueabi target in order to link using GCC ld.
This works for me:
@radek-senfeld we can add
It's pretty easy to add compiler-rt functions. I can try to get those in today. Were there any other missing ones for you besides these 3?
Hi Andrew, at first I want to thank you for your amazing project! I'm hooked to Zig!
Well, my motivation was that I just had to know what is the problem and why it doesn't work. After spending quite a few hours digging around I now much better understand how things work under the hood.
Well, there's apparently no issue with EABIs when Zig links the file. Running
Which is quite strange because of ommited
After linking with compiler_rt.o everything I've tried has been sorted out. I just wanted to know if there's chance to have fp formatting in the firmware. Unfortunately the size of this feature is prohibitive (~100kB) at this moment. I've tried just a simple test:
There's one more issue but I'm not quite sure about the cause yet. It just hangs the MCU. I need to inspect it using a debugger. This causes MCU to hang:
Thank you for the compliment and I'm happy that you like it.
Only if the symbols are called or used. Perhaps this is zig's lazy analysis of top level declarations? If you do not call a function then it does not get analyzed or included in the result.
Ah that's interesting. Here we have a good use case for perhaps selecting a different implementation of floating point formatting when the
Feel free to open a new issue which is dedicated to exploring your exact use case. We can comment back and forth there and perhaps learn some new Zig issues that need to be filed.
You're probably right.
I guess it's caused by me not specifying a linker script. Which means entry point isn't defined thus fn main() is not linked in and no symbols are missing because they are not used.
Oh, my bad. Now I feel a bit stupid. When compiled using
Floating-point formatting enabled:
Here is the summary: