LoongArch: rust: Switch to use built-in rustc target
authorWANG Rui <wangrui@loongson.cn>
Tue, 14 May 2024 04:24:18 +0000 (12:24 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Tue, 14 May 2024 04:24:18 +0000 (12:24 +0800)
This commit switches to use the LoongArch's built-in rustc target
'loongarch64-unknown-none-softfloat'. The Rust samples have been tested.

Acked-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/Makefile
rust/Makefile
scripts/Makefile
scripts/generate_rust_target.rs

index df6caf79537a9d884aa97161a32840782147460e..4347915721bd9bb549df58c38331cd70fa7cb9a8 100644 (file)
@@ -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)
index 86a125c4243cb2e5eba7f906417be4602bd8b738..a1eab64140ada52c89b805cdc83f70edcf15c3c2 100644 (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)
-ifneq ($(or $(CONFIG_X86_64),$(CONFIG_LOONGARCH)),)
+ifdef CONFIG_X86_64
 $(obj)/core.o: scripts/target.json
 endif
 
index bc90520a54266cc1d9cd2584ccde4e874f3827a7..fe56eeef09dd49bdda9436463fddbf2740f96422 100644 (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
 
-ifneq ($(or $(CONFIG_X86_64),$(CONFIG_LOONGARCH)),)
+ifdef CONFIG_X86_64
 always-$(CONFIG_RUST)                                  += target.json
 filechk_rust_target = $< < include/config/auto.conf
 
index 54919cf48621e897868677169ddf5e29482969a3..acd3b1acef83777800461a5494f82b1367641c8b 100644 (file)
@@ -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");
     }