Skip to content

Commit e7e4044

Browse files
author
Jason NI (nixin)
committed
Fixed build issues for latest rust nightly.
1 parent d0f609e commit e7e4044

File tree

8 files changed

+31
-22
lines changed

8 files changed

+31
-22
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ authors = ["Alex Gaynor <[email protected]>"]
77
bitflags = "1"
88

99
[build-dependencies]
10-
bindgen = "*"
10+
bindgen = "0.47.3"
1111
cc = "1.0"
1212
shlex = "0.1"

hello-world/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "hello-world"
33
version = "0.1.0"
44
authors = ["Geoffrey Thomas <[email protected]>"]
5+
edition = "2018"
56

67
[lib]
78
crate-type = ["staticlib"]

hello-world/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
extern crate alloc;
55
use alloc::borrow::ToOwned;
6-
use alloc::String;
6+
//use alloc::String;
7+
use alloc::string::String;
78

89
#[macro_use]
910
extern crate linux_kernel_module;

src/allocator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::alloc::{AllocErr, GlobalAlloc, Layout};
1+
use core::alloc::{GlobalAlloc, Layout};
22

33
use bindings;
44
use c_types;
@@ -22,6 +22,6 @@ unsafe impl GlobalAlloc for KernelAllocator {
2222
}
2323

2424
#[lang = "oom"]
25-
extern "C" fn oom(_err: AllocErr) -> ! {
26-
panic!("Out of memory!");
25+
extern "C" fn oom(layout: Layout) -> ! {
26+
panic!("Out of memory! {}", layout.size());
2727
}

src/filesystem.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use core::mem;
66
use bindings;
77
use c_types;
88
use error;
9+
use println;
910

1011
pub struct FileSystemRegistration<T: FileSystem> {
1112
_phantom: marker::PhantomData<T>,
@@ -58,6 +59,7 @@ extern "C" fn mount_callback<T: FileSystem>(
5859
_dev_name: *const c_types::c_char,
5960
data: *mut c_types::c_void,
6061
) -> *mut bindings::dentry {
62+
println!("==== {:?} - {:?}", fs_type, flags);
6163
unsafe { bindings::mount_nodev(fs_type, flags, data, Some(fill_super_callback::<T>)) }
6264
}
6365

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![no_std]
2-
#![feature(alloc, allocator_api, const_fn, lang_items, panic_implementation)]
2+
#![feature(alloc, allocator_api, const_fn, lang_items)]
33

44
#[macro_use]
55
extern crate alloc;
@@ -66,15 +66,15 @@ macro_rules! kernel_module {
6666
};
6767
}
6868

69-
pub trait KernelModule: Sized + Sync {
69+
pub trait KernelModule: Sized {
7070
fn init() -> KernelResult<Self>;
7171
}
7272

7373
extern "C" {
7474
fn bug_helper() -> !;
7575
}
7676

77-
#[panic_implementation]
77+
#[panic_handler]
7878
fn panic(_info: &PanicInfo) -> ! {
7979
unsafe {
8080
bug_helper();

src/printk.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,22 @@ impl fmt::Write for LogLineWriter {
4444
}
4545
}
4646

47-
#[macro_export]
48-
macro_rules! println {
49-
() => ({
50-
$crate::printk::printk("\n".as_bytes());
51-
});
52-
($fmt:expr) => ({
53-
$crate::printk::printk(concat!($fmt, "\n").as_bytes());
54-
});
55-
($fmt:expr, $($arg:tt)*) => ({
56-
use ::core::fmt;
57-
let mut writer = $crate::printk::LogLineWriter::new();
58-
let _ = fmt::write(&mut writer, format_args!(concat!($fmt, "\n"), $($arg)*)).unwrap();
59-
$crate::printk::printk(writer.as_bytes());
60-
});
47+
#[macro_use]
48+
mod printk {
49+
50+
#[macro_export]
51+
macro_rules! println {
52+
() => ({
53+
$crate::printk::printk("\n".as_bytes());
54+
});
55+
($fmt:expr) => ({
56+
$crate::printk::printk(concat!($fmt, "\n").as_bytes());
57+
});
58+
($fmt:expr, $($arg:tt)*) => ({
59+
use ::core::fmt;
60+
let mut writer = $crate::printk::LogLineWriter::new();
61+
let _ = fmt::write(&mut writer, format_args!(concat!($fmt, "\n"), $($arg)*)).unwrap();
62+
$crate::printk::printk(writer.as_bytes());
63+
});
64+
}
6165
}

x86_64-linux-kernel-module.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"-m64"
2323
]
2424
},
25+
"needs-plt": true,
2526
"relocation-model": "static",
2627
"relro-level": "full",
2728
"target-c-int-width": "32",

0 commit comments

Comments
 (0)