-
Notifications
You must be signed in to change notification settings - Fork 99
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
AVR support #3
Comments
Here's an email I sent out to the tl;dr there's really only 3 files needed before the backend will be 80% usable. |
Hey, @dylanmckay. I'm wondering what's the current status. I saw that there's only one "PR" (differential revision) in the review queue and that it has already been accepted but has not landed yet. After that lands, will LLVM be ready to compile Rust programs for AVR? Will you (and @shepmaster) be sending a PR updating Rust's LLVM next? Happy to help with anything to land this in rust-lang/rust. 😄 (I should finish landing my PR that moves rust-lang/rust to the WIP Rust port of compiler-rt intrinsics; I suspect that it may help here) |
Eventually, yeah, except the LLVM 4.0 changes are more annoying than any previous LLVM changes I've had to make.
I think it will help. Especially because one "bug" we have at the moment is that I've forgotten to publish the WIP branch of compiler-rt so people are getting build failures. |
I'm really looking forward to LLVM 4.0 in rust-lang/rust so if you make it happen you'll have my gratitude.
Did you have to implement new intrinsics? I only see build system related changes in your fork. |
What benefits do you expect to see from it?
I think we might have to, but haven't yet. |
I'm working on embedding lld, the LLVM linker, into |
I'm about to commit that one now :)
It should be able to compile very trivial instructions. There are two source files that will fix that.
|
@japaric Big shout out for |
@raphaelcohn Check rust-lang/rust#36120. It's pretty much already working on Linux and it can link Cortex-M programs without arm-none-eabi-gcc. It hasn't landed because I couldn't get lld to build properly on Windows 😞
Indeed! If all goes well we'll also be able to (cross) compile statically linked MUSL binaries without needing glibc installed on the system as well. Ahh, the dream of the "zero installation steps" cross compilation setup may soon come true. |
🎉 Awesome work, @dylanmckay! 🎉 Now, it's time for the (Rust) compiler hackers (hey, don't look at me!) to roll up their sleeves and update the LLVM submodule to version 4.0 to enable this backend in rustc. |
Check rust-lang/rust#37609 |
There will still be a bunch of code generation bugs that'll cause the compiler to crash, but I/we can fix them as we get them, and I will then be able to cherry-pick the fixes into our fork. |
Current status: rust-lang/rust has alread switched to LLVM 4.0 but there are still some bugs in the AVR backend that make it impossible to compile the core crate for the AVR architecture. (I bet 128-bit integers are to blame) However, you can get away by using a smaller version of the core crate that does compile with the current AVR backend (plus some patches). If you are feeling adventurous, the process is documented in this blog post. |
One of many things, sadly. But we are making progress! |
What's the current status of this? @japaric @dylanmckay |
@dylanmckay if core didn't contain any 128-bit integer related code how many codegen bugs would still need to be fixed to be able to build core? If your answer is 0 then I'll try my best to convince the Rust team to temporarily I should also note that developments like pure MIR .rlibs (cf. rust-lang/rust#48373) may let us bypass the i128 codegen bugs. Since no machine code will be generated when compiling libcore.rlib no codegen bug can be encountered. Still you would probably hit the codegen bug when compiling the final application unless your application doesn't make use of 128 bit integers and rustc had some dead code elimintation pass at the MIR level (which afaik doesn't exist right now) that eliminates all i128 code before it reaches LLVM. |
I have rebased the avr-rust fork ontop of Rust master. There I've summarised the results here. Aside from the removal of the i128 type, the only other change required to get libcore compiling as a static library was to remove the The blink example fails to compile with LLVM 6 - avr-rust/rust-legacy-fork#37. That bug will need to be fixed before the AVR fork can be updated.
FWIW, it looks like libcore already understands the |
That's just the feature gate that prevents you from using |
@japaric good catch, that's my mistake. I wonder if it worked for me because it always evaluated to true. Easy to replace with |
@dylanmckay rustc moved to LLVM 7 a few weeks ago. I believe the last upgrade to LLVM 6 ended up increasing the number of codegen bugs encountered when building core. Was wondering if you had a chance to check if moving to LLVM 7 improved things or made them worse? |
There are at least 2 bugs left: avr-rust/rust-legacy-fork#101 and avr-rust/rust-legacy-fork#103 |
FWIW, we moved to LLVM 8 recently, thanks to @TimNN. We've been able to compile the entire core library (probably not using all of it though), removing the need for our special hacked libcore. |
One of the Rust 2019 Wish lists |
I've updated the checklist for merge in the description and raised #282 to track performing a Crater run against AVR. |
@dylanmckay I think you meant #282 ;) |
Whoops, is it still a ninja edit 25 minutes later? 🤔 |
AVR support was merged into Rustc. Can this be closed now? |
Yes, let's close this. |
Parent issue: #2
Next steps:
programs for this target
See also avr-rust/rust for out of tree work towards AVR support in Rust.
The text was updated successfully, but these errors were encountered: