-
Notifications
You must be signed in to change notification settings - Fork 98
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
Test AVR against all no_std crates in a Crater run #282
Comments
I guess, in the Crater run, the |
Hi! Main Crater developer here!
As long as you have a PR on the
Crater already has some code to inspect/edit a crate's
Crater uses docker to sandbox builds, and it's not a problem to hook custom machines to it. As far as infrastructure goes, at the moment a Crater run is executed on a
Do you need to build/run stuff on embedded hardware or can it run on a x86_64 machine? (not too familiar with the embedded world, sorry!) If everything can be done on x86_64 we can execute the run on our Crater machines. Unfortunately I won't have time to do the changes to the Crater codebase needed to do this run, but I'd be happy to mentor! You can find me in the |
I believe that the goal here would be to simply compile the code, doing the equivalent of We should look into running tests on an AVR emulator/device, of course, but I think that's future work. |
#![crate_type = "lib"]
#![no_std]
#[no_mangle]
fn foo(x: &AtomicUsize) -> usize {
x.load(Ordering::Acquire) // TODO try all orderings;
}
#[no_mangle]
fn bar(x: &AtomicUsize) -> usize {
x.fetch_add(1, Ordering::Acquire) // TODO try all orderings;
}
// TODO try compiler_fence and AtomicUsize.store $ cargo objdump --target thumbv7m-none-eabi --lib --release -- -d -no-show-raw-insn
Disassembly of section .text.foo:
foo:
0: ldr r0, [r0]
2: dmb sy
6: bx lr
Disassembly of section .text.bar:
bar:
0: mov r1, r0
2: ldrex r0, [r1]
6: adds r2, r0, #1
8: strex r3, r2, [r1]
c: cmp r3, #0
e: bne #-16 <bar+0x2>
10: dmb sy
14: bx lr
// TODO also try `fn() -> !` (it can use more registers) and `#[naked]` (it has a weird ABI)
#[no_mangle]
unsafe fn foo() {
asm!("" :: "r"(0) "r"(1) "r"(2) "r"(3) "r"(4) "r"(5) /* .. */ :: "volatile");
} |
Hahahaha. I think this has been the single most difficult part of the AVR port; we've run into so many issues around this. I'm sure we haven't seen the last of them! |
What is the status of this? It would be really interesting to be able to publish Arduino libraries written in Rust |
@pietroalbini that's good to hear, thanks! I will create a DO NOT MERGE PR to upstream Rust including the changes required to run the AVR rustc fork. Do you have any links to existing crater PRs that include Thanks for the help! |
@japaric those are good suggestions. I've raised avr-rust/rust-legacy-fork#125 to track testing of Unfortunately, we can't use compiler-builtins with AVR yet because the libgcc library from avr-libc contains a few functions with nonstandard calling conventions, which the LLVM AVR backend currently emits code to match. This is mostly around the division and multiplication routines. We should make the libgcc-specific calling convention logic optional somehow, then |
The |
Closing this as part of 2024 triage. AVR support is in upstream rustc now, there's no rustc fork maintained by the WG anymore. |
The AVR fork can now fully compile libcore to machine code in all the programs we've tested. It is unclear if there are other, yet unexercised parts of
libcore
that have issues with AVR.On top of this, we don't have a clear idea of which existing crates are compatible with 16-bit targets.
Many of the hundreds of common Rust libraries have not been tested against AVR. It would be pertinent to know if there are any current AVR troubles with the existing crate ecosystem before we progress with merging the backend upstream.
Upstream Rust use a tool called
crater
to assess the impact of breaking changes on every crate publishes tocrates.io
.We should perform a crater run with AVR so we will have a precise breakdown of exactly which crates will work, which crates will break, and what bugs we may need to fix before upstream.
Is it possible to use Crater on a
rustc
fork, constrained tono_std
crates? Does a crater run require heavy infrastructure, and if so, can we plug in something like a docker host and use it on our own machines? I don't really know how it works internally.Does anyone know if this is feasible?
The text was updated successfully, but these errors were encountered: