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: 205387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp588893dyb; Fri, 23 Feb 2024 05:39:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXE95Ml+sEVxuVADPYkYpdV6UujvU6kmXp+QLmVxYqKJuL/fGzAUbp8ZfsA6nMnAfetB3Vdggcydy3YT6pvjFM6lxusOw== X-Google-Smtp-Source: AGHT+IEBetM5O0VrACuYx7xEL6A8GDe2+Rdjn/+JZYOhy0IJv4wcae7LmZTlmOOIU7GGsTYoBHa/ X-Received: by 2002:a05:622a:1306:b0:42e:411d:ee50 with SMTP id v6-20020a05622a130600b0042e411dee50mr9020273qtk.15.1708695592162; Fri, 23 Feb 2024 05:39:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708695592; cv=pass; d=google.com; s=arc-20160816; b=dDKnc7B34156ehUTWNUbdfiNp9yDUIFZghgeCqJ0c8tlpWVjbYh1/0kffucPFrmNn6 Yo8y084UlhWvtxVfBGmWJmOMHe9/aI/0m6fC3zUX3KeUa5+TCCxC470g1bmzprtxJ6V+ P7iUz6xnyYFdo77gqejBizyxLsaOvrJXKUMivs8fBV4QZIwi/ctrxfh8qVQ9M8z0DhhF lUs7szfxuzEu1BEhQgTQrIwgYhdA8mEkYKkgjTm6QgXvPdG/e7s18yWwNLdRH+StnlfE zPYYkg+XEQSaHXdmPHerNXqEbpJqxquf0aDtnUoUB3uxzooyxY8lUxO6Znw3IhUnWyJF zY1A== ARC-Message-Signature: i=2; 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:dkim-signature; bh=d9zTG9Q/D7hjqGdJH9bas9VTeOur6ufthRK5sGKsQCc=; fh=dCTP4Ymdp7PEyus72y/np7wEnm5YMONLCB550f4Y5pY=; b=bgcXhMhs/Cp96XWKf0+Isb5Ivk4R334ghLGJXUIcd32/e7NC+V0mXjpuLRdOVzl3wh nD0VixXtTRnP7az/jWw0Tcty8neCvNIAvHICV4wVVqiL8Bq95SeJkEUcivYMC0nfb0k8 /8mOOgHDw49o7+EzIQCO8hBiJ8XGSfwKjZa6lIu3NxvXD8CjeUaLsAs+Y0MWOfdTS78P rYFJ4C50qwpGr3ec0uk2TQ6pzRtAjj9TSrqL3cPh+KzxqvrbFjhd/RKnZ3jPz34S1hJR 0EfyeTAxaGFGOVtOC3BEkj9dBxcPfPoT/FRNW/dhW5cDVYkrLCPszym92dCwKlx6DHIB bOlw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NAYoe9Wa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w12-20020a05622a134c00b0042e02fcfc98si13671553qtk.795.2024.02.23.05.39.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 05:39:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NAYoe9Wa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id ECE8E1C221F2 for ; Fri, 23 Feb 2024 13:39:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEF9F81AD4; Fri, 23 Feb 2024 13:38:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NAYoe9Wa" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35DB97FBA7; Fri, 23 Feb 2024 13:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695521; cv=none; b=CiTAHvJXwgRBh+P9/JR4URTN6n1SVq8YAmd7ysEZeCiLZVmMvLqy1TUYmVWzo+3IryFV1t2hB+HIlyX0dOhZ2YWdlgj3QWzVnal+EGDlnWd3WPqPlS9mcibXPC3w6qDBuU0U0TYDGxOm1R5UJ9pmSfaKPivhK/NbqnKnutPS2Gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695521; c=relaxed/simple; bh=GBY3CxtFjRdlkWk0xQcPhghSUX/TMHc7PXVii3OW0UI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PggK4/WE18tkMe3xk0ZkF5I3vMO5DydSZxRioKKI5bcIGRpB4RbBmScVSFOKw0Ml17TgmBV8W1WqWBoCF96laPo/Xe3c5NC7LzRUt3fT2OO2V9qCksMlCXVoqD3pW+opZOdsFY4dq97G8JdrG1WGRqt5aZGBTX2MVQ8Ola0YGZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NAYoe9Wa; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791697189036756498 X-GMAIL-MSGID: 1791697189036756498 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"); }