You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the stabilization of the new asm language, the old llvm_asm is getting deprecated in Rust, creating the threat of eventual removal.
To build stable Rust code, we should aim to not just copy over the (LLVM / GCC style) assembly from C code, but try to change it to the newer (and stable) assembly language.
(#306 is different from this; that is just about emitting the old assembly with the new llvm_asm names).
I'm aware this is not a trivial request; it may be necessary to look for use cases that sponsor work on this.
Possible alternatives:
It may be possible to create extra assembly files for the blocks and then pull them in from the generated Rust code. It may also not.
This is going to be very painful; I had hoped we'd have a bit of time.
Do you see any chance of implementing asm generation within the time
frame of llvm_asm's removal?
From what I can tell the assembly currently produced by c2rust doesn't even work on the latest nightly (or in fact any nightly in the last 2 years) since it's using the old LLVM assembly syntax with asm!.
It's working alright for my use case in the RIOT project (with some fixes that are all in open PRs -- one to rename it to llvm_asm, one to fix some lifetime issues IIRC).
I've been doing some tests on viable alternatives, and from the looks of it, little of the ASM that's part of the everyday code gets actually used, leaving (in the one example I've had a look at) only one actually used item. My current workaround is manually doing the changes on selected ASM statements, about like this -- with an unavailable symbol to squeak if any non-transpiled assembly does make it past dead code elimination into the linker.
I've done a (fairly unpolished, and assuming x86_64 in a few places) pass at this in the syn PR, because it's a necessary part of bringing us up to speed with the rest of the Rust ecosystem. Test coverage is still lacking, so any feedback would be particularly appreciated.
#374 has merged, but I'll leave this bug open until we have broader test coverage to better validate the asm translation. Currently there's some minimal asm for a bswap implementation that gets dragged in from system headers, a few places doing cpuid, and a few mathy bits from python in the testsuite, but we would do well to have targeted test cases for inline asm in the c2rust repo itself.
Activity
C2Rust: Silence deprecation warning on llvm_asm
Amanieu commentedon Jan 13, 2022
llvm_asm!is being removed in rust-lang/rust#92816.chrysn commentedon Jan 13, 2022
Amanieu commentedon Jan 13, 2022
From what I can tell the assembly currently produced by c2rust doesn't even work on the latest nightly (or in fact any nightly in the last 2 years) since it's using the old LLVM assembly syntax with
asm!.chrysn commentedon Jan 13, 2022
It's working alright for my use case in the RIOT project (with some fixes that are all in open PRs -- one to rename it to llvm_asm, one to fix some lifetime issues IIRC).
I've been doing some tests on viable alternatives, and from the looks of it, little of the ASM that's part of the everyday code gets actually used, leaving (in the one example I've had a look at) only one actually used item. My current workaround is manually doing the changes on selected ASM statements, about like this -- with an unavailable symbol to squeak if any non-transpiled assembly does make it past dead code elimination into the linker.
(With no guarantees for equivalence of the two lines).
fw-immunant commentedon Jan 20, 2022
llvm_asmwas recently removed, which makes this a bit more urgent as a requirement for supporting current rustc.fw-immunant commentedon Apr 12, 2022
I've done a (fairly unpolished, and assuming x86_64 in a few places) pass at this in the syn PR, because it's a necessary part of bringing us up to speed with the rest of the Rust ecosystem. Test coverage is still lacking, so any feedback would be particularly appreciated.
fw-immunant commentedon Apr 13, 2022
#374 has merged, but I'll leave this bug open until we have broader test coverage to better validate the asm translation. Currently there's some minimal asm for a bswap implementation that gets dragged in from system headers, a few places doing cpuid, and a few mathy bits from python in the testsuite, but we would do well to have targeted test cases for inline asm in the c2rust repo itself.