Gentoo Archives: gentoo-commits

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