tsgates / rust.ko

A minimal Linux kernel module written in rust.
896 stars 66 forks source link

Does not work with recent Rust versions #12

Closed perlun closed 8 years ago

perlun commented 8 years ago

It seems like there have been a bit of changes, so that e.g. #![feature(libc)] and #![feature(core)] aren't readily available any more. Are you able to compile this code yourself w/ rustc 1.2 or newer versions?

perlun commented 8 years ago

Correction: this is the error I'm getting with the most recent nightly. (Hadn't actually tried to compile your code, but was getting errors when copying the approach into my own project.)

/usr/local/bin/rustc -O -C code-model=kernel -C relocation-model=static --crate-type lib -o main.o --emit obj main.rs
main.rs:8:1: 8:19 error: an external crate named `core` has already been imported into this module [E0259]
main.rs:8 extern crate core;
          ^~~~~~~~~~~~~~~~~~
main.rs:8:1: 8:19 help: run `rustc --explain E0259` to see a detailed explanation
error: aborting due to previous error
make: *** [main.o] Error 101
perlun commented 8 years ago

The above is with rustc 1.4.0-beta (i.e. nightly). If I switch to the stable channel, I get this instead:

/usr/local/bin/rustc -O -C code-model=kernel -C relocation-model=static --crate-type lib -o main.o --emit obj main.rs
main.rs:1:1: 1:18 error: #[feature] may not be used on the stable release channel
main.rs:1 #![feature(core)]
          ^~~~~~~~~~~~~~~~~
main.rs:2:1: 2:26 error: #[feature] may not be used on the stable release channel
main.rs:2 #![feature(core_str_ext)]
          ^~~~~~~~~~~~~~~~~~~~~~~~~
main.rs:3:1: 3:18 error: #[feature] may not be used on the stable release channel
main.rs:3 #![feature(libc)]
          ^~~~~~~~~~~~~~~~~
main.rs:4:1: 4:20 error: #[feature] may not be used on the stable release channel
main.rs:4 #![feature(no_std)]
          ^~~~~~~~~~~~~~~~~~~
error: aborting due to 4 previous errors
make: *** [main.o] Error 101

I think it says the same if you try w/ the unstable channel as well.

cuviper commented 8 years ago

You definitely need #![no_std] for kernel code, and for now this is still feature gated, so it can't be used on the stable channel.

It does look like extern crate core; and #![feature(core)] aren't needed in main.rs anymore.

johnjelinek commented 8 years ago

Can the Makefile be replaced by cargo?