Gentoo Archives: gentoo-commits

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/
Date: Thu, 11 Feb 2021 23:49:28
Message-Id: 1613086857.d1213c7db33bf8664a9a03b742dcca45c52813cf.gyakovlev@gentoo
1 commit: d1213c7db33bf8664a9a03b742dcca45c52813cf
2 Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
3 AuthorDate: Thu Feb 11 22:23:08 2021 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Thu Feb 11 23:40:57 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d1213c7d
7
8 dev-lang/rust: bump to 1.50.0
9
10 Package-Manager: Portage-3.0.14, Repoman-3.0.2
11 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
12
13 dev-lang/rust/Manifest | 15 +
14 dev-lang/rust/rust-1.50.0.ebuild | 619 +++++++++++++++++++++++++++++++++++++++
15 2 files changed, 634 insertions(+)
16
17 diff --git a/dev-lang/rust/Manifest b/dev-lang/rust/Manifest
18 index e296ab86edf..74eff5ba8e9 100644
19 --- a/dev-lang/rust/Manifest
20 +++ b/dev-lang/rust/Manifest
21 @@ -54,7 +54,22 @@ DIST rust-1.48.0-powerpc64le-unknown-linux-gnu.tar.xz 124335896 BLAKE2B fe95cb27
22 DIST rust-1.48.0-s390x-unknown-linux-gnu.tar.xz 127221600 BLAKE2B 08511be6aadc0feb36caa19df5914a207565eed3b4b3914cad7fc8f7170011a7431c14d50b1334f5d5e00b4c94e7e84ee59afad179286e889480cc9b21e1f402 SHA512 b2b1565f3b1cc0c3bf4aa06aba1da7df775c6e29c892ca7727d0e549f175b632080433be2586e799c5636231de6c678f0228dedee8358fbf167016a1f7d25389
23 DIST rust-1.48.0-x86_64-unknown-linux-gnu.tar.xz 155254844 BLAKE2B 37bce978eb297bb1732f9d513bb6fdcee4aefc42a578496a84b5f8abbb9f90f1c524c73f28c85f33c25a365bf5ba566253b1739009bb112c2e1d46a2ed978e10 SHA512 0784e156e70c47386abfa88ecfeb62b1109364459b1fee225de0749c30379c4eb443ff3ff7faa7dc1a6ff373bc6eb43997007f937889cb35daf940a74641753b
24 DIST rust-1.48.0-x86_64-unknown-linux-musl.tar.xz 168361012 BLAKE2B efeb9a9812f2fa2cbf1cfd963b5b714cf18d73ca9b7a3de4efa701acf7e2e8fc3b610cd90f7391b10bddd1c9d44b8b0aa910f58ce739750d4e910b063825dc28 SHA512 7188fb0b1bf6fd6ab320089cd17f334867baefec1a9c57a81e6cb729276456e56850938dbd0eafbc52375266a87392ad3045a4dbd2c41689bba6b0da152e4034
25 +DIST rust-1.49.0-aarch64-unknown-linux-gnu.tar.xz 179627172 BLAKE2B 911fc176a7161bf3ca1a6ec01ec38d4f1792b11feb3c24c9587f8feb2923b42aa97f0e3391449ee1189507b9bdc2ef16be8f064ac3161f73aba18fd7b11c8f5d SHA512 fa81b618359c2952de941e094eabfe2966e3c1a39a1b20452a77f1a68a54dde9cc5cade18db911cf448ffe947d934461ce752112bd9b5b5430e1fcdabbd8b56a
26 +DIST rust-1.49.0-arm-unknown-linux-gnueabi.tar.xz 172021916 BLAKE2B 69e80df9f8d582c8216adfcd27ce8a19a9af49f27423fc3ee478ccb8b60b489e36c1f38633c86c58a504b2110cebf4026dc418e55897caf60865c21209ea2366 SHA512 2ea1d8564577cb4f687384e0d933e6ed7e1e5c95aeb49410d660409a23867959bc175344fa00bdc342cf511ea867cb2d97507af117e7d5b34714e69d4b8ffaff
27 +DIST rust-1.49.0-arm-unknown-linux-gnueabihf.tar.xz 173557760 BLAKE2B 63c1815b3bfdcb5bf1c745bd8b85cee052b2c85f42a800166da6ee66374716e899919fac7b9c75d0a6b0ddc963e22e2b842ac382eca431433cb1ef4c1d568ad4 SHA512 9c4a49b8a3bf11d5e0f3d54032e2dfee8779f3fb68676a219c9b8e344539a3dd840d912167783f3fbaa3bd3fbf73b6bdd5afa9343c042a67496ab57c9a9ca96e
28 +DIST rust-1.49.0-armv7-unknown-linux-gnueabihf.tar.xz 176194076 BLAKE2B 1d2a1eca1d44d48cdd542411acc0f1a81767b6e62c744c800a840f3ecdcc060acd7552d342539230f85cf3e2771f8aa4a2c1ff88efaccf7021bbb2e0af71c222 SHA512 1cba85fc958371aeb1d521e8842ad576e65d244147e2c75c34eaa776552ed025434d10284fa976d901d6cede69f6db3e5fdd770005ca0b93bb5e3202b9f9392a
29 +DIST rust-1.49.0-i686-unknown-linux-gnu.tar.xz 201492368 BLAKE2B b666693ffd3468330c3aaabc81556d3f6c907e136f98edde9ea4605bd95a5750e57432a51e5eba0643a816b4281129f1cc295cf9821d5f285cdfd8cb3cb68c3f SHA512 b4d39cb234314f013969b5db3d365d21719d7a01f2dc0816e4f221c5e6d4abecd7f9e83f54b8640173d00d3e701cb3cbb61cef32f00db9356139005a1ce3bd19
30 +DIST rust-1.49.0-mips-unknown-linux-gnu.tar.xz 134041460 BLAKE2B 0e779b3494221f22529ba7a4b9e1098186965d36f7cb94b5d76c84bd4703c354ebc57aa03a58fe3b5592c1543ac6193575f9d443cd8fa663a69d9af1ae7d0b82 SHA512 9293814a64d7382f97beb137ccb8beeeb76ae5f71d6db7d2c70f3c643a877f5991c0abc2d53270bccaa6aa5c8de4f0e46fe4b92ad09e2253e5cd5487a3f46d6c
31 +DIST rust-1.49.0-mips64-unknown-linux-gnuabi64.tar.xz 143820152 BLAKE2B f22869487eac68f5ed698da1b05b1c53ae138cff79d2c5011008663b027858c5b91ce1b2f26924ecc17d13ca9559ff444e1b03a44a5b3b536e66753075c8d05a SHA512 ea1d90a388c44a2e5bd5f51dd5e8b95721e49c8284369cd638560e9c729c8a7c54ba6cccf55547f0b0b1731498623eaf743783cfd67e61c13f89f0ad9275c051
32 +DIST rust-1.49.0-mipsel-unknown-linux-gnu.tar.xz 140145252 BLAKE2B 5a26ca9e2af4a2d96c34da29e50c5c68b1fb0f2e6db20685853a4211042aee76f0f86b17c4697bcecce99de21ac7b60b055ed43cd2acf03dfa043eb5e3546692 SHA512 a2079d5068737cae36532c2922fc4aebf4aac723208804a128a1234ae78868f20a6559a967cf01a456ba7de2bf48ea3961fc9a31dd3bc45130b0de328a712295
33 +DIST rust-1.49.0-powerpc-unknown-linux-gnu.tar.xz 147163992 BLAKE2B 4822af4b54a22214425e0dd993081f0bc7b0ae0973c0e11d021a2a8671f05272b2cb6b3ca307eef9b3ad25db6a1eef7976f1e8e4ead8ac4c5226d9c7596c0f6d SHA512 905c624baccf0bbcd166407a8722909b2645c7e1993e80a37aa4cfe43d0dce5b92db2c5443295ecb79fa6c3c2cbe6e0e67ad7f8ba312075fb8960cbe50183a25
34 +DIST rust-1.49.0-powerpc64-unknown-linux-gnu.tar.xz 160585188 BLAKE2B f0e4a5da3767b1bfb633c899c1b9b2ee9725d8bea9154142037cbcc9212d67a364f0eb130ea4d2a4c62d0fe55a8d9d880faac2f6e167155a99a235f7ee28fc1d SHA512 36f94b0ae399f872a22c697225abcb35a893ae6e4ed369961edb693299cb58e294267b1d73a99555057618f179202a70ae2fdcff2b3bedbabf2774b3809a2a62
35 +DIST rust-1.49.0-powerpc64le-unknown-linux-gnu.tar.xz 169253520 BLAKE2B 4648467a84d7f81f63ddf610fce6e1e2388ce5c91a7ce73c8b8d054356bfcba379d4d0a543fdbc9bad9b689b10f8dffa4c145b83ff02ac1d77ede7f600bb5924 SHA512 c17eb27ec4dbcc56da3edffbc57e0edda99744d6a0d38369fa08af066894aeb13dd78c7b8055f2246fc3bf13c654842675ea4df44b7bc8852e0f9952acdf7e7c
36 +DIST rust-1.49.0-s390x-unknown-linux-gnu.tar.xz 170753008 BLAKE2B a81618240d86d4a70bd27f3e33caf0258868539b3b081a8f8f461a3debf82ab1493fea18dd5a32083d1f34db268f4bff471f5f45fb3d4910dd9559f227dc3aab SHA512 25259ea2e499c89459b14571e2c54f230d642af9cfe539dc2b8be15eff0e23b8c6e60af4c567bcbb6c6c185b4537eaab19c3395fce48b1f6e5ef1234efc31e3a
37 +DIST rust-1.49.0-x86_64-unknown-linux-gnu.tar.xz 144752500 BLAKE2B 188fafdbff02cbffae22e8a48d259119c59aa435252477ba3b4f4522cc00c90d9a242bd5ac76e8d8210bd032b8f78538e5f95606fe2c862ffd7477acdfb6e1a7 SHA512 c008aa50e17db6a0134fb85235a958258d345410f5063bc77175f7c28b2e35895427b9e68cd1ac9acb769769c83313cd59fe6465b453e891cf415a2514b7722d
38 +DIST rust-1.49.0-x86_64-unknown-linux-musl.tar.xz 217795696 BLAKE2B 264348951db96a9f046e4bec599b92a5ee6d185d961f833f8d2127c1ac4578b91401834d09b5eed421f03d14933ff3b2e85961ff09927d19bf6c701d80eb1b67 SHA512 be165de42e3acd50f6e6a21fe386ea2333fd0f19abedbb059d6eb8ce8c80a8e79257eab8a7775e3b72307596b52e803bd8c4c46330a6e66acbadbe2f63cea42a
39 DIST rustc-1.46.0-src.tar.xz 101868452 BLAKE2B da9798596b124a10d79c236a871228f05e5f571d22c2259328e7026c91e088c85f5de9c0536a16531e0cb10477bfcd16d3ac11467979f5561cb6199442b877ef SHA512 099857f1d295043587a4e2a65ef3e6a90e12c8b6958e98535a1656c113c553f9a9b621aba8a19cf21bd8d2c79d27cbfa4b8e6fabbcb3cbfee23b545be7b450b4
40 DIST rustc-1.47.0-src.tar.xz 104143736 BLAKE2B 0454094dde35275488046826da87655e51bf0795481d6d08fd70d644bfc12481bca8641166106ef32f20494906025244715b16ff21a1c023f4bd2818aab42521 SHA512 6ba83c0158f8130ddeae7e070417a2121d8a548c8fe97e28bce116d84048636c75aaee78e0c92cd43a50f5679a1223fc226cc8c5ba9bbd1465e84c5c6034d5c9
41 DIST rustc-1.48.0-src.tar.xz 105951736 BLAKE2B 42468fc5ac5e80c4793cfe0913cbb8e43a8def28cc8cf5ed25ab989561e2bf33e155c83e180183362535cbc9008f341eb1273087a2364672b1a4032ac2d6ca45 SHA512 4e12baa6893238a8d336ec9ebe891477d18676f271b32763474fa7a6a8b58fb3187dd4e2aa95bce482989b692cc2e1360221669d6811eec71b326f22a1756c23
42 DIST rustc-1.49.0-src.tar.xz 108330280 BLAKE2B 65e36253482ded2df225cbbf15253b6c9a8ae935053b071d9fb9e7b1d47d5d3ac47a138876e4a5cfeda455c655ac06ceff2658c8668cef7d2206116906740653 SHA512 fd8bc67ec0a73d3b6bf9c1fabb7ea981ef817644b4e6ced982fa90b12eae9b55de074634a670bdfb38bfee6588603e818ddcbcc2f2a05f83057c061b4194b4b7
43 +DIST rustc-1.50.0-src.tar.xz 108666272 BLAKE2B abb1b6f57093334bae5892dd99c964ffaf5e2b906cc92f0b92d5786cf80484cff923643169f24f4f92a5724c21b8bd671c72531c2cd1f6fbe0ea7107b5bd923b SHA512 df3c83c0fdc9ebce6fdccddda781dea0cdbd88d2b2a8220cac40cc3a8fa957923ae834d1fa45283d4ad227b334bd9e220e37a4a1ad7a1c7aeb806ed9ed387245
44
45 diff --git a/dev-lang/rust/rust-1.50.0.ebuild b/dev-lang/rust/rust-1.50.0.ebuild
46 new file mode 100644
47 index 00000000000..e98848b6f30
48 --- /dev/null
49 +++ b/dev-lang/rust/rust-1.50.0.ebuild
50 @@ -0,0 +1,619 @@
51 +# Copyright 1999-2021 Gentoo Authors
52 +# Distributed under the terms of the GNU General Public License v2
53 +
54 +EAPI=7
55 +
56 +PYTHON_COMPAT=( python3_{7..9} )
57 +
58 +inherit bash-completion-r1 check-reqs estack flag-o-matic llvm multiprocessing multilib-build python-any-r1 rust-toolchain toolchain-funcs
59 +
60 +if [[ ${PV} = *beta* ]]; then
61 + betaver=${PV//*beta}
62 + BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}"
63 + MY_P="rustc-beta"
64 + SLOT="beta/${PV}"
65 + SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz -> rustc-${PV}-src.tar.xz"
66 +else
67 + ABI_VER="$(ver_cut 1-2)"
68 + SLOT="stable/${ABI_VER}"
69 + MY_P="rustc-${PV}"
70 + SRC="${MY_P}-src.tar.xz"
71 + KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86"
72 +fi
73 +
74 +RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
75 +
76 +DESCRIPTION="Systems programming language from Mozilla"
77 +HOMEPAGE="https://www.rust-lang.org/"
78 +
79 +SRC_URI="
80 + https://static.rust-lang.org/dist/${SRC}
81 + !system-bootstrap? ( $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION}) )
82 +"
83 +
84 +# keep in sync with llvm ebuild of the same version as bundled one.
85 +ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430
86 + NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore )
87 +ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
88 +LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?}
89 +
90 +LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
91 +
92 +IUSE="clippy cpu_flags_x86_sse2 debug doc libressl miri nightly parallel-compiler rls rustfmt system-bootstrap system-llvm test wasm ${ALL_LLVM_TARGETS[*]}"
93 +
94 +# Please keep the LLVM dependency block separate. Since LLVM is slotted,
95 +# we need to *really* make sure we're not pulling more than one slot
96 +# simultaneously.
97 +
98 +# How to use it:
99 +# 1. List all the working slots (with min versions) in ||, newest first.
100 +# 2. Update the := to specify *max* version, e.g. < 12.
101 +# 3. Specify LLVM_MAX_SLOT, e.g. 11.
102 +LLVM_DEPEND="
103 + || (
104 + sys-devel/llvm:11[${LLVM_TARGET_USEDEPS// /,}]
105 + )
106 + <sys-devel/llvm-12:=
107 + wasm? ( sys-devel/lld )
108 +"
109 +LLVM_MAX_SLOT=11
110 +
111 +# to bootstrap we need at least exactly previous version, or same.
112 +# most of the time previous versions fail to bootstrap with newer
113 +# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
114 +# but it fails to bootstrap with 1.48.x
115 +# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.txt
116 +BOOTSTRAP_DEPEND="||
117 + (
118 + =dev-lang/rust-$(ver_cut 1).$(($(ver_cut 2) - 1))*
119 + =dev-lang/rust-bin-$(ver_cut 1).$(($(ver_cut 2) - 1))*
120 + =dev-lang/rust-$(ver_cut 1).$(ver_cut 2)*
121 + =dev-lang/rust-bin-$(ver_cut 1).$(ver_cut 2)*
122 + )
123 +"
124 +
125 +BDEPEND="${PYTHON_DEPS}
126 + app-eselect/eselect-rust
127 + || (
128 + >=sys-devel/gcc-4.7
129 + >=sys-devel/clang-3.5
130 + )
131 + system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
132 + !system-llvm? (
133 + dev-util/cmake
134 + dev-util/ninja
135 + )
136 +"
137 +
138 +DEPEND="
139 + >=app-arch/xz-utils-5.2
140 + net-misc/curl:=[http2,ssl]
141 + sys-libs/zlib:=
142 + !libressl? ( dev-libs/openssl:0= )
143 + libressl? ( dev-libs/libressl:0= )
144 + elibc_musl? ( sys-libs/libunwind:= )
145 + system-llvm? (
146 + ${LLVM_DEPEND}
147 + )
148 +"
149 +
150 +# we need to block older versions due to layout changes.
151 +RDEPEND="${DEPEND}
152 + app-eselect/eselect-rust
153 + !<dev-lang/rust-1.47.0-r1
154 + !<dev-lang/rust-bin-1.47.0-r1
155 +"
156 +
157 +REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )
158 + miri? ( nightly )
159 + parallel-compiler? ( nightly )
160 + test? ( ${ALL_LLVM_TARGETS[*]} )
161 + wasm? ( llvm_targets_WebAssembly )
162 + x86? ( cpu_flags_x86_sse2 )
163 +"
164 +
165 +# we don't use cmake.eclass, but can get a warnings
166 +CMAKE_WARN_UNUSED_CLI=no
167 +
168 +QA_FLAGS_IGNORED="
169 + usr/lib/${PN}/${PV}/bin/.*
170 + usr/lib/${PN}/${PV}/libexec/.*
171 + usr/lib/${PN}/${PV}/lib/lib.*.so
172 + usr/lib/${PN}/${PV}/lib/rustlib/.*/bin/.*
173 + usr/lib/${PN}/${PV}/lib/rustlib/.*/lib/lib.*.so
174 +"
175 +
176 +QA_SONAME="
177 + usr/lib/${PN}/${PV}/lib/lib.*.so.*
178 + usr/lib/${PN}/${PV}/lib/rustlib/.*/lib/lib.*.so
179 +"
180 +
181 +# causes double bootstrap
182 +RESTRICT="test"
183 +
184 +PATCHES=(
185 + "${FILESDIR}"/1.47.0-libressl.patch
186 + "${FILESDIR}"/1.47.0-ignore-broken-and-non-applicable-tests.patch
187 + "${FILESDIR}"/1.47.0-llvm-tensorflow-fix.patch
188 + "${FILESDIR}"/1.49.0-gentoo-musl-target-specs.patch
189 + "${FILESDIR}"/1.49.0-llvm-ver-display.patch
190 +)
191 +
192 +S="${WORKDIR}/${MY_P}-src"
193 +
194 +toml_usex() {
195 + usex "${1}" true false
196 +}
197 +
198 +boostrap_rust_version_check() {
199 + # never call from pkg_pretend. eselect-rust may be not installed yet.
200 + [[ ${MERGE_TYPE} == binary ]] && return
201 + local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
202 + local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
203 + local rustc_version=( $(eselect --brief rust show 2>/dev/null) )
204 + rustc_version=${rustc_version[0]#rust-bin-}
205 + rustc_version=${rustc_version#rust-}
206 +
207 + [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, check 'eselect rust' output"
208 +
209 + if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
210 + eerror "Rust >=${rustc_wanted} is required"
211 + eerror "please run 'eselect rust' and set correct rust version"
212 + die "selected rust version is too old"
213 + elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
214 + eerror "Rust <${rustc_toonew} is required"
215 + eerror "please run 'eselect rust' and set correct rust version"
216 + die "selected rust version is too new"
217 + else
218 + einfo "Using rust ${rustc_version} to build"
219 + fi
220 +}
221 +
222 +pre_build_checks() {
223 + local M=6144
224 + M=$(( $(usex clippy 128 0) + ${M} ))
225 + M=$(( $(usex miri 128 0) + ${M} ))
226 + M=$(( $(usex rls 512 0) + ${M} ))
227 + M=$(( $(usex rustfmt 256 0) + ${M} ))
228 + M=$(( $(usex system-llvm 0 2048) + ${M} ))
229 + M=$(( $(usex wasm 256 0) + ${M} ))
230 + M=$(( $(usex debug 15 10) * ${M} / 10 ))
231 + eshopts_push -s extglob
232 + if is-flagq '-g?(gdb)?([1-9])'; then
233 + M=$(( 15 * ${M} / 10 ))
234 + fi
235 + eshopts_pop
236 + M=$(( $(usex system-bootstrap 0 1024) + ${M} ))
237 + M=$(( $(usex doc 256 0) + ${M} ))
238 + CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE}
239 +}
240 +
241 +pkg_pretend() {
242 + pre_build_checks
243 +}
244 +
245 +pkg_setup() {
246 + pre_build_checks
247 + python-any-r1_pkg_setup
248 +
249 + export LIBGIT2_NO_PKG_CONFIG=1 #749381
250 +
251 + use system-bootstrap && boostrap_rust_version_check
252 +
253 + if use system-llvm; then
254 + llvm_pkg_setup
255 +
256 + local llvm_config="$(get_llvm_prefix "$LLVM_MAX_SLOT")/bin/llvm-config"
257 + export LLVM_LINK_SHARED=1
258 + export RUSTFLAGS="${RUSTFLAGS} -Lnative=$("${llvm_config}" --libdir)"
259 + fi
260 +}
261 +
262 +src_prepare() {
263 + if ! use system-bootstrap; then
264 + local rust_stage0_root="${WORKDIR}"/rust-stage0
265 + local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)"
266 +
267 + "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig \
268 + --destdir="${rust_stage0_root}" --prefix=/ || die
269 + fi
270 +
271 + default
272 +}
273 +
274 +src_configure() {
275 + local rust_target="" rust_targets="" arch_cflags
276 +
277 + # Collect rust target names to compile standard libs for all ABIs.
278 + for v in $(multilib_get_enabled_abi_pairs); do
279 + rust_targets="${rust_targets},\"$(rust_abi $(get_abi_CHOST ${v##*.}))\""
280 + done
281 + if use wasm; then
282 + rust_targets="${rust_targets},\"wasm32-unknown-unknown\""
283 + if use system-llvm; then
284 + # un-hardcode rust-lld linker for this target
285 + # https://bugs.gentoo.org/715348
286 + sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/wasm32_base.rs || die
287 + fi
288 + fi
289 + rust_targets="${rust_targets#,}"
290 +
291 + local tools="\"cargo\","
292 + if use clippy; then
293 + tools="\"clippy\",$tools"
294 + fi
295 + if use miri; then
296 + tools="\"miri\",$tools"
297 + fi
298 + if use rls; then
299 + tools="\"rls\",\"analysis\",\"src\",$tools"
300 + fi
301 + if use rustfmt; then
302 + tools="\"rustfmt\",$tools"
303 + fi
304 +
305 + local rust_stage0_root
306 + if use system-bootstrap; then
307 + rust_stage0_root="$(rustc --print sysroot)"
308 + else
309 + rust_stage0_root="${WORKDIR}"/rust-stage0
310 + fi
311 +
312 + rust_target="$(rust_abi)"
313 +
314 + cat <<- _EOF_ > "${S}"/config.toml
315 + [llvm]
316 + optimize = $(toml_usex !debug)
317 + release-debuginfo = $(toml_usex debug)
318 + assertions = $(toml_usex debug)
319 + ninja = true
320 + targets = "${LLVM_TARGETS// /;}"
321 + experimental-targets = ""
322 + link-shared = $(toml_usex system-llvm)
323 + [build]
324 + build = "${rust_target}"
325 + host = ["${rust_target}"]
326 + target = [${rust_targets}]
327 + cargo = "${rust_stage0_root}/bin/cargo"
328 + rustc = "${rust_stage0_root}/bin/rustc"
329 + docs = $(toml_usex doc)
330 + compiler-docs = $(toml_usex doc)
331 + submodules = false
332 + python = "${EPYTHON}"
333 + locked-deps = true
334 + vendor = true
335 + extended = true
336 + tools = [${tools}]
337 + verbose = 2
338 + sanitizers = false
339 + profiler = false
340 + cargo-native-static = false
341 + [install]
342 + prefix = "${EPREFIX}/usr/lib/${PN}/${PV}"
343 + sysconfdir = "etc"
344 + docdir = "share/doc/rust"
345 + bindir = "bin"
346 + libdir = "lib"
347 + mandir = "share/man"
348 + [rust]
349 + # https://github.com/rust-lang/rust/issues/54872
350 + codegen-units-std = 1
351 + optimize = true
352 + debug = $(toml_usex debug)
353 + debug-assertions = $(toml_usex debug)
354 + debuginfo-level-rustc = 0
355 + backtrace = true
356 + incremental = false
357 + default-linker = "$(tc-getCC)"
358 + parallel-compiler = $(toml_usex parallel-compiler)
359 + channel = "$(usex nightly nightly stable)"
360 + rpath = false
361 + verbose-tests = true
362 + optimize-tests = $(toml_usex !debug)
363 + codegen-tests = true
364 + dist-src = false
365 + remap-debuginfo = true
366 + lld = $(usex system-llvm false $(toml_usex wasm))
367 + backtrace-on-ice = true
368 + jemalloc = false
369 + [dist]
370 + src-tarball = false
371 + _EOF_
372 +
373 + for v in $(multilib_get_enabled_abi_pairs); do
374 + rust_target=$(rust_abi $(get_abi_CHOST ${v##*.}))
375 + arch_cflags="$(get_abi_CFLAGS ${v##*.})"
376 +
377 + cat <<- _EOF_ >> "${S}"/config.env
378 + CFLAGS_${rust_target}=${arch_cflags}
379 + _EOF_
380 +
381 + cat <<- _EOF_ >> "${S}"/config.toml
382 + [target.${rust_target}]
383 + cc = "$(tc-getBUILD_CC)"
384 + cxx = "$(tc-getBUILD_CXX)"
385 + linker = "$(tc-getCC)"
386 + ar = "$(tc-getAR)"
387 + _EOF_
388 + # librustc_target/spec/linux_musl_base.rs sets base.crt_static_default = true;
389 + if use elibc_musl; then
390 + cat <<- _EOF_ >> "${S}"/config.toml
391 + crt-static = false
392 + _EOF_
393 + fi
394 + if use system-llvm; then
395 + cat <<- _EOF_ >> "${S}"/config.toml
396 + llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config"
397 + _EOF_
398 + fi
399 + done
400 + if use wasm; then
401 + cat <<- _EOF_ >> "${S}"/config.toml
402 + [target.wasm32-unknown-unknown]
403 + linker = "$(usex system-llvm lld rust-lld)"
404 + _EOF_
405 + fi
406 +
407 + if [[ -n ${I_KNOW_WHAT_I_AM_DOING_CROSS} ]]; then # whitespace intentionally shifted below
408 + # experimental cross support
409 + # discussion: https://bugs.gentoo.org/679878
410 + # TODO: c*flags, clang, system-llvm, cargo.eclass target support
411 + # it would be much better if we could split out stdlib
412 + # complilation to separate ebuild and abuse CATEGORY to
413 + # just install to /usr/lib/rustlib/<target>
414 +
415 + # extra targets defined as a bash array
416 + # spec format: <LLVM target>:<rust-target>:<CTARGET>
417 + # best place would be /etc/portage/env/dev-lang/rust
418 + # Example:
419 + # RUST_CROSS_TARGETS=(
420 + # "AArch64:aarch64-unknown-linux-gnu:aarch64-unknown-linux-gnu"
421 + # )
422 + # no extra hand holding is done, no target transformations, all
423 + # values are passed as-is with just basic checks, so it's up to user to supply correct values
424 + # valid rust targets can be obtained with
425 + # rustc --print target-list
426 + # matching cross toolchain has to be installed
427 + # matching LLVM_TARGET has to be enabled for both rust and llvm (if using system one)
428 + # only gcc toolchains installed with crossdev are checked for now.
429 +
430 + # BUG: we can't pass host flags to cross compiler, so just filter for now
431 + # BUG: this should be more fine-grained.
432 + filter-flags '-mcpu=*' '-march=*' '-mtune=*'
433 +
434 + local cross_target_spec
435 + for cross_target_spec in "${RUST_CROSS_TARGETS[@]}";do
436 + # extracts first element form <LLVM target>:<rust-target>:<CTARGET>
437 + local cross_llvm_target="${cross_target_spec%%:*}"
438 + # extracts toolchain triples, <rust-target>:<CTARGET>
439 + local cross_triples="${cross_target_spec#*:}"
440 + # extracts first element after before : separator
441 + local cross_rust_target="${cross_triples%%:*}"
442 + # extracts last element after : separator
443 + local cross_toolchain="${cross_triples##*:}"
444 + use llvm_targets_${cross_llvm_target} || die "need llvm_targets_${cross_llvm_target} target enabled"
445 + command -v ${cross_toolchain}-gcc > /dev/null 2>&1 || die "need ${cross_toolchain} cross toolchain"
446 +
447 + cat <<- _EOF_ >> "${S}"/config.toml
448 + [target.${cross_rust_target}]
449 + cc = "${cross_toolchain}-gcc"
450 + cxx = "${cross_toolchain}-g++"
451 + linker = "${cross_toolchain}-gcc"
452 + ar = "${cross_toolchain}-ar"
453 + _EOF_
454 + if use system-llvm; then
455 + cat <<- _EOF_ >> "${S}"/config.toml
456 + llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config"
457 + _EOF_
458 + fi
459 +
460 + # append cross target to "normal" target list
461 + # example 'target = ["powerpc64le-unknown-linux-gnu"]'
462 + # becomes 'target = ["powerpc64le-unknown-linux-gnu","aarch64-unknown-linux-gnu"]'
463 +
464 + rust_targets="${rust_targets},\"${cross_rust_target}\""
465 + sed -i "/^target = \[/ s#\[.*\]#\[${rust_targets}\]#" config.toml || die
466 +
467 + ewarn
468 + ewarn "Enabled ${cross_rust_target} rust target"
469 + ewarn "Using ${cross_toolchain} cross toolchain"
470 + ewarn
471 + if ! has_version -b 'sys-devel/binutils[multitarget]' ; then
472 + ewarn "'sys-devel/binutils[multitarget]' is not installed"
473 + ewarn "'strip' will be unable to strip cross libraries"
474 + ewarn "cross targets will be installed with full debug information"
475 + ewarn "enable 'multitarget' USE flag for binutils to be able to strip object files"
476 + ewarn
477 + ewarn "Alternatively llvm-strip can be used, it supports stripping any target"
478 + ewarn "define STRIP=\"llvm-strip\" to use it (experimental)"
479 + ewarn
480 + fi
481 + done
482 + fi # I_KNOW_WHAT_I_AM_DOING_CROSS
483 +
484 + einfo "Rust configured with the following settings:"
485 + cat "${S}"/config.toml || die
486 +}
487 +
488 +src_compile() {
489 + # we need \n IFS to have config.env with spaces loaded properly. #734018
490 + (
491 + IFS=$'\n'
492 + env $(cat "${S}"/config.env) RUST_BACKTRACE=1\
493 + "${EPYTHON}" ./x.py dist -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die
494 + )
495 +}
496 +
497 +src_test() {
498 + # https://rustc-dev-guide.rust-lang.org/tests/intro.html
499 +
500 + # those are basic and codegen tests.
501 + local tests=(
502 + codegen
503 + codegen-units
504 + compile-fail
505 + incremental
506 + mir-opt
507 + pretty
508 + run-make
509 + )
510 +
511 + # fails if llvm is not built with ALL targets.
512 + # and known to fail with system llvm sometimes.
513 + use system-llvm || tests+=( assembly )
514 +
515 + # fragile/expensive/less important tests
516 + # or tests that require extra builds
517 + # TODO: instead of skipping, just make some nonfatal.
518 + if [[ ${ERUST_RUN_EXTRA_TESTS:-no} != no ]]; then
519 + tests+=(
520 + rustdoc
521 + rustdoc-js
522 + rustdoc-js-std
523 + rustdoc-ui
524 + run-make-fulldeps
525 + ui
526 + ui-fulldeps
527 + )
528 + fi
529 +
530 + local i failed=()
531 + einfo "rust_src_test: enabled tests ${tests[@]/#/src/test/}"
532 + for i in "${tests[@]}"; do
533 + local t="src/test/${i}"
534 + einfo "rust_src_test: running ${t}"
535 + if ! (
536 + IFS=$'\n'
537 + env $(cat "${S}"/config.env) RUST_BACKTRACE=1 \
538 + "${EPYTHON}" ./x.py test -vv --config="${S}"/config.toml \
539 + -j$(makeopts_jobs) --no-doc --no-fail-fast "${t}"
540 + )
541 + then
542 + failed+=( "${t}" )
543 + eerror "rust_src_test: ${t} failed"
544 + fi
545 + done
546 +
547 + if [[ ${#failed[@]} -ne 0 ]]; then
548 + eerror "rust_src_test: failure summary: ${failed[@]}"
549 + die "aborting due to test failures"
550 + fi
551 +}
552 +
553 +src_install() {
554 + # https://github.com/rust-lang/rust/issues/77721
555 + # also 1.46.0-don-t-create-prefix-at-time-of-check.patch
556 + dodir "/usr/lib/${PN}/${PV}"
557 + (
558 + IFS=$'\n'
559 + env $(cat "${S}"/config.env) DESTDIR="${D}" \
560 + "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml || die
561 + )
562 +
563 + # bug #689562, #689160
564 + rm -v "${ED}/usr/lib/${PN}/${PV}/etc/bash_completion.d/cargo" || die
565 + rmdir -v "${ED}/usr/lib/${PN}/${PV}"/etc{/bash_completion.d,} || die
566 + newbashcomp src/tools/cargo/src/etc/cargo.bashcomp.sh cargo
567 +
568 + local symlinks=(
569 + cargo
570 + rustc
571 + rustdoc
572 + rust-gdb
573 + rust-gdbgui
574 + rust-lldb
575 + )
576 +
577 + use clippy && symlinks+=( clippy-driver cargo-clippy )
578 + use miri && symlinks+=( miri cargo-miri )
579 + use rls && symlinks+=( rls )
580 + use rustfmt && symlinks+=( rustfmt cargo-fmt )
581 +
582 + einfo "installing eselect-rust symlinks and paths: ${symlinks[@]}"
583 + local i
584 + for i in "${symlinks[@]}"; do
585 + # we need realpath on /usr/bin/* symlink return version-appended binary path.
586 + # so /usr/bin/rustc should point to /usr/lib/rust/<ver>/bin/rustc-<ver>
587 + # need to fix eselect-rust to remove this hack.
588 + local ver_i="${i}-${PV}"
589 + if [[ -f "${ED}/usr/lib/${PN}/${PV}/bin/${i}" ]]; then
590 + einfo "Installing ${i} symlink"
591 + ln -v "${ED}/usr/lib/${PN}/${PV}/bin/${i}" "${ED}/usr/lib/${PN}/${PV}/bin/${ver_i}" || die
592 + else
593 + ewarn "${i} symlink requested, but source file not found"
594 + ewarn "please report this"
595 + fi
596 + dosym "../lib/${PN}/${PV}/bin/${ver_i}" "/usr/bin/${ver_i}"
597 + done
598 +
599 + # symlinks to switch components to active rust in eselect
600 + dosym "${PV}/lib" "/usr/lib/${PN}/lib-${PV}"
601 + dosym "${PV}/libexec" "/usr/lib/${PN}/libexec-${PV}"
602 + dosym "${PV}/share/man" "/usr/lib/${PN}/man-${PV}"
603 + dosym "rust/${PV}/lib/rustlib" "/usr/lib/rustlib-${PV}"
604 + dosym "../../lib/${PN}/${PV}/share/doc/rust" "/usr/share/doc/${P}"
605 +
606 + newenvd - "50${P}" <<-_EOF_
607 + LDPATH="${EPREFIX}/usr/lib/rust/lib"
608 + MANPATH="${EPREFIX}/usr/lib/rust/man"
609 + $(use amd64 && usex elibc_musl 'CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=-crt-static"' '')
610 + $(use arm64 && usex elibc_musl 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=-crt-static"' '')
611 + _EOF_
612 +
613 + rm -rf "${ED}/usr/lib/${PN}/${PV}"/*.old || die
614 + rm -rf "${ED}/usr/lib/${PN}/${PV}/doc"/*.old || die
615 +
616 + # note: eselect-rust adds EROOT to all paths below
617 + cat <<-_EOF_ > "${T}/provider-${P}"
618 + /usr/bin/cargo
619 + /usr/bin/rustdoc
620 + /usr/bin/rust-gdb
621 + /usr/bin/rust-gdbgui
622 + /usr/bin/rust-lldb
623 + /usr/lib/rustlib
624 + /usr/lib/rust/lib
625 + /usr/lib/rust/libexec
626 + /usr/lib/rust/man
627 + /usr/share/doc/rust
628 + _EOF_
629 +
630 + if use clippy; then
631 + echo /usr/bin/clippy-driver >> "${T}/provider-${P}"
632 + echo /usr/bin/cargo-clippy >> "${T}/provider-${P}"
633 + fi
634 + if use miri; then
635 + echo /usr/bin/miri >> "${T}/provider-${P}"
636 + echo /usr/bin/cargo-miri >> "${T}/provider-${P}"
637 + fi
638 + if use rls; then
639 + echo /usr/bin/rls >> "${T}/provider-${P}"
640 + fi
641 + if use rustfmt; then
642 + echo /usr/bin/rustfmt >> "${T}/provider-${P}"
643 + echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
644 + fi
645 +
646 + insinto /etc/env.d/rust
647 + doins "${T}/provider-${P}"
648 +}
649 +
650 +pkg_postinst() {
651 + eselect rust update
652 +
653 + if has_version sys-devel/gdb || has_version dev-util/lldb; then
654 + elog "Rust installs a helper script for calling GDB and LLDB,"
655 + elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}."
656 + fi
657 +
658 + if has_version app-editors/emacs; then
659 + elog "install app-emacs/rust-mode to get emacs support for rust."
660 + fi
661 +
662 + if has_version app-editors/gvim || has_version app-editors/vim; then
663 + elog "install app-vim/rust-vim to get vim support for rust."
664 + fi
665 +}
666 +
667 +pkg_postrm() {
668 + eselect rust cleanup
669 +}