Skip to content

Commit 8311cae

Browse files
authored
Merge pull request raspberrypi#635 from ojeda/attr
rust: avoid the need of crate attributes in kernel modules
2 parents ea924a7 + 59c8746 commit 8311cae

14 files changed

+5
-41
lines changed

drivers/android/rust_binder.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
//!
55
//! TODO: This module is a work in progress.
66
7-
#![no_std]
8-
#![feature(global_asm, allocator_api, concat_idents, generic_associated_types)]
9-
107
use kernel::{
118
io_buffer::IoBufferWriter,
129
linked_list::{GetLinks, GetLinksWrapped, Links},

drivers/char/hw_random/bcm2835_rng_rust.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Broadcom BCM2835 Random Number Generator support.
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::{
96
c_str, device, file::File, file_operations::FileOperations, io_buffer::IoBufferWriter, miscdev,
107
module_platform_driver, of, platform, prelude::*, sync::Ref,

drivers/gpio/gpio_pl061_rust.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
//!
55
//! Based on the C driver written by Baruch Siach <baruch@tkos.co.il>.
66
7-
#![no_std]
8-
#![feature(global_asm, allocator_api)]
9-
107
use kernel::{
118
amba, bit, bits_iter, define_amba_id_table, device, gpio,
129
io_mem::IoMem,

samples/rust/rust_chrdev.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust character device sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96
use kernel::{chrdev, file, file_operations::FileOperations};
107

samples/rust/rust_minimal.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust minimal sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96

107
module! {

samples/rust/rust_miscdev.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust miscellaneous device sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96
use kernel::{
107
file::File,

samples/rust/rust_module_parameters.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust module parameters sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96

107
module! {

samples/rust/rust_platform.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust platform device driver sample.
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::{module_platform_driver, of, platform, prelude::*};
96

107
module_platform_driver! {

samples/rust/rust_print.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust printing macros sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96
use kernel::{pr_cont, str::CStr, ThisModule};
107

samples/rust/rust_random.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
//! Adapted from Alex Gaynor's original available at
66
//! <https://github.com/alex/just-use/blob/master/src/lib.rs>.
77
8-
#![no_std]
9-
#![feature(allocator_api, global_asm)]
10-
118
use kernel::{
129
file::File,
1310
file_operations::FileOperations,

samples/rust/rust_semaphore.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
//! before decrementing); `echo -n 123 > semaphore` increments the semaphore by 3, potentially
1414
//! unblocking up to 3 blocked readers.
1515
16-
#![no_std]
17-
#![feature(allocator_api, global_asm, generic_associated_types)]
18-
1916
use core::sync::atomic::{AtomicU64, Ordering};
2017
use kernel::{
2118
condvar_init, declare_file_operations,

samples/rust/rust_stack_probing.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
//! Rust stack probing sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
#![feature(bench_black_box)]
8-
95
use kernel::prelude::*;
106

117
module! {

samples/rust/rust_sync.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust synchronisation primitives sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96
use kernel::{
107
condvar_init, mutex_init, spinlock_init,

scripts/Makefile.build

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,15 @@ $(obj)/%.lst: $(src)/%.c FORCE
331331
# otherwise rustdoc and rustc compute different hashes for the target.
332332
rust_cross_flags := --target=$(realpath $(KBUILD_RUST_TARGET))
333333

334+
rust_allowed_features := allocator_api,bench_black_box,concat_idents,generic_associated_types,global_asm
335+
334336
quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
335337
cmd_rustc_o_rs = \
336338
RUST_MODFILE=$(modfile) \
337339
$(RUSTC_OR_CLIPPY) $(rust_flags) $(rust_cross_flags) \
338-
-Zallow-features=allocator_api,bench_black_box,concat_idents,generic_associated_types,global_asm \
340+
-Zallow-features=$(rust_allowed_features) \
341+
-Zcrate-attr=no_std \
342+
-Zcrate-attr='feature($(rust_allowed_features))' \
339343
--extern alloc --extern kernel \
340344
--crate-type rlib --out-dir $(obj) -L $(objtree)/rust/ \
341345
--crate-name $(patsubst %.o,%,$(notdir $@)) $<; \

0 commit comments

Comments
 (0)