[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240304141426.163517-1-wangrui@loongson.cn>
Date: Mon, 4 Mar 2024 22:14:26 +0800
From: WANG Rui <wangrui@...ngson.cn>
To: Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Huacai Chen <chenhuacai@...nel.org>
Cc: Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...sung.com>,
Alice Ryhl <aliceryhl@...gle.com>,
Jamie Cunliffe <Jamie.Cunliffe@....com>,
Catalin Marinas <catalin.marinas@....com>,
WANG Xuerui <kernel@...0n.name>,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
loongarch@...ts.linux.dev,
loongson-kernel@...ts.loongnix.cn,
WANG Rui <wangrui@...ngson.cn>
Subject: [PATCH] loongarch: rust: Switch to use built-in rustc target
This commit switches to using the built-in rustc
loongarch64-unknown-none-softfloat target for LoongArch.
The Rust samples have been tested with this commit.
Signed-off-by: WANG Rui <wangrui@...ngson.cn>
---
base-commit: ("rust: Refactor the build target to allow the use of builtin targets")
Link: https://lore.kernel.org/r/20231020155056.3495121-2-Jamie.Cunliffe@arm.com
---
arch/loongarch/Makefile | 2 +-
rust/Makefile | 2 +-
scripts/Makefile | 2 +-
scripts/generate_rust_target.rs | 7 +------
4 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index df6caf79537a..17aabe7b0315 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -101,7 +101,7 @@ ifdef CONFIG_OBJTOOL
KBUILD_CFLAGS += -fno-jump-tables
endif
-KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
+KBUILD_RUSTFLAGS += --target=loongarch64-unknown-none-softfloat
KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=pic
ifeq ($(CONFIG_RELOCATABLE),y)
diff --git a/rust/Makefile b/rust/Makefile
index fe045dbc701e..cb40a1ce1331 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -437,7 +437,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)
-ifneq ($(or $(CONFIG_X86_64),$(CONFIG_LOONGARCH)),)
+ifdef CONFIG_X86_64
$(obj)/core.o: scripts/target.json
endif
diff --git a/scripts/Makefile b/scripts/Makefile
index bc90520a5426..fe56eeef09dd 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -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
-ifneq ($(or $(CONFIG_X86_64),$(CONFIG_LOONGARCH)),)
+ifdef CONFIG_X86_64
always-$(CONFIG_RUST) += target.json
filechk_rust_target = $< < include/config/auto.conf
diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
index 54919cf48621..acd3b1acef83 100644
--- a/scripts/generate_rust_target.rs
+++ b/scripts/generate_rust_target.rs
@@ -164,12 +164,7 @@ fn main() {
ts.push("llvm-target", "x86_64-linux-gnu");
ts.push("target-pointer-width", "64");
} else if cfg.has("LOONGARCH") {
- ts.push("arch", "loongarch64");
- ts.push("data-layout", "e-m:e-p:64:64-i64:64-i128:128-n64-S128");
- ts.push("features", "-f,-d");
- ts.push("llvm-target", "loongarch64-linux-gnusf");
- ts.push("llvm-abiname", "lp64s");
- ts.push("target-pointer-width", "64");
+ panic!("loongarch uses the builtin rustc loongarch64-unknown-none-softfloat target");
} else {
panic!("Unsupported architecture");
}
--
2.44.0
Powered by blists - more mailing lists