Skip to content

Commit 83d8bd4

Browse files
committed
Acknowledge that assebly can be pulled in through static inlines
including all the necessary workarounds See-Also: immunant/c2rust#306 See-Also: immunant/c2rust#307
1 parent 833d8ea commit 83d8bd4

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ default-target = "i686-unknown-linux-gnu"
1818

1919
[dependencies]
2020
cty = "^0.2"
21+
# see https://github.com/immunant/c2rust/pull/307
22+
c2rust-asm-casts = { git = "https://github.com/chrysn-pull-requests/c2rust", branch = "nostd-c2rust-asm-casts" }
2123

2224
[build-dependencies]
2325
bindgen = "0.53.1"

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ static {type_name} init_{macro_name}(void) {{
191191
rustcode = rustcode.replace(" #[no_mangle]\n fn ", " #[no_mangle]\n pub fn ");
192192
// used as a callback, therefore does need the extern "C" -- FIXME probably worth a RIOT issue
193193
rustcode = rustcode.replace(r"pub unsafe fn _evtimer_msg_handler", r#"pub unsafe extern "C" fn _evtimer_msg_handler"#);
194+
// C2Rust still generates old-style ASM -- workaround for https://github.com/immunant/c2rust/issues/306
195+
rustcode = rustcode.replace(" asm!(", " llvm_asm!(");
194196
// particular functions known to be const because they have macro equivalents as well
195197
// (Probably we could remove the 'extern "C"' from all functions)
196198
rustcode = rustcode.replace(r#"pub unsafe extern "C" fn mutex_init("#, r#"pub const unsafe fn mutex_init("#);

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
// when experimenting with C2Rust generated extern functions, C library fn are pulled in and they
5858
// have stuff like `pub type iovec`
5959
#![feature(extern_types)]
60+
// eg. for irq_enable on arm
61+
#![feature(llvm_asm)]
6062

6163
pub mod libc;
6264

0 commit comments

Comments
 (0)