From patchwork Mon Jan 8 03:21:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Rui X-Patchwork-Id: 185800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp810276dyq; Sun, 7 Jan 2024 19:22:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUJ8b+5NsBizR65Eafiwfh86dk1NnCMlxysxH+UnZC6DVuKeqy6EC2AX+/dFRoTRz8w6nJ X-Received: by 2002:a50:875b:0:b0:556:8c9e:5087 with SMTP id 27-20020a50875b000000b005568c9e5087mr1651503edv.85.1704684176358; Sun, 07 Jan 2024 19:22:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704684176; cv=none; d=google.com; s=arc-20160816; b=zmZSL4zktpnEj4zBjEolY3vb1/Zooa96/pvtkCNT8R0LAWvFQ0kydJfJjD3GOtCr5H jWJ69lLzy3vqmd2MejSr6HrPBRjwnmZovmAFDj6kMEMnHCPI035ZO9vAQZ7iaO/t1tXQ Q4C+7G5L4nrfZC7edrHQ0iGPaRMScW4VLly2u67/3emqrFm1tOuAClJsf7TL/G/s+tWl g3E73seonNdSJbMiK4E38BdXWv27D7365JLdSIDNGYj6dCtwVouJTeWiFyD4byDGMLdk lK06EOCwn1czpLPROvnAYNzochpVQoPpqcPZ75ASQEuoR1juJXETBoJ2FOE6poCT5t81 L5HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=WxjZczdC9ffq7uGKqth69fVhmwTtR3ZsJEVPNl5DEC0=; fh=RGFtQ7AhSb96yhUUo5QasDYPReqVInzjoTKXixObO6U=; b=ib+XR9ihxpBw/nPIfzqlwlxjjAo3/lrR7Z+ykg4WY2Ok9QGeuX6IBJK6FZIZl/ahxV nTwNhC77bPPfasFwlzyXK/5b7gTiIm1FZTJLyda24FKQmbAu/Jc2OB2lT5ptS16NJW0L VNUdYe0V9H8szUh6l+2exYfAo/1FJcYNP3Q6tnEZCCcjm7I5po3PEUzTZ8yuy3CHLTHi AaGKnjhHB8pTZNTFJqHCTyPfhBoYmA+kIzeDmoUrzEWckHNeLJ9K5nHAVKo+WP4P0JlN hG+1JgzMOA4BikpGVRKH/d3aPLJMEQ+9Q6+VwntgcNKbFsWpw3l30dsfYGAGKVqw8Xd9 421g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19062-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19062-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z14-20020a509e0e000000b00553456e44a3si2782819ede.602.2024.01.07.19.22.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 19:22:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19062-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19062-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19062-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B6B8D1F21595 for ; Mon, 8 Jan 2024 03:22:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4044BA56; Mon, 8 Jan 2024 03:21:43 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org 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_Roy_Baron?= , 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 X-CM-TRANSID: AQAAf8CxO9wxaptlNuUGAA--.17925S4 X-CM-SenderInfo: pzdqw2txl6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWxWr4xWr4xGr4fWr13CFWDKFX_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_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jHv3bUUUUU= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787490914768802553 X-GMAIL-MSGID: 1787490914768802553 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. ============= ================ ============================================== Architecture Level of support Constraints ============= ================ ============================================== +``loongarch`` Maintained - ``um`` Maintained ``x86_64`` only. ``x86`` Maintained ``x86_64`` only. ============= ================ ============================================== 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 += -Wa,-mla-global-with-abs KBUILD_CFLAGS_MODULE += -fplt -Wa,-mla-global-with-abs,-mla-local-with-abs endif +KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=pic + ifeq ($(CONFIG_RELOCATABLE),y) KBUILD_CFLAGS_KERNEL += -fPIE +KBUILD_RUSTFLAGS_KERNEL += -Crelocation-model=pie LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext $(call ld-option, --apply-dynamic-relocs) endif 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"); }