Skip to content

Commit

Permalink
Acknowledge that assebly can be pulled in through static inlines
Browse files Browse the repository at this point in the history
including all the necessary workarounds

See-Also: immunant/c2rust#306
See-Also: immunant/c2rust#307
  • Loading branch information
chrysn committed Sep 20, 2020
1 parent 833d8ea commit 83d8bd4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ default-target = "i686-unknown-linux-gnu"

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

[build-dependencies]
bindgen = "0.53.1"
Expand Down
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ static {type_name} init_{macro_name}(void) {{
rustcode = rustcode.replace(" #[no_mangle]\n fn ", " #[no_mangle]\n pub fn ");
// used as a callback, therefore does need the extern "C" -- FIXME probably worth a RIOT issue
rustcode = rustcode.replace(r"pub unsafe fn _evtimer_msg_handler", r#"pub unsafe extern "C" fn _evtimer_msg_handler"#);
// C2Rust still generates old-style ASM -- workaround for https://github.com/immunant/c2rust/issues/306
rustcode = rustcode.replace(" asm!(", " llvm_asm!(");
// particular functions known to be const because they have macro equivalents as well
// (Probably we could remove the 'extern "C"' from all functions)
rustcode = rustcode.replace(r#"pub unsafe extern "C" fn mutex_init("#, r#"pub const unsafe fn mutex_init("#);
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
// when experimenting with C2Rust generated extern functions, C library fn are pulled in and they
// have stuff like `pub type iovec`
#![feature(extern_types)]
// eg. for irq_enable on arm
#![feature(llvm_asm)]

pub mod libc;

Expand Down

0 comments on commit 83d8bd4

Please sign in to comment.