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: Fri, 01 Jul 2022 19:32:51
Message-Id: 1656703743.4b9147cfc20fc6fd4e52a0c4573f02b4a69c4e03.gyakovlev@gentoo
1 commit: 4b9147cfc20fc6fd4e52a0c4573f02b4a69c4e03
2 Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jul 1 17:41:02 2022 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Fri Jul 1 19:29:03 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4b9147cf
7
8 dev-lang/rust: drop 1.61.0-r1
9
10 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
11
12 dev-lang/rust/rust-1.61.0-r1.ebuild | 729 ------------------------------------
13 1 file changed, 729 deletions(-)
14
15 diff --git a/dev-lang/rust/rust-1.61.0-r1.ebuild b/dev-lang/rust/rust-1.61.0-r1.ebuild
16 deleted file mode 100644
17 index f2d87f021ce4..000000000000
18 --- a/dev-lang/rust/rust-1.61.0-r1.ebuild
19 +++ /dev/null
20 @@ -1,729 +0,0 @@
21 -# Copyright 1999-2022 Gentoo Authors
22 -# Distributed under the terms of the GNU General Public License v2
23 -
24 -EAPI=8
25 -
26 -PYTHON_COMPAT=( python3_{8..10} )
27 -
28 -inherit bash-completion-r1 check-reqs estack flag-o-matic llvm multiprocessing \
29 - multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs verify-sig
30 -
31 -if [[ ${PV} = *beta* ]]; then
32 - betaver=${PV//*beta}
33 - BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}"
34 - MY_P="rustc-beta"
35 - SLOT="beta/${PV}"
36 - SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz -> rustc-${PV}-src.tar.xz"
37 -else
38 - ABI_VER="$(ver_cut 1-2)"
39 - SLOT="stable/${ABI_VER}"
40 - MY_P="rustc-${PV}"
41 - SRC="${MY_P}-src.tar.xz"
42 - KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~sparc ~x86"
43 -fi
44 -
45 -RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
46 -
47 -DESCRIPTION="Systems programming language from Mozilla"
48 -HOMEPAGE="https://www.rust-lang.org/"
49 -
50 -SRC_URI="
51 - https://static.rust-lang.org/dist/${SRC}
52 - verify-sig? ( https://static.rust-lang.org/dist/${SRC}.asc )
53 - !system-bootstrap? ( $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION}) )
54 -"
55 -
56 -# keep in sync with llvm ebuild of the same version as bundled one.
57 -ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430
58 - NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore )
59 -ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
60 -LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/(-)?}
61 -
62 -LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
63 -
64 -IUSE="clippy cpu_flags_x86_sse2 debug dist doc miri nightly parallel-compiler profiler rls rustfmt rust-src system-bootstrap system-llvm test wasm ${ALL_LLVM_TARGETS[*]}"
65 -
66 -# Please keep the LLVM dependency block separate. Since LLVM is slotted,
67 -# we need to *really* make sure we're not pulling more than one slot
68 -# simultaneously.
69 -
70 -# How to use it:
71 -# List all the working slots in LLVM_VALID_SLOTS, newest first.
72 -LLVM_VALID_SLOTS=( 14 )
73 -LLVM_MAX_SLOT="${LLVM_VALID_SLOTS[0]}"
74 -
75 -# splitting usedeps needed to avoid CI/pkgcheck's UncheckableDep limitation
76 -# (-) usedep needed because we may build with older llvm without that target
77 -LLVM_DEPEND="|| ( "
78 -for _s in ${LLVM_VALID_SLOTS[@]}; do
79 - LLVM_DEPEND+=" ( "
80 - for _x in ${ALL_LLVM_TARGETS[@]}; do
81 - LLVM_DEPEND+="
82 - ${_x}? ( sys-devel/llvm:${_s}[${_x}(-)] )"
83 - done
84 - LLVM_DEPEND+=" )"
85 -done
86 -unset _s _x
87 -LLVM_DEPEND+=" )
88 - <sys-devel/llvm-$(( LLVM_MAX_SLOT + 1 )):=
89 - wasm? ( sys-devel/lld )
90 -"
91 -
92 -# to bootstrap we need at least exactly previous version, or same.
93 -# most of the time previous versions fail to bootstrap with newer
94 -# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
95 -# but it fails to bootstrap with 1.48.x
96 -# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.txt
97 -RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
98 -RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
99 -BOOTSTRAP_DEPEND="||
100 - (
101 - =dev-lang/rust-"${RUST_DEP_PREV}"
102 - =dev-lang/rust-bin-"${RUST_DEP_PREV}"
103 - =dev-lang/rust-"${RUST_DEP_CURR}"
104 - =dev-lang/rust-bin-"${RUST_DEP_CURR}"
105 - )
106 -"
107 -
108 -BDEPEND="${PYTHON_DEPS}
109 - app-eselect/eselect-rust
110 - || (
111 - >=sys-devel/gcc-4.7
112 - >=sys-devel/clang-3.5
113 - )
114 - system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
115 - !system-llvm? (
116 - >=dev-util/cmake-3.13.4
117 - dev-util/ninja
118 - )
119 - test? ( sys-devel/gdb )
120 - verify-sig? ( sec-keys/openpgp-keys-rust )
121 -"
122 -
123 -DEPEND="
124 - >=app-arch/xz-utils-5.2
125 - net-misc/curl:=[http2,ssl]
126 - sys-libs/zlib:=
127 - dev-libs/openssl:0=
128 - elibc_musl? ( sys-libs/libunwind:= )
129 - system-llvm? ( ${LLVM_DEPEND} )
130 -"
131 -
132 -RDEPEND="${DEPEND}
133 - app-eselect/eselect-rust
134 - sys-apps/lsb-release
135 -"
136 -
137 -REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )
138 - miri? ( nightly )
139 - parallel-compiler? ( nightly )
140 - rls? ( rust-src )
141 - test? ( ${ALL_LLVM_TARGETS[*]} )
142 - wasm? ( llvm_targets_WebAssembly )
143 - x86? ( cpu_flags_x86_sse2 )
144 -"
145 -
146 -# we don't use cmake.eclass, but can get a warning
147 -CMAKE_WARN_UNUSED_CLI=no
148 -
149 -QA_FLAGS_IGNORED="
150 - usr/lib/${PN}/${PV}/bin/.*
151 - usr/lib/${PN}/${PV}/libexec/.*
152 - usr/lib/${PN}/${PV}/lib/lib.*.so
153 - usr/lib/${PN}/${PV}/lib/rustlib/.*/bin/.*
154 - usr/lib/${PN}/${PV}/lib/rustlib/.*/lib/lib.*.so
155 -"
156 -
157 -QA_SONAME="
158 - usr/lib/${PN}/${PV}/lib/lib.*.so.*
159 - usr/lib/${PN}/${PV}/lib/rustlib/.*/lib/lib.*.so
160 -"
161 -
162 -QA_PRESTRIPPED="
163 - usr/lib/${PN}/${PV}/lib/rustlib/.*/bin/rust-llvm-dwp
164 -"
165 -
166 -# An rmeta file is custom binary format that contains the metadata for the crate.
167 -# rmeta files do not support linking, since they do not contain compiled object files.
168 -# so we can safely silence the warning for this QA check.
169 -QA_EXECSTACK="usr/lib/${PN}/${PV}/lib/rustlib/*/lib*.rlib:lib.rmeta"
170 -
171 -# causes double bootstrap
172 -RESTRICT="test"
173 -
174 -VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/rust.asc
175 -
176 -PATCHES=(
177 - "${FILESDIR}"/1.55.0-ignore-broken-and-non-applicable-tests.patch
178 - "${FILESDIR}"/1.61.0-gentoo-musl-target-specs.patch
179 - "${FILESDIR}"/1.61.0-llvm_selectInterleaveCount.patch
180 - "${FILESDIR}"/1.61.0-llvm_addrspacecast.patch
181 - "${FILESDIR}"/1.61.0-miri-cow.patch
182 -)
183 -
184 -S="${WORKDIR}/${MY_P}-src"
185 -
186 -toml_usex() {
187 - usex "${1}" true false
188 -}
189 -
190 -bootstrap_rust_version_check() {
191 - # never call from pkg_pretend. eselect-rust may be not installed yet.
192 - [[ ${MERGE_TYPE} == binary ]] && return
193 - local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
194 - local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
195 - local rustc_version=( $(eselect --brief rust show 2>/dev/null) )
196 - rustc_version=${rustc_version[0]#rust-bin-}
197 - rustc_version=${rustc_version#rust-}
198 -
199 - [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, check 'eselect rust' output"
200 -
201 - if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
202 - eerror "Rust >=${rustc_wanted} is required"
203 - eerror "please run 'eselect rust' and set correct rust version"
204 - die "selected rust version is too old"
205 - elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
206 - eerror "Rust <${rustc_toonew} is required"
207 - eerror "please run 'eselect rust' and set correct rust version"
208 - die "selected rust version is too new"
209 - else
210 - einfo "Using rust ${rustc_version} to build"
211 - fi
212 -}
213 -
214 -pre_build_checks() {
215 - local M=8192
216 - # multiply requirements by 1.3 if we are doing x86-multilib
217 - if use amd64; then
218 - M=$(( $(usex abi_x86_32 13 10) * ${M} / 10 ))
219 - fi
220 - M=$(( $(usex clippy 128 0) + ${M} ))
221 - M=$(( $(usex miri 128 0) + ${M} ))
222 - M=$(( $(usex rls 512 0) + ${M} ))
223 - M=$(( $(usex rustfmt 256 0) + ${M} ))
224 - # add 2G if we compile llvm and 256M per llvm_target
225 - if ! use system-llvm; then
226 - M=$(( 2048 + ${M} ))
227 - local ltarget
228 - for ltarget in ${ALL_LLVM_TARGETS[@]}; do
229 - M=$(( $(usex ${ltarget} 256 0) + ${M} ))
230 - done
231 - fi
232 - M=$(( $(usex wasm 256 0) + ${M} ))
233 - M=$(( $(usex debug 2 1) * ${M} ))
234 - eshopts_push -s extglob
235 - if is-flagq '-g?(gdb)?([1-9])'; then
236 - M=$(( 15 * ${M} / 10 ))
237 - fi
238 - eshopts_pop
239 - M=$(( $(usex system-bootstrap 0 1024) + ${M} ))
240 - M=$(( $(usex doc 256 0) + ${M} ))
241 - CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE}
242 -}
243 -
244 -llvm_check_deps() {
245 - has_version -r "sys-devel/llvm:${LLVM_SLOT}[${LLVM_TARGET_USEDEPS// /,}]"
246 -}
247 -
248 -pkg_pretend() {
249 - pre_build_checks
250 -}
251 -
252 -pkg_setup() {
253 - pre_build_checks
254 - python-any-r1_pkg_setup
255 -
256 - export LIBGIT2_NO_PKG_CONFIG=1 #749381
257 -
258 - use system-bootstrap && bootstrap_rust_version_check
259 -
260 - if use system-llvm; then
261 - llvm_pkg_setup
262 -
263 - local llvm_config="$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config"
264 - export LLVM_LINK_SHARED=1
265 - export RUSTFLAGS="${RUSTFLAGS} -Lnative=$("${llvm_config}" --libdir)"
266 - fi
267 -}
268 -
269 -src_prepare() {
270 - if ! use system-bootstrap; then
271 - local rust_stage0_root="${WORKDIR}"/rust-stage0
272 - local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)"
273 -
274 - "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig \
275 - --without=rust-docs --destdir="${rust_stage0_root}" --prefix=/ || die
276 - fi
277 -
278 - default
279 -}
280 -
281 -src_configure() {
282 - local rust_target="" rust_targets="" arch_cflags use_libcxx="false"
283 -
284 - # Collect rust target names to compile standard libs for all ABIs.
285 - for v in $(multilib_get_enabled_abi_pairs); do
286 - rust_targets="${rust_targets},\"$(rust_abi $(get_abi_CHOST ${v##*.}))\""
287 - done
288 - if use wasm; then
289 - rust_targets="${rust_targets},\"wasm32-unknown-unknown\""
290 - if use system-llvm; then
291 - # un-hardcode rust-lld linker for this target
292 - # https://bugs.gentoo.org/715348
293 - sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/wasm_base.rs || die
294 - fi
295 - fi
296 - rust_targets="${rust_targets#,}"
297 -
298 - local tools="\"cargo\","
299 - if use clippy; then
300 - tools="\"clippy\",$tools"
301 - fi
302 - if use miri; then
303 - tools="\"miri\",$tools"
304 - fi
305 - if use profiler; then
306 - tools="\"rust-demangler\",$tools"
307 - fi
308 - if use rls; then
309 - tools="\"rls\",\"analysis\",$tools"
310 - fi
311 - if use rustfmt; then
312 - tools="\"rustfmt\",$tools"
313 - fi
314 - if use rust-src; then
315 - tools="\"src\",$tools"
316 - fi
317 -
318 - local rust_stage0_root
319 - if use system-bootstrap; then
320 - local printsysroot
321 - printsysroot="$(rustc --print sysroot || die "Can't determine rust's sysroot")"
322 - rust_stage0_root="${printsysroot}"
323 - else
324 - rust_stage0_root="${WORKDIR}"/rust-stage0
325 - fi
326 - # in case of prefix it will be already prefixed, as --print sysroot returns full path
327 - [[ -d ${rust_stage0_root} ]] || die "${rust_stage0_root} is not a directory"
328 -
329 - rust_target="$(rust_abi)"
330 -
331 - # https://bugs.gentoo.org/732632
332 - if tc-is-clang; then
333 - local clang_slot="$(clang-major-version)"
334 - if { has_version "sys-devel/clang:${clang_slot}[default-libcxx]" || is-flagq -stdlib=libc++; }; then
335 - use_libcxx="true"
336 - fi
337 - fi
338 -
339 - cat <<- _EOF_ > "${S}"/config.toml
340 - changelog-seen = 2
341 - [llvm]
342 - download-ci-llvm = false
343 - optimize = $(toml_usex !debug)
344 - release-debuginfo = $(toml_usex debug)
345 - assertions = $(toml_usex debug)
346 - ninja = true
347 - targets = "${LLVM_TARGETS// /;}"
348 - experimental-targets = ""
349 - link-shared = $(toml_usex system-llvm)
350 - $(if [[ ${use_libcxx} == true ]]; then
351 - echo "use-libcxx = true"
352 - echo "static-libstdcpp = false"
353 - fi)
354 - $(case "${rust_target}" in
355 - i586-*-linux-*)
356 - # https://github.com/rust-lang/rust/issues/93059
357 - echo 'cflags = "-fcf-protection=none"'
358 - echo 'cxxflags = "-fcf-protection=none"'
359 - echo 'ldflags = "-fcf-protection=none"'
360 - ;;
361 - *)
362 - ;;
363 - esac)
364 - [build]
365 - build-stage = 2
366 - test-stage = 2
367 - doc-stage = 2
368 - build = "${rust_target}"
369 - host = ["${rust_target}"]
370 - target = [${rust_targets}]
371 - cargo = "${rust_stage0_root}/bin/cargo"
372 - rustc = "${rust_stage0_root}/bin/rustc"
373 - rustfmt = "${rust_stage0_root}/bin/rustfmt"
374 - docs = $(toml_usex doc)
375 - compiler-docs = false
376 - submodules = false
377 - python = "${EPYTHON}"
378 - locked-deps = true
379 - vendor = true
380 - extended = true
381 - tools = [${tools}]
382 - verbose = 2
383 - sanitizers = false
384 - profiler = $(toml_usex profiler)
385 - cargo-native-static = false
386 - [install]
387 - prefix = "${EPREFIX}/usr/lib/${PN}/${PV}"
388 - sysconfdir = "etc"
389 - docdir = "share/doc/rust"
390 - bindir = "bin"
391 - libdir = "lib"
392 - mandir = "share/man"
393 - [rust]
394 - # https://github.com/rust-lang/rust/issues/54872
395 - codegen-units-std = 1
396 - optimize = true
397 - debug = $(toml_usex debug)
398 - debug-assertions = $(toml_usex debug)
399 - debug-assertions-std = $(toml_usex debug)
400 - debuginfo-level = $(usex debug 2 0)
401 - debuginfo-level-rustc = $(usex debug 2 0)
402 - debuginfo-level-std = $(usex debug 2 0)
403 - debuginfo-level-tools = $(usex debug 2 0)
404 - debuginfo-level-tests = 0
405 - backtrace = true
406 - incremental = false
407 - default-linker = "$(tc-getCC)"
408 - parallel-compiler = $(toml_usex parallel-compiler)
409 - channel = "$(usex nightly nightly stable)"
410 - description = "gentoo"
411 - rpath = false
412 - verbose-tests = true
413 - optimize-tests = $(toml_usex !debug)
414 - codegen-tests = true
415 - dist-src = false
416 - remap-debuginfo = true
417 - lld = $(usex system-llvm false $(toml_usex wasm))
418 - # only deny warnings if doc+wasm are NOT requested, documenting stage0 wasm std fails without it
419 - # https://github.com/rust-lang/rust/issues/74976
420 - # https://github.com/rust-lang/rust/issues/76526
421 - deny-warnings = $(usex wasm $(usex doc false true) true)
422 - backtrace-on-ice = true
423 - jemalloc = false
424 - [dist]
425 - src-tarball = false
426 - compression-formats = ["xz"]
427 - _EOF_
428 -
429 - for v in $(multilib_get_enabled_abi_pairs); do
430 - rust_target=$(rust_abi $(get_abi_CHOST ${v##*.}))
431 - arch_cflags="$(get_abi_CFLAGS ${v##*.})"
432 -
433 - cat <<- _EOF_ >> "${S}"/config.env
434 - CFLAGS_${rust_target}=${arch_cflags}
435 - _EOF_
436 -
437 - cat <<- _EOF_ >> "${S}"/config.toml
438 - [target.${rust_target}]
439 - ar = "$(tc-getAR)"
440 - cc = "$(tc-getCC)"
441 - cxx = "$(tc-getCXX)"
442 - linker = "$(tc-getCC)"
443 - ranlib = "$(tc-getRANLIB)"
444 - _EOF_
445 - # librustc_target/spec/linux_musl_base.rs sets base.crt_static_default = true;
446 - if use elibc_musl; then
447 - cat <<- _EOF_ >> "${S}"/config.toml
448 - crt-static = false
449 - _EOF_
450 - fi
451 - if use system-llvm; then
452 - cat <<- _EOF_ >> "${S}"/config.toml
453 - llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config"
454 - _EOF_
455 - fi
456 - done
457 - if use wasm; then
458 - cat <<- _EOF_ >> "${S}"/config.toml
459 - [target.wasm32-unknown-unknown]
460 - linker = "$(usex system-llvm lld rust-lld)"
461 - # wasm target does not have profiler_builtins https://bugs.gentoo.org/848483
462 - profiler = false
463 - _EOF_
464 - fi
465 -
466 - if [[ -n ${I_KNOW_WHAT_I_AM_DOING_CROSS} ]]; then # whitespace intentionally shifted below
467 - # experimental cross support
468 - # discussion: https://bugs.gentoo.org/679878
469 - # TODO: c*flags, clang, system-llvm, cargo.eclass target support
470 - # it would be much better if we could split out stdlib
471 - # complilation to separate ebuild and abuse CATEGORY to
472 - # just install to /usr/lib/rustlib/<target>
473 -
474 - # extra targets defined as a bash array
475 - # spec format: <LLVM target>:<rust-target>:<CTARGET>
476 - # best place would be /etc/portage/env/dev-lang/rust
477 - # Example:
478 - # RUST_CROSS_TARGETS=(
479 - # "AArch64:aarch64-unknown-linux-gnu:aarch64-unknown-linux-gnu"
480 - # )
481 - # no extra hand holding is done, no target transformations, all
482 - # values are passed as-is with just basic checks, so it's up to user to supply correct values
483 - # valid rust targets can be obtained with
484 - # rustc --print target-list
485 - # matching cross toolchain has to be installed
486 - # matching LLVM_TARGET has to be enabled for both rust and llvm (if using system one)
487 - # only gcc toolchains installed with crossdev are checked for now.
488 -
489 - # BUG: we can't pass host flags to cross compiler, so just filter for now
490 - # BUG: this should be more fine-grained.
491 - filter-flags '-mcpu=*' '-march=*' '-mtune=*'
492 -
493 - local cross_target_spec
494 - for cross_target_spec in "${RUST_CROSS_TARGETS[@]}";do
495 - # extracts first element form <LLVM target>:<rust-target>:<CTARGET>
496 - local cross_llvm_target="${cross_target_spec%%:*}"
497 - # extracts toolchain triples, <rust-target>:<CTARGET>
498 - local cross_triples="${cross_target_spec#*:}"
499 - # extracts first element after before : separator
500 - local cross_rust_target="${cross_triples%%:*}"
501 - # extracts last element after : separator
502 - local cross_toolchain="${cross_triples##*:}"
503 - use llvm_targets_${cross_llvm_target} || die "need llvm_targets_${cross_llvm_target} target enabled"
504 - command -v ${cross_toolchain}-gcc > /dev/null 2>&1 || die "need ${cross_toolchain} cross toolchain"
505 -
506 - cat <<- _EOF_ >> "${S}"/config.toml
507 - [target.${cross_rust_target}]
508 - ar = "${cross_toolchain}-ar"
509 - cc = "${cross_toolchain}-gcc"
510 - cxx = "${cross_toolchain}-g++"
511 - linker = "${cross_toolchain}-gcc"
512 - ranlib = "${cross_toolchain}-ranlib"
513 - _EOF_
514 - if use system-llvm; then
515 - cat <<- _EOF_ >> "${S}"/config.toml
516 - llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config"
517 - _EOF_
518 - fi
519 - if [[ "${cross_toolchain}" == *-musl* ]]; then
520 - cat <<- _EOF_ >> "${S}"/config.toml
521 - musl-root = "$(${cross_toolchain}-gcc -print-sysroot)/usr"
522 - _EOF_
523 - fi
524 -
525 - # append cross target to "normal" target list
526 - # example 'target = ["powerpc64le-unknown-linux-gnu"]'
527 - # becomes 'target = ["powerpc64le-unknown-linux-gnu","aarch64-unknown-linux-gnu"]'
528 -
529 - rust_targets="${rust_targets},\"${cross_rust_target}\""
530 - sed -i "/^target = \[/ s#\[.*\]#\[${rust_targets}\]#" config.toml || die
531 -
532 - ewarn
533 - ewarn "Enabled ${cross_rust_target} rust target"
534 - ewarn "Using ${cross_toolchain} cross toolchain"
535 - ewarn
536 - if ! has_version -b 'sys-devel/binutils[multitarget]' ; then
537 - ewarn "'sys-devel/binutils[multitarget]' is not installed"
538 - ewarn "'strip' will be unable to strip cross libraries"
539 - ewarn "cross targets will be installed with full debug information"
540 - ewarn "enable 'multitarget' USE flag for binutils to be able to strip object files"
541 - ewarn
542 - ewarn "Alternatively llvm-strip can be used, it supports stripping any target"
543 - ewarn "define STRIP=\"llvm-strip\" to use it (experimental)"
544 - ewarn
545 - fi
546 - done
547 - fi # I_KNOW_WHAT_I_AM_DOING_CROSS
548 -
549 - einfo "Rust configured with the following flags:"
550 - echo
551 - echo RUSTFLAGS="${RUSTFLAGS:-}"
552 - echo RUSTFLAGS_BOOTSTRAP="${RUSTFLAGS_BOOTSTRAP:-}"
553 - echo RUSTFLAGS_NOT_BOOTSTRAP="${RUSTFLAGS_NOT_BOOTSTRAP:-}"
554 - env | grep "CARGO_TARGET_.*_RUSTFLAGS="
555 - cat "${S}"/config.env || die
556 - echo
557 - einfo "config.toml contents:"
558 - cat "${S}"/config.toml || die
559 - echo
560 -}
561 -
562 -src_compile() {
563 - # we need \n IFS to have config.env with spaces loaded properly. #734018
564 - (
565 - IFS=$'\n'
566 - env $(cat "${S}"/config.env) RUST_BACKTRACE=1\
567 - "${EPYTHON}" ./x.py build -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die
568 - )
569 -}
570 -
571 -src_test() {
572 - # https://rustc-dev-guide.rust-lang.org/tests/intro.html
573 -
574 - # those are basic and codegen tests.
575 - local tests=(
576 - codegen
577 - codegen-units
578 - compile-fail
579 - incremental
580 - mir-opt
581 - pretty
582 - run-make
583 - )
584 -
585 - # fails if llvm is not built with ALL targets.
586 - # and known to fail with system llvm sometimes.
587 - use system-llvm || tests+=( assembly )
588 -
589 - # fragile/expensive/less important tests
590 - # or tests that require extra builds
591 - # TODO: instead of skipping, just make some nonfatal.
592 - if [[ ${ERUST_RUN_EXTRA_TESTS:-no} != no ]]; then
593 - tests+=(
594 - rustdoc
595 - rustdoc-js
596 - rustdoc-js-std
597 - rustdoc-ui
598 - run-make-fulldeps
599 - ui
600 - ui-fulldeps
601 - )
602 - fi
603 -
604 - local i failed=()
605 - einfo "rust_src_test: enabled tests ${tests[@]/#/src/test/}"
606 - for i in "${tests[@]}"; do
607 - local t="src/test/${i}"
608 - einfo "rust_src_test: running ${t}"
609 - if ! (
610 - IFS=$'\n'
611 - env $(cat "${S}"/config.env) RUST_BACKTRACE=1 \
612 - "${EPYTHON}" ./x.py test -vv --config="${S}"/config.toml \
613 - -j$(makeopts_jobs) --no-doc --no-fail-fast "${t}"
614 - )
615 - then
616 - failed+=( "${t}" )
617 - eerror "rust_src_test: ${t} failed"
618 - fi
619 - done
620 -
621 - if [[ ${#failed[@]} -ne 0 ]]; then
622 - eerror "rust_src_test: failure summary: ${failed[@]}"
623 - die "aborting due to test failures"
624 - fi
625 -}
626 -
627 -src_install() {
628 - (
629 - IFS=$'\n'
630 - env $(cat "${S}"/config.env) DESTDIR="${D}" \
631 - "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die
632 - )
633 -
634 - # bug #689562, #689160
635 - rm -v "${ED}/usr/lib/${PN}/${PV}/etc/bash_completion.d/cargo" || die
636 - rmdir -v "${ED}/usr/lib/${PN}/${PV}"/etc{/bash_completion.d,} || die
637 - newbashcomp src/tools/cargo/src/etc/cargo.bashcomp.sh cargo
638 -
639 - local symlinks=(
640 - cargo
641 - rustc
642 - rustdoc
643 - rust-gdb
644 - rust-gdbgui
645 - rust-lldb
646 - )
647 -
648 - use clippy && symlinks+=( clippy-driver cargo-clippy )
649 - use miri && symlinks+=( miri cargo-miri )
650 - use profiler && symlinks+=( rust-demangler )
651 - use rls && symlinks+=( rls )
652 - use rustfmt && symlinks+=( rustfmt cargo-fmt )
653 -
654 - einfo "installing eselect-rust symlinks and paths: ${symlinks[@]}"
655 - local i
656 - for i in "${symlinks[@]}"; do
657 - # we need realpath on /usr/bin/* symlink return version-appended binary path.
658 - # so /usr/bin/rustc should point to /usr/lib/rust/<ver>/bin/rustc-<ver>
659 - # need to fix eselect-rust to remove this hack.
660 - local ver_i="${i}-${PV}"
661 - if [[ -f "${ED}/usr/lib/${PN}/${PV}/bin/${i}" ]]; then
662 - einfo "Installing ${i} symlink"
663 - ln -v "${ED}/usr/lib/${PN}/${PV}/bin/${i}" "${ED}/usr/lib/${PN}/${PV}/bin/${ver_i}" || die
664 - else
665 - ewarn "${i} symlink requested, but source file not found"
666 - ewarn "please report this"
667 - fi
668 - dosym "../lib/${PN}/${PV}/bin/${ver_i}" "/usr/bin/${ver_i}"
669 - done
670 -
671 - # symlinks to switch components to active rust in eselect
672 - dosym "${PV}/lib" "/usr/lib/${PN}/lib-${PV}"
673 - dosym "${PV}/libexec" "/usr/lib/${PN}/libexec-${PV}"
674 - dosym "${PV}/share/man" "/usr/lib/${PN}/man-${PV}"
675 - dosym "rust/${PV}/lib/rustlib" "/usr/lib/rustlib-${PV}"
676 - dosym "../../lib/${PN}/${PV}/share/doc/rust" "/usr/share/doc/${P}"
677 -
678 - newenvd - "50${P}" <<-_EOF_
679 - LDPATH="${EPREFIX}/usr/lib/rust/lib"
680 - MANPATH="${EPREFIX}/usr/lib/rust/man"
681 - $(use amd64 && usex elibc_musl 'CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=-crt-static"' '')
682 - $(use arm64 && usex elibc_musl 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=-crt-static"' '')
683 - _EOF_
684 -
685 - rm -rf "${ED}/usr/lib/${PN}/${PV}"/*.old || die
686 - rm -rf "${ED}/usr/lib/${PN}/${PV}/doc"/*.old || die
687 -
688 - # note: eselect-rust adds EROOT to all paths below
689 - cat <<-_EOF_ > "${T}/provider-${P}"
690 - /usr/bin/cargo
691 - /usr/bin/rustdoc
692 - /usr/bin/rust-gdb
693 - /usr/bin/rust-gdbgui
694 - /usr/bin/rust-lldb
695 - /usr/lib/rustlib
696 - /usr/lib/rust/lib
697 - /usr/lib/rust/libexec
698 - /usr/lib/rust/man
699 - /usr/share/doc/rust
700 - _EOF_
701 -
702 - if use clippy; then
703 - echo /usr/bin/clippy-driver >> "${T}/provider-${P}"
704 - echo /usr/bin/cargo-clippy >> "${T}/provider-${P}"
705 - fi
706 - if use miri; then
707 - echo /usr/bin/miri >> "${T}/provider-${P}"
708 - echo /usr/bin/cargo-miri >> "${T}/provider-${P}"
709 - fi
710 - if use profiler; then
711 - echo /usr/bin/rust-demangler >> "${T}/provider-${P}"
712 - fi
713 - if use rls; then
714 - echo /usr/bin/rls >> "${T}/provider-${P}"
715 - fi
716 - if use rustfmt; then
717 - echo /usr/bin/rustfmt >> "${T}/provider-${P}"
718 - echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
719 - fi
720 -
721 - insinto /etc/env.d/rust
722 - doins "${T}/provider-${P}"
723 -
724 - if use dist; then
725 - insinto "/usr/lib/${PN}/${PV}/dist"
726 - doins -r "${S}/build/dist/."
727 - fi
728 -}
729 -
730 -pkg_postinst() {
731 - eselect rust update
732 -
733 - if has_version sys-devel/gdb || has_version dev-util/lldb; then
734 - elog "Rust installs a helper script for calling GDB and LLDB,"
735 - elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}."
736 - fi
737 -
738 - if has_version app-editors/emacs; then
739 - elog "install app-emacs/rust-mode to get emacs support for rust."
740 - fi
741 -
742 - if has_version app-editors/gvim || has_version app-editors/vim; then
743 - elog "install app-vim/rust-vim to get vim support for rust."
744 - fi
745 -}
746 -
747 -pkg_postrm() {
748 - eselect rust cleanup
749 -}