Skip to content
This repository has been archived by the owner on Mar 7, 2021. It is now read-only.

Automated conversion from C to Rust #151

Open
XVilka opened this issue Aug 30, 2019 · 10 comments
Open

Automated conversion from C to Rust #151

XVilka opened this issue Aug 30, 2019 · 10 comments

Comments

@XVilka
Copy link

XVilka commented Aug 30, 2019

Idea is to provide the framework for automated conversion using c2rust, as they do for the user-space programs.

Corresponding issue in c2rust itself: immunant/c2rust#150

@geofft
Copy link
Collaborator

geofft commented Aug 30, 2019

Interesting! I think the two things to do are

  • use the c_types module in this crate instead of the libc crate (analogous to bindgen builder.ctypes_prefix("c_types"))
  • make sure FFI calls go through bindings

Do you have an idea of what a good first target would be?

@geofft
Copy link
Collaborator

geofft commented Aug 30, 2019

Hmmmm, seems like c2rust handles macros just fine. I wonder if we want to use it to process src/helpers.c instead of compiling that as a separate C object. Since helpers.c is a separate translation unit, calls to macros can't get inlined and get a bit slow.

@alex
Copy link
Member

alex commented Aug 31, 2019

FWIW, calls across translation units are inlinable if we use LTO.

@rinon
Copy link

rinon commented Sep 3, 2019

Just wanted to pop over here to say we're definitely interested in making it easier to get c2rust working on kernel modules. We've translated one module so far, and things seems to work fairly well after we improved support for a bunch of gcc-isms.

Automatically refactoring the initial output of c2rust to use your types and bindings ought to be fairly straightforward and might be a good path to better usability.

@XVilka
Copy link
Author

XVilka commented Dec 24, 2019

Sorry for the noise, but were there any updates regarding this goal/blog post?

@rinon
Copy link

rinon commented Dec 27, 2019

We're still planning to put up a blog post on using C2Rust for a kernel module, hopefully in January.

@marcograss
Copy link

is there any update on the blogpost for c2rusting a kernel module? I'm really looking forward to it

@rinon
Copy link

rinon commented Apr 30, 2020

Not yet, but thanks for the reminder. It had to get pushed back a bit because of other things taking priority. However, definitely still going to happen, hopefully can write it soon!

@stappersg
Copy link

Which kernel module has been c 2 rust? Is it virtio-net? ( Context #260 )

@elichai
Copy link

elichai commented Oct 28, 2020

FWIW last time I checked c2rust violates rust's aliasing rules (or proposed aliasing rules) although it can be solved by using raw references(rust-lang/rust#73394)

Stacked borrows(rust's proposed aliasing rules): https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md

EDIT: I think this is the right tracking issue: immunant/c2rust#301

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants