Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

LoongArch: Enable initial Rust support

Enable initial Rust support for LoongArch.

Tested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>

authored by

WANG Rui and committed by
Huacai Chen
90868ff9 f58b0aba

+18 -6
+7 -6
Documentation/rust/arch-support.rst
··· 12 12 Below is a general summary of architectures that currently work. Level of 13 13 support corresponds to ``S`` values in the ``MAINTAINERS`` file. 14 14 15 - ============ ================ ============================================== 16 - Architecture Level of support Constraints 17 - ============ ================ ============================================== 18 - ``um`` Maintained ``x86_64`` only. 19 - ``x86`` Maintained ``x86_64`` only. 20 - ============ ================ ============================================== 15 + ============= ================ ============================================== 16 + Architecture Level of support Constraints 17 + ============= ================ ============================================== 18 + ``loongarch`` Maintained - 19 + ``um`` Maintained ``x86_64`` only. 20 + ``x86`` Maintained ``x86_64`` only. 21 + ============= ================ ============================================== 21 22
+1
arch/loongarch/Kconfig
··· 140 140 select HAVE_REGS_AND_STACK_ACCESS_API 141 141 select HAVE_RETHOOK 142 142 select HAVE_RSEQ 143 + select HAVE_RUST 143 144 select HAVE_SAMPLE_FTRACE_DIRECT 144 145 select HAVE_SAMPLE_FTRACE_DIRECT_MULTI 145 146 select HAVE_SETUP_PER_CPU_AREA if NUMA
+3
arch/loongarch/Makefile
··· 81 81 KBUILD_CFLAGS_MODULE += -fplt -Wa,-mla-global-with-abs,-mla-local-with-abs 82 82 endif 83 83 84 + KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=pic 85 + 84 86 ifeq ($(CONFIG_RELOCATABLE),y) 85 87 KBUILD_CFLAGS_KERNEL += -fPIE 88 + KBUILD_RUSTFLAGS_KERNEL += -Crelocation-model=pie 86 89 LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext $(call ld-option, --apply-dynamic-relocs) 87 90 endif 88 91
+7
scripts/generate_rust_target.rs
··· 161 161 ts.push("features", features); 162 162 ts.push("llvm-target", "x86_64-linux-gnu"); 163 163 ts.push("target-pointer-width", "64"); 164 + } else if cfg.has("LOONGARCH") { 165 + ts.push("arch", "loongarch64"); 166 + ts.push("data-layout", "e-m:e-p:64:64-i64:64-i128:128-n64-S128"); 167 + ts.push("features", "-f,-d"); 168 + ts.push("llvm-target", "loongarch64-linux-gnusf"); 169 + ts.push("llvm-abiname", "lp64s"); 170 + ts.push("target-pointer-width", "64"); 164 171 } else { 165 172 panic!("Unsupported architecture"); 166 173 }