From nobody Sun Feb 8 22:02:30 2026 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96B248827; Mon, 8 Jan 2024 03:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [112.22.232.245]) by gateway (Coremail) with SMTP id _____8Bx2elAaptlqgQDAA--.5571S3; Mon, 08 Jan 2024 11:21:36 +0800 (CST) Received: from localhost.localdomain (unknown [112.22.232.245]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxO9wxaptlNuUGAA--.17925S4; Mon, 08 Jan 2024 11:21:33 +0800 (CST) From: WANG Rui To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Huacai Chen , Jonathan Corbet Cc: Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , WANG Xuerui , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-doc@vger.kernel.org, loongson-kernel@lists.loongnix.cn, WANG Rui Subject: [PATCH v1 2/2] LoongArch: Enable initial Rust support Date: Mon, 8 Jan 2024 11:21:17 +0800 Message-ID: <20240108032117.215171-3-wangrui@loongson.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240108032117.215171-1-wangrui@loongson.cn> References: <20240108032117.215171-1-wangrui@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxO9wxaptlNuUGAA--.17925S4 X-CM-SenderInfo: pzdqw2txl6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWxWr4xWr4xGr4fWr13CFWDKFX_yoW5Ary3pa 929r97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daVFxhVjvjDU0xZFpf9x07jHv3bUUUUU= Content-Type: text/plain; charset="utf-8" Add initial Rust support for LoongArch. Signed-off-by: WANG Rui --- Documentation/rust/arch-support.rst | 1 + arch/loongarch/Kconfig | 1 + arch/loongarch/Makefile | 3 +++ scripts/generate_rust_target.rs | 10 ++++++++++ 4 files changed, 15 insertions(+) diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-= support.rst index 14875a2e073a..73203ba1e901 100644 --- a/Documentation/rust/arch-support.rst +++ b/Documentation/rust/arch-support.rst @@ -15,6 +15,7 @@ support corresponds to ``S`` values in the ``MAINTAINERS`= ` file. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Architecture Level of support Constraints =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +``loongarch`` Maintained - ``um`` Maintained ``x86_64`` only. ``x86`` Maintained ``x86_64`` only. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 15d05dd2b7f3..6d39ec3077da 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -142,6 +142,7 @@ config LOONGARCH select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RETHOOK select HAVE_RSEQ + select HAVE_RUST select HAVE_SAMPLE_FTRACE_DIRECT select HAVE_SAMPLE_FTRACE_DIRECT_MULTI select HAVE_SETUP_PER_CPU_AREA if NUMA diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index 4ba8d67ddb09..ba45cb7b621c 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -81,8 +81,11 @@ KBUILD_AFLAGS_MODULE +=3D -Wa,-mla-global-with-abs KBUILD_CFLAGS_MODULE +=3D -fplt -Wa,-mla-global-with-abs,-mla-local-with-= abs endif =20 +KBUILD_RUSTFLAGS_MODULE +=3D -Crelocation-model=3Dpic + ifeq ($(CONFIG_RELOCATABLE),y) KBUILD_CFLAGS_KERNEL +=3D -fPIE +KBUILD_RUSTFLAGS_KERNEL +=3D -Crelocation-model=3Dpie LDFLAGS_vmlinux +=3D -static -pie --no-dynamic-linker -z notext $(call l= d-option, --apply-dynamic-relocs) endif =20 diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target= .rs index 3c6cbe2b278d..3edda6a10dd0 100644 --- a/scripts/generate_rust_target.rs +++ b/scripts/generate_rust_target.rs @@ -161,6 +161,16 @@ fn main() { ts.push("features", features); 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"); } else { panic!("Unsupported architecture"); } --=20 2.43.0