From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 579761382C5 for ; Fri, 12 Jun 2020 00:31:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5BB9AE08F0; Fri, 12 Jun 2020 00:31:13 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 23359E08F0 for ; Fri, 12 Jun 2020 00:31:13 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6B68334E590 for ; Fri, 12 Jun 2020 00:31:11 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E5F49275 for ; Fri, 12 Jun 2020 00:31:09 +0000 (UTC) From: "Georgy Yakovlev" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Georgy Yakovlev" Message-ID: <1591921849.0326022d60e80c438d0ea90f489eebb722320417.gyakovlev@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-lang/rust/rust-1.44.0.ebuild X-VCS-Directories: dev-lang/rust/ X-VCS-Committer: gyakovlev X-VCS-Committer-Name: Georgy Yakovlev X-VCS-Revision: 0326022d60e80c438d0ea90f489eebb722320417 X-VCS-Branch: master Date: Fri, 12 Jun 2020 00:31:09 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 092eaeca-4f73-4016-986e-0f758143c3f0 X-Archives-Hash: f55cd20e8f7e86ea86d64c8f261800bd commit: 0326022d60e80c438d0ea90f489eebb722320417 Author: Georgy Yakovlev gentoo org> AuthorDate: Thu Jun 11 22:12:30 2020 +0000 Commit: Georgy Yakovlev gentoo org> CommitDate: Fri Jun 12 00:30:49 2020 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0326022d dev-lang/rust: add experimental cross support to 1.44.0 Brief usage how-to in the ebuild Bug: https://bugs.gentoo.org/680652 Bug: https://bugs.gentoo.org/680652 Package-Manager: Portage-2.3.100, Repoman-2.3.22 Signed-off-by: Georgy Yakovlev gentoo.org> dev-lang/rust/rust-1.44.0.ebuild | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/dev-lang/rust/rust-1.44.0.ebuild b/dev-lang/rust/rust-1.44.0.ebuild index 5deb73a5022..1a6fdeabca6 100644 --- a/dev-lang/rust/rust-1.44.0.ebuild +++ b/dev-lang/rust/rust-1.44.0.ebuild @@ -295,6 +295,63 @@ src_configure() { EOF fi + if [[ -n ${I_KNOW_WHAT_I_AM_DOING_CROSS} ]]; then #whitespace intentionally shifted below + # experimental cross support + # discussion: https://bugs.gentoo.org/679878 + # TODO: c*flags, clang, system-llvm, cargo.eclass target support + # it would be much better if we could split out stdlib + # complilation to separate ebuild and abuse CATEGORY to + # just install to /usr/lib/rustlib/ + + # extra targets defined as a bash array + # spec format: :: + # best place would be /etc/portage/env/dev-lang/rust + # Example: + # RUST_CROSS_TARGETS=( + # "AArch64:aarch64-unknown-linux-gnu:aarch64-unknown-linux-gnu" + # ) + # no extra hand holding is done, no target transformations, all + # values are passed as-is with just basic checks, so it's up to user to supply correct values + # valid rust targets can be obtained with + # rustc --print target-list + # matching cross toolchain has to be installed + # matching LLVM_TARGET has to be enabled for both rust and llvm (if using system one) + # only gcc toolchains installed with crossdev are checked for now. + + # BUG: we can't pass host flags to cross compiler, so just filter for now + # BUG: this should be more fine-grained. + filter-flags '-mcpu=*' '-march=*' '-mtune=*' + + local cross_target_spec + for cross_target_spec in "${RUST_CROSS_TARGETS[@]}";do + local cross_llvm_target="${cross_target_spec%%:*}" + local cross_triples="${cross_target_spec#*:}" + local cross_rust_target="${cross_triples#*:}" + local cross_toolchain="${cross_triples%:*}" + use llvm_targets_${cross_llvm_target} || die "need llvm_targets_${cross_llvm_target} target enabled" + command -v ${cross_toolchain}-gcc > /dev/null 2>&1 || die "need ${cross_toolchain} cross toolchain" + + cat <<- EOF >> "${S}"/config.toml + [target.${cross_rust_target}] + cc = "${cross_toolchain}-gcc" + cxx = "${cross_toolchain}-g++" + linker = "${cross_toolchain}-gcc" + ar = "${cross_toolchain}-ar" + EOF + if use system-llvm; then + cat <<- EOF >> "${S}"/config.toml + llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config" + EOF + fi + + rust_targets="${rust_targets},\"${cross_rust_target}\"" + sed -i "/^target = \[/ s#\[.*\]#\[${rust_targets}\]#" config.toml || die + ewarn + ewarn "enabled ${rust_target} rust target, using ${cross_toolchain} cross toolchain" + ewarn + done + fi # I_KNOW_WHAT_I_AM_DOING_CROSS + einfo "Rust configured with the following settings:" cat "${S}"/config.toml || die }