Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1407617rdb; Sun, 7 Jan 2024 19:22:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbcvfb2RNFBcjVw4/pN4v/eJyclTtfp8Lf43HrL5bA78CVcePladpp/RfpYby9eu+Pt3Fn X-Received: by 2002:a17:903:32c2:b0:1d4:a24c:b5b2 with SMTP id i2-20020a17090332c200b001d4a24cb5b2mr4145264plr.65.1704684148011; Sun, 07 Jan 2024 19:22:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704684147; cv=none; d=google.com; s=arc-20160816; b=xaqOEoMFutHYKPzpOmAM4ibwuyidGhoD1jg7p8eOqfvpmDr2ueCZ7vvIUBMCajHktH R2pkdG3lOnPwnHITBfhUKWv17vJreVEvYx8zuh7WrqWfCrKtNrwxyULJhmm6L+0bjmQS mSzuQ9Xsg0mkBfmJ7BpP+a1RD2/GT4L/R3z+5LtD6sGbqWqSJ4Vnr/LvNNkVQr5JSS+s uAFx0M6hAGgjBUykmioIgqHzTXKCB1Gjr1hkdZp1t782EJj5zFQBrY8BY7hhzJmic/oF r3IC3k2BxPXsoayr5FlS3yxVnQ9Oxo32j2FqlPkwX52f3bp+1mOkprnxjjDqxUTbVUjP mRmQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19062-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j4-20020a170902c3c400b001d52198a844si2019429plj.614.2024.01.07.19.22.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 19:22:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19062-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A7672281957 for ; Mon, 8 Jan 2024 03:22:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABAF0AD55; Mon, 8 Jan 2024 03:21:42 +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=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: 8bit X-CM-TRANSID:AQAAf8CxO9wxaptlNuUGAA--.17925S4 X-CM-SenderInfo: pzdqw2txl6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWxWr4xWr4xGr4fWr13CFWDKFX_yoW5Ary3pa 929r97Jr4xXrykJrn8JFyUZr4UAFyDGr47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UUUUU= 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"); } -- 2.43.0