aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Crane <cranes@google.com>2024-03-07 22:28:23 +0000
committerStephen Crane <cranes@google.com>2024-03-12 00:19:21 +0000
commitaa965d741be8d42f010f9b336295a2fe968eda3e (patch)
tree6e8daeb4506a71e4cc76ff26c523f7555f4a7402
parentd2ac19e08be4593dbb5005c3e44e0bb0baa85704 (diff)
downloadcommon-aa965d741be8d42f010f9b336295a2fe968eda3e.tar.gz
make: Add rust x86-64 target for the kernel
Rust in the kernel needs to not use floating point and SSE registers. Bug: 304850822 Test: build.py generic-x86_64-test Change-Id: I582aaf5c1de33805ff9a41f05df20a310d30d01d
-rw-r--r--arch/x86/toolchain.mk8
-rw-r--r--arch/x86/x86_64-unknown-trusty-kernel.json28
2 files changed, 36 insertions, 0 deletions
diff --git a/arch/x86/toolchain.mk b/arch/x86/toolchain.mk
index 691eb61c..d6628991 100644
--- a/arch/x86/toolchain.mk
+++ b/arch/x86/toolchain.mk
@@ -1,3 +1,5 @@
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
# x86-32 toolchain
ifeq ($(SUBARCH),x86-32)
ifndef ARCH_x86_TOOLCHAIN_INCLUDED
@@ -26,7 +28,13 @@ ARCH_x86_COMPILEFLAGS += -target x86_64-$(CLANG_X86_64_TARGET_SYS)-$(CLANG_X86_6
# Set Rust target to match clang target
ARCH_x86_SUPPORTS_RUST := true
+ifeq (true,$(call TOBOOL,$(TRUSTY_USERSPACE)))
ARCH_x86_RUSTFLAGS := --target=x86_64-unknown-trusty
+else
+# Use custom toolchain file that disables hardware floating point
+ARCH_x86_RUSTFLAGS := --target=$(LOCAL_DIR)/x86_64-unknown-trusty-kernel.json
+endif
+
endif
endif
diff --git a/arch/x86/x86_64-unknown-trusty-kernel.json b/arch/x86/x86_64-unknown-trusty-kernel.json
new file mode 100644
index 00000000..8adbe456
--- /dev/null
+++ b/arch/x86/x86_64-unknown-trusty-kernel.json
@@ -0,0 +1,28 @@
+{
+ "arch": "x86_64",
+ "cpu": "x86-64",
+ "crt-objects-fallback": "musl",
+ "crt-static-default": true,
+ "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
+ "dynamic-linking": false,
+ "env": "musl",
+ "has-rpath": false,
+ "linker-flavor": "gnu-cc",
+ "llvm-target": "x86_64-unknown-unknown-musl",
+ "max-atomic-width": 64,
+ "os": "trusty",
+ "panic-strategy": "abort",
+ "plt-by-default": false,
+ "relro-level": "full",
+ "stack-probes": {
+ "kind": "inline-or-call",
+ "min-llvm-version-for-inline": [
+ 16,
+ 0,
+ 0
+ ]
+ },
+ "static-position-independent-executables": true,
+ "target-pointer-width": "64",
+ "features": "-3dnow,-3dnowa,-mmx,-sse,-sse2,+soft-float"
+}