Skip to content

Forbid rustc from using -f{function,data}-sections (fixes #20 panic) #28

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

Merged
merged 1 commit into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,9 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_RUSTCFLAGS :=
# TODO: a simple way to update `Cargo.lock` when we add a new driver
# TODO: another option is using explicit target specs, e.g.
# `--target=$(srctree)/arch/$(SRCARCH)/rust-target-spec.json`
KBUILD_CARGOFLAGS := $(CARGO_VERBOSE) --locked \
-Z build-std=core,alloc -Z unstable-options \
--out-dir=out --target=x86_64-linux-kernel
--out-dir=out --target=$(PWD)/$(srctree)/arch/$(SRCARCH)/rust/target.json
KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
KBUILD_RUSTCFLAGS_KERNEL :=
Expand Down
34 changes: 34 additions & 0 deletions arch/x86/rust/target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"arch": "x86_64",
"code-model": "kernel",
"cpu": "x86-64",
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
"disable-redzone": true,
"eliminate-frame-pointer": false,
"env": "gnu",
"features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float",
"function-sections": false,
"is-builtin": true,
"linker-flavor": "gcc",
"linker-is-gnu": true,
"llvm-target": "x86_64-elf",
"max-atomic-width": 64,
"needs-plt": true,
"os": "none",
"panic-strategy": "abort",
"position-independent-executables": true,
"pre-link-args": {
"gcc": [
"-Wl,--as-needed",
"-Wl,-z,noexecstack",
"-m64"
]
},
"relocation-model": "static",
"relro-level": "full",
"stack-probes": true,
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "64",
"vendor": "unknown"
}
3 changes: 2 additions & 1 deletion rust/kernel/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ fn main() {

let kernel_args = prepare_cflags(&cflags, &kernel_dir);

let target = env::var("TARGET").unwrap();
// TODO: pass the proper triple to bindgen
let target = "x86_64-linux-kernel";

let mut builder = bindgen::Builder::default()
.use_core()
Expand Down