From ce2e2c2ca0a5f07b505b90ec214f66646cc31d0d Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 5 Sep 2019 19:18:32 -0500 Subject: [PATCH] Use target from rust itself --- .travis.yml | 2 +- README.md | 2 +- build.rs | 4 ++-- hello-world/Makefile | 2 +- tests/Makefile | 2 +- tests/run_tests.py | 5 +---- x86_64-linux-kernel-module.json | 32 -------------------------------- 7 files changed, 7 insertions(+), 42 deletions(-) delete mode 100644 x86_64-linux-kernel-module.json diff --git a/.travis.yml b/.travis.yml index 14fba324..163003fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ matrix: language: rust rust: - - nightly-2019-08-15 + - nightly-2019-09-11 cache: - cargo: true diff --git a/README.md b/README.md index db4d085f..aca44e0d 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ cd hello-world 3. Build the static object with cargo xbuild, pointing it at our custom target ``` -cargo xbuild --target $(pwd)/../x86_64-linux-kernel-module.json +cargo xbuild --target x86_64-linux-kernel ``` 4. Build the kernel module using the Linux kernel build system (kbuild) diff --git a/build.rs b/build.rs index dac6a769..9edfc026 100644 --- a/build.rs +++ b/build.rs @@ -108,7 +108,7 @@ fn main() { .derive_default(true) .rustfmt_bindings(true); - builder = builder.clang_arg("--target=x86_64-linux-kernel-module"); + builder = builder.clang_arg("--target=x86_64-linux-kernel"); for arg in shlex::split(std::str::from_utf8(&output.stdout).unwrap()).unwrap() { builder = builder.clang_arg(arg.to_string()); } @@ -140,7 +140,7 @@ fn main() { let mut builder = cc::Build::new(); println!("cargo:rerun-if-env-changed=CLANG"); builder.compiler(env::var("CLANG").unwrap_or("clang".to_string())); - builder.target("x86_64-linux-kernel-module"); + builder.target("x86_64-linux-kernel"); builder.warnings(false); builder.file("src/helpers.c"); for arg in shlex::split(std::str::from_utf8(&output.stdout).unwrap()).unwrap() { diff --git a/hello-world/Makefile b/hello-world/Makefile index b35b71bf..e894f8e6 100644 --- a/hello-world/Makefile +++ b/hello-world/Makefile @@ -2,7 +2,7 @@ obj-m := helloworld.o helloworld-objs := hello_world.rust.o KDIR ?= /lib/modules/$(shell uname -r)/build -%.rust.o: target/x86_64-linux-kernel-module/debug/lib%.a +%.rust.o: target/x86_64-linux-kernel/debug/lib%.a $(LD) -r -o $@ --whole-archive $< all: diff --git a/tests/Makefile b/tests/Makefile index 73d4d50d..024e3abc 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,7 +2,7 @@ obj-m := testmodule.o testmodule-objs := $(TEST_NAME).rust.o KDIR ?= /lib/modules/$(shell uname -r)/build -%.rust.o: target/x86_64-linux-kernel-module/debug/lib%.a +%.rust.o: target/x86_64-linux-kernel/debug/lib%.a $(LD) -r -o $@ --whole-archive $< all: diff --git a/tests/run_tests.py b/tests/run_tests.py index 56050f48..d5932dab 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -27,10 +27,7 @@ def main(): print("+ [{}]".format(path)) run( "cargo", "xbuild", - "--target", - os.path.join( - BASE_DIR, os.path.pardir, "x86_64-linux-kernel-module.json" - ), + "--target", "x86_64-linux-kernel", cwd=os.path.join(BASE_DIR, path), environ=dict( os.environ, diff --git a/x86_64-linux-kernel-module.json b/x86_64-linux-kernel-module.json deleted file mode 100644 index 5f7174ea..00000000 --- a/x86_64-linux-kernel-module.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "arch": "x86_64", - "cpu": "x86-64", - "code-model": "kernel", - "data-layout": "e-m:e-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", - "linker-flavor": "gcc", - "linker-is-gnu": true, - "llvm-target": "x86_64-elf", - "max-atomic-width": 64, - "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", - "needs-plt": true, - "target-c-int-width": "32", - "target-endian": "little", - "target-family": "unix", - "target-pointer-width": "64", - "vendor": "unknown" -}