From patchwork Thu Dec 15 07:32:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Enedino Hernandez Samaniego X-Patchwork-Id: 16757 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BBF5C00145 for ; Thu, 15 Dec 2022 07:32:50 +0000 (UTC) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.128360.1671089563137465916 for ; Wed, 14 Dec 2022 23:32:43 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: enedino.org, ip: 13.77.154.182, mailfrom: alejandro@enedino.org) Received: from alsamon-xub.lan (cpe-68-201-55-29.elp.res.rr.com [68.201.55.29]) by linux.microsoft.com (Postfix) with ESMTPSA id D692520B87DD; Wed, 14 Dec 2022 23:32:41 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D692520B87DD From: Alejandro Enedino Hernandez Samaniego To: openembedded-core@lists.openembedded.org Cc: Alejandro Hernandez Samaniego Subject: [PATCH 1/2] rust: Enable building rust from stable, beta and nightly channels Date: Thu, 15 Dec 2022 00:32:23 -0700 Message-Id: <20221215073224.3061128-1-alejandro@enedino.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 15 Dec 2022 07:32:50 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/174561 From: Alejandro Hernandez Samaniego Rust follows the train release model via the stable, beta and nightly channels, by default we build rust from the stable channel, however there are certain features which are only available in the beta or nightly channels. Make these channels available by setting a RUST_CHANNEL variable which defaults to stable making this change transparent to the user. The snapshot version used by rust during its compilation wont necessarily match the version being built, specially if were building from an unstable channel, to avoid confusion rename this to SNAPSHOT_VERSION and use RUST_VERSION for the version to be built. Append -beta or -nightly to rusts PV for signature awareness. It is important to note that this does not build rust from the beta/nightly published tarball (which today build rust v1.67.0 and v1.68.0 respectively), instead this builds rust from the current selected version (1.65.0) and enables the beta/nightly features for that version. Setting the variable RUST_CHANNEL=nightly results in the following: $ rustc -Vv rustc 1.65.0-nightly Signed-off-by: Alejandro Hernandez Samaniego --- meta/recipes-devtools/rust/rust-snapshot.inc | 7 ++++--- meta/recipes-devtools/rust/rust-source.inc | 5 +++-- meta/recipes-devtools/rust/rust.inc | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/meta/recipes-devtools/rust/rust-snapshot.inc b/meta/recipes-devtools/rust/rust-snapshot.inc index 2f9cdb9566..d84a3ded59 100644 --- a/meta/recipes-devtools/rust/rust-snapshot.inc +++ b/meta/recipes-devtools/rust/rust-snapshot.inc @@ -5,7 +5,8 @@ ## The version is replicated here. ## TODO: find a way to add additional SRC_URIs based on the contents of an ## earlier SRC_URI. -RS_VERSION = "1.64.0" + +SNAPSHOT_VERSION = "1.64.0" CARGO_VERSION = "1.64.0" # TODO: Add hashes for other architecture toolchains as well. Make a script? @@ -27,6 +28,6 @@ SRC_URI += " \ https://static.rust-lang.org/dist/${CARGO_SNAPSHOT}.tar.xz;name=cargo-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \ " -RUST_STD_SNAPSHOT = "rust-std-${RS_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" -RUSTC_SNAPSHOT = "rustc-${RS_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +RUST_STD_SNAPSHOT = "rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +RUSTC_SNAPSHOT = "rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" CARGO_SNAPSHOT = "cargo-${CARGO_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc index 0c85b4b480..a10f5c653a 100644 --- a/meta/recipes-devtools/rust/rust-source.inc +++ b/meta/recipes-devtools/rust/rust-source.inc @@ -1,4 +1,5 @@ -SRC_URI += "https://static.rust-lang.org/dist/rustc-${PV}-src.tar.xz;name=rust" +RUST_VERSION = "1.65.0" +SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust" SRC_URI[rust.sha256sum] = "2d6aa2ea3fedd55acbbd65f78349385f9daa9c14e25db7a8df5d015588eee1cf" SRC_URI:append:class-target:pn-rust = " \ @@ -7,7 +8,7 @@ SRC_URI:append:class-target:pn-rust = " \ file://0001-Add-ENOTSUP-constant-for-riscv32-musl.patch" SRC_URI:append:class-nativesdk:pn-nativesdk-rust = " file://hardcodepaths.patch" -RUSTSRC = "${WORKDIR}/rustc-${PV}-src" +RUSTSRC = "${WORKDIR}/rustc-${RUST_VERSION}-src" UPSTREAM_CHECK_URI = "https://forge.rust-lang.org/infra/other-installation-methods.html" UPSTREAM_CHECK_REGEX = "rustc-(?P\d+(\.\d+)+)-src" diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc index 956301023a..8a8dcd0b18 100644 --- a/meta/recipes-devtools/rust/rust.inc +++ b/meta/recipes-devtools/rust/rust.inc @@ -13,6 +13,9 @@ DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" S = "${RUSTSRC}" +RUST_CHANNEL ?= "stable" +PV:append = "${@bb.utils.contains('RUST_CHANNEL', 'stable', '', '-${RUST_CHANNEL}', d)}" + export FORCE_CRATE_HASH="${BB_TASKHASH}" RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" @@ -116,7 +119,7 @@ python do_configure() { # [rust] config.add_section("rust") config.set("rust", "rpath", e(True)) - config.set("rust", "channel", e("stable")) + config.set("rust", "channel", e(d.expand("${RUST_CHANNEL}"))) # Whether or not to optimize the compiler and standard library config.set("rust", "optimize", e(True)) From patchwork Thu Dec 15 07:32:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Enedino Hernandez Samaniego X-Patchwork-Id: 16758 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A908C4332F for ; Thu, 15 Dec 2022 07:32:50 +0000 (UTC) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.127535.1671089563284812274 for ; Wed, 14 Dec 2022 23:32:43 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: enedino.org, ip: 13.77.154.182, mailfrom: alejandro@enedino.org) Received: from alsamon-xub.lan (cpe-68-201-55-29.elp.res.rr.com [68.201.55.29]) by linux.microsoft.com (Postfix) with ESMTPSA id 6032520B87E0; Wed, 14 Dec 2022 23:32:42 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6032520B87E0 From: Alejandro Enedino Hernandez Samaniego To: openembedded-core@lists.openembedded.org Cc: Alejandro Enedino Hernandez Samaniego Subject: [PATCH 2/2] rust: Enable baremetal targets Date: Thu, 15 Dec 2022 00:32:24 -0700 Message-Id: <20221215073224.3061128-2-alejandro@enedino.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221215073224.3061128-1-alejandro@enedino.org> References: <20221215073224.3061128-1-alejandro@enedino.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 15 Dec 2022 07:32:50 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/174562 Allow rust to build for baremetal targets by generating the proper target triple, follow the format specified by rusts Triple [1], that is: --- This is done automatically based on both TARGET_OS and TCLIBC. For example, a riscv64 baremetal target triple would look like this: riscv64gc-poky-none-elf matching rusts own target triple for riscv64 according to platform-support [2] [1] https://docs.rs/target-lexicon/latest/target_lexicon/struct.Triple.html [2] https://doc.rust-lang.org/stable/rustc/platform-support.html Signed-off-by: Alejandro Enedino Hernandez Samaniego --- meta/classes-recipe/rust-common.bbclass | 6 ++++++ meta/classes-recipe/rust-target-config.bbclass | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/meta/classes-recipe/rust-common.bbclass b/meta/classes-recipe/rust-common.bbclass index 3338de7502..0f72e45e8c 100644 --- a/meta/classes-recipe/rust-common.bbclass +++ b/meta/classes-recipe/rust-common.bbclass @@ -66,6 +66,12 @@ def rust_base_triple(d, thing): elif "musl" in os: libc = "-musl" os = "linux" + elif "elf" in os: + libc = "-elf" + os = "none" + elif "eabi" in os: + libc = "-eabi" + os = "none" return arch + vendor + '-' + os + libc diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass index 2710b4325d..7fd7128bcf 100644 --- a/meta/classes-recipe/rust-target-config.bbclass +++ b/meta/classes-recipe/rust-target-config.bbclass @@ -355,7 +355,10 @@ def rust_gen_target(d, thing, wd, arch): tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch_abi) tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch_abi) tspec['arch'] = arch_to_rust_target_arch(rust_arch) - tspec['os'] = "linux" + if "baremetal" in d.getVar('TCLIBC'): + tspec['os'] = "none" + else: + tspec['os'] = "linux" if "musl" in tspec['llvm-target']: tspec['env'] = "musl" else: