Skip to content

Commit 90868ff

Browse files
heiherchenhuacai
authored andcommitted
LoongArch: Enable initial Rust support
Enable initial Rust support for LoongArch. Tested-by: Miguel Ojeda <[email protected]> Signed-off-by: WANG Rui <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent f58b0ab commit 90868ff

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

Documentation/rust/arch-support.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ which uses ``libclang``.
1212
Below is a general summary of architectures that currently work. Level of
1313
support corresponds to ``S`` values in the ``MAINTAINERS`` file.
1414

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+
============= ================ ==============================================
2122

arch/loongarch/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ config LOONGARCH
140140
select HAVE_REGS_AND_STACK_ACCESS_API
141141
select HAVE_RETHOOK
142142
select HAVE_RSEQ
143+
select HAVE_RUST
143144
select HAVE_SAMPLE_FTRACE_DIRECT
144145
select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
145146
select HAVE_SETUP_PER_CPU_AREA if NUMA

arch/loongarch/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ KBUILD_AFLAGS_MODULE += -Wa,-mla-global-with-abs
8181
KBUILD_CFLAGS_MODULE += -fplt -Wa,-mla-global-with-abs,-mla-local-with-abs
8282
endif
8383

84+
KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=pic
85+
8486
ifeq ($(CONFIG_RELOCATABLE),y)
8587
KBUILD_CFLAGS_KERNEL += -fPIE
88+
KBUILD_RUSTFLAGS_KERNEL += -Crelocation-model=pie
8689
LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext $(call ld-option, --apply-dynamic-relocs)
8790
endif
8891

scripts/generate_rust_target.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ fn main() {
161161
ts.push("features", features);
162162
ts.push("llvm-target", "x86_64-linux-gnu");
163163
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");
164171
} else {
165172
panic!("Unsupported architecture");
166173
}

0 commit comments

Comments
 (0)