immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.95k stars 234 forks source link

C2Rust transpiler emits features removed in recent nightlies #1054

Open SheldonHH opened 9 months ago

SheldonHH commented 9 months ago

I'm experiencing difficulties in building the bzip2 project, which I have converted from C to Rust using C2Rust. The original bzip2 project is hosted on GitLab, and my converted version is on GitHub.

I am unable to build the converted project, hindering any further testing or development. Below are the details:

Build Issues:

Questions:

  1. Are there known challenges or common errors when building a C2Rust converted project?
  2. What steps can be taken to resolve build issues in a project converted from C to Rust?
  3. Are there specific configurations or adjustments needed for a successful build in such cases?

I would appreciate any guidance or suggestions to resolve these build issues. Thank you for your assistance.

thedataking commented 9 months ago

Hi @SheldonHH

Thanks for your report, it would have been helpful if you'd directly included the build errors. This is what I see:

error[E0557]: feature has been removed
 --> c2rust-lib.rs:8:12
  |
8 | #![feature(const_raw_ptr_to_usize_cast)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
  |
  = note: at compile-time, pointers do not have an integer value, so these casts cannot be properly supported

error[E0557]: feature has been removed
  --> c2rust-lib.rs:12:12
   |
12 | #![feature(main)]
   |            ^^^^ feature has been removed

error: cannot find attribute `main` in this scope
    --> bzip2.rs:3164:3
     |
3164 | #[main]
     |   ^^^^
     |
     = note: `main` is in scope, but it is a function, not an attribute

error: cannot find attribute `main` in this scope
   --> bzip2recover.rs:590:3
    |
590 | #[main]
    |   ^^^^
    |
    = note: `main` is in scope, but it is a function, not an attribute

It seems that C2Rust relies on features that are no longer in the latest nightlies. As a workaround, you can build with a much older nightly until you've patched the transpiled code to remove uses of the deprecated features. This works for me:

cargo +nightly-2020-03-21 build

GPHemsley commented 1 week ago

Dupe of #46?