Skip to content

Test that __rust_probestack can be linked #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions drivers/char/rust_example_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ impl KernelModule for RustExample3 {
println!("[3] Parameters:");
println!("[3] my_bool: {}", my_bool.read());
println!("[3] my_i32: {}", my_i32.read());

// Including this large variable on the stack will trigger a call to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! The 2/3/4 examples are intended to be copy-pastes of the first one (for the CI). Can you please put this into all of them?

In the future we will probably move these runtime tests somewhere else, but for now it is good to have them here. +1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// `compiler_builtins::probestack::__rust_probestack` on x86_64.
// This will verify that we are able to link modules which call
// `__rust_probestack`.
let x: [u64; 1028] = [5; 1028];
println!("Large array has length: {}", x.len());

Ok(RustExample3 {
message: "on the heap!".to_owned(),
})
Expand Down
5 changes: 5 additions & 0 deletions rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ obj-$(CONFIG_RUST) += core.o compiler_builtins.o alloc.o kernel.o
extra-$(CONFIG_RUST) += bindings_generated.rs libmodule.so
extra-$(CONFIG_RUST) += exports_core_generated.h exports_alloc_generated.h
extra-$(CONFIG_RUST) += exports_kernel_generated.h
extra-$(CONFIG_RUST) += exports_compiler_builtins_generated.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Suggested change
extra-$(CONFIG_RUST) += exports_core_generated.h exports_alloc_generated.h
extra-$(CONFIG_RUST) += exports_kernel_generated.h
extra-$(CONFIG_RUST) += exports_compiler_builtins_generated.h
extra-$(CONFIG_RUST) += exports_core_generated.h
extra-$(CONFIG_RUST) += exports_compiler_builtins_generated.h
extra-$(CONFIG_RUST) += exports_alloc_generated.h
extra-$(CONFIG_RUST) += exports_kernel_generated.h


ifdef CONFIG_CC_IS_CLANG
bindgen_c_flags = $(c_flags)
Expand Down Expand Up @@ -62,6 +63,10 @@ $(objtree)/rust/exports_kernel_generated.h: exports_target_type := _RUST_GPL
$(objtree)/rust/exports_kernel_generated.h: $(objtree)/rust/kernel.o FORCE
$(call if_changed,exports)

$(objtree)/rust/exports_compiler_builtins_generated.h: exports_target_type := _RUST
$(objtree)/rust/exports_compiler_builtins_generated.h: $(objtree)/rust/compiler_builtins.o FORCE
$(call if_changed,exports)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please move these in-between core and alloc? (I keep them like that due to the dependency chain).

quiet_cmd_rustc_procmacro = RUSTC P $@
cmd_rustc_procmacro = \
$(RUSTC) $(rustc_flags) --edition 2018 --extern proc_macro \
Expand Down
1 change: 1 addition & 0 deletions rust/exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
#include "exports_core_generated.h"
#include "exports_alloc_generated.h"
#include "exports_kernel_generated.h"
#include "exports_compiler_builtins_generated.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same please.