ANDROID: rust: use target.json for aarch64

Enabling Rust currently prints the following warning to the log:

	warning: unknown feature specified for `-Ctarget-feature`: `reserve-x18`
	  |
	  = note: it is still passed through to the codegen backend
	  = help: consider filing a feature request

The best way to fix this warning would be to backport the relevant
one-line change in the Rust compiler to our 1.73.0 compiler and make a
respin. However, as a temporary measure until such a respin happens, we
can silence the warning by using a target.json for aarch64.

Bug: 348496478
Change-Id: I3fce783d6f7be1c72d00f8b59fb248a78bfefaae
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
Alice Ryhl 2024-06-21 13:16:45 +00:00 committed by Matthias Männich
parent 1656e8d99d
commit 3396c2131d
4 changed files with 17 additions and 5 deletions

View File

@ -41,7 +41,7 @@ KBUILD_CFLAGS += -mgeneral-regs-only \
KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
KBUILD_AFLAGS += $(compat_vdso)
KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"
KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
KBUILD_CFLAGS += $(call cc-option,-mabi=lp64)
KBUILD_AFLAGS += $(call cc-option,-mabi=lp64)
@ -110,7 +110,6 @@ endif
ifeq ($(CONFIG_SHADOW_CALL_STACK), y)
KBUILD_CFLAGS += -ffixed-x18
KBUILD_RUSTFLAGS += -Ctarget-feature=+reserve-x18
endif
ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)

View File

@ -436,7 +436,7 @@ $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--re
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
$(call if_changed_dep,rustc_library)
ifdef CONFIG_X86_64
ifneq ($(or $(CONFIG_X86_64),$(CONFIG_ARM64)),)
$(obj)/core.o: scripts/target.json
endif

View File

@ -12,7 +12,7 @@ hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder
hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen
ifdef CONFIG_X86_64
ifneq ($(or $(CONFIG_X86_64),$(CONFIG_ARM64)),)
always-$(CONFIG_RUST) += target.json
filechk_rust_target = $< < include/config/auto.conf

View File

@ -173,7 +173,20 @@ fn main() {
// `llvm-target`s are taken from `scripts/Makefile.clang`.
if cfg.has("ARM64") {
panic!("arm64 uses the builtin rustc aarch64-unknown-none target");
ts.push("arch", "aarch64");
ts.push(
"data-layout",
"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
);
ts.push("disable-redzone", true);
let mut features = "+v8a,+strict-align,+neon,+fp-armv8".to_string();
if cfg.has("SHADOW_CALL_STACK") {
features += ",+reserve-x18";
}
ts.push("features", features);
ts.push("llvm-target", "aarch64-linux-gnu");
ts.push("supported-sanitizers", ["kcfi"]);
ts.push("target-pointer-width", "64");
} else if cfg.has("X86_64") {
ts.push("arch", "x86_64");
ts.push(