From patchwork Fri Feb 23 13:38:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13569098 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 530DAC5478C for ; Fri, 23 Feb 2024 13:39:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v5lesqqyMS0U2CpRZ6rlV4BgLU92sdZxH0ga5Kkxu7I=; b=NPfczGfbT8KjDR tvOAeVg0vHdFYEJTI36BMCeThkV8e10GC1gQTlGqCUtZutsVuZhB6gMjxYYGLPSBuwLsSPazU3w3+ akJDnyVQyQfcm5bV0SAtARG+OpR6jjl+0Dc0SUFXOKOuEonYnNOKYTtUFgd+jlcEebCQcy9h4Nmvp Juc+rxbyq2dg3/IHrFHzVtBSjZ0UbG5wIdRhLFdZ96LjEqsbzX7tnFnpz93aLGXzwLBZylQYTaLFj M187KQiHDnuW4IPSdkcXobrAjfJW6uUPK5ejVuDeWP+PPBjlCeQx4QBN1xIcsDiov4hjJUX7RhOJg 2iHE4EvO0ch3WdMLHhkQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdVlG-00000009b9m-20QU; Fri, 23 Feb 2024 13:38:46 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdVlE-00000009b7t-0nKg for linux-riscv@lists.infradead.org; Fri, 23 Feb 2024 13:38:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C9EAECE2BFE; Fri, 23 Feb 2024 13:38:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84281C433C7; Fri, 23 Feb 2024 13:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708695521; bh=GBY3CxtFjRdlkWk0xQcPhghSUX/TMHc7PXVii3OW0UI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAYoe9WaOvWjK1nqOgnvCRLfNM1vZZ77ud9LwZ25q4toItC75bJj1HTjri6c2gXdA qx6gYl6UK3FaZPRWQtXRkeKeMNxLZH7BloLltp+gB9ahCt1OG+0ZTwxb3EoKpi6GYN Mbq4hQSa43Hf4YoY1B0DUu9QUvy3j4JJyAdd74AV3Avzt5xg6Ox4FylJRDHG1oSfts zB8IHxJFvZpDcgNweVSDpkC0wMuv3OWRL6SRzq91BNBWy7zk/+idBiurodqRLm6qSt lGDm6eVu3pt63byZpq3ks1rLII5B+W750e8gG1wICoaebGb7eaw3n4SUrkPrpfsh/r UHJujfNg9x3dg== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Nathan Chancellor , Nick Desaulniers , Tom Rix , rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2 2/3] scripts: generate_rust_target: enable building on RISC-V Date: Fri, 23 Feb 2024 13:38:04 +0000 Message-ID: <20240223-employee-pessimism-03ba0b58db6b@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240223-leverage-walmart-5424542cd8bd@spud> References: <20240223-leverage-walmart-5424542cd8bd@spud> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1601; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=p3JdpTjlU4Gcdumuom76iCrubxUFIi9NJkWxSpqwhJ0=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDKk35u/5lrFAdfnzD1GuIt8lz140CmXaqXr44cXs8KWGK R2WOsGHOkpZGMQ4GGTFFFkSb/e1SK3/47LDuectzBxWJpAhDFycAjCRPSsYGSan/60+PG/FqTAG kUlzFlW8U7p6xSjmJYeo5ZTlD5iZ9rkxMnwt/bL+85NpTZyR6SErzVtmXlqpyCW6YMKvR3qGn5M 3MbMDAA== X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240223_053844_664310_F1D95677 X-CRM114-Status: UNSURE ( 8.69 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Miguel Ojeda Add the required bits from rust-for-linux to enable generating a RISC-V target for rust. The script, written by Miguel, was originally a config file contributed by Gary. Co-developed-by: Gary Guo Signed-off-by: Gary Guo Signed-off-by: Miguel Ojeda Signed-off-by: Conor Dooley --- scripts/generate_rust_target.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs index 416c6b89e806..942ddca57ee4 100644 --- a/scripts/generate_rust_target.rs +++ b/scripts/generate_rust_target.rs @@ -171,6 +171,22 @@ fn main() { ts.push("llvm-target", "loongarch64-linux-gnusf"); ts.push("llvm-abiname", "lp64s"); ts.push("target-pointer-width", "64"); + } else if cfg.has("RISCV") { + if cfg.has("64BIT") { + ts.push("arch", "riscv64"); + ts.push("data-layout", "e-m:e-p:64:64-i64:64-i128:128-n64-S128"); + ts.push("llvm-target", "riscv64-linux-gnu"); + ts.push("target-pointer-width", "64"); + } else { + panic!("32-bit RISC-V is an unsupported architecture"); + } + ts.push("code-model", "medium"); + ts.push("disable-redzone", true); + let mut features = "+m,+a".to_string(); + if cfg.has("RISCV_ISA_C") { + features += ",+c"; + } + ts.push("features", features); } else { panic!("Unsupported architecture"); }