From d1213c7db33bf8664a9a03b742dcca45c52813cf Mon Sep 17 00:00:00 2001 From: Georgy Yakovlev Date: Thu, 11 Feb 2021 14:23:08 -0800 Subject: dev-lang/rust: bump to 1.50.0 Package-Manager: Portage-3.0.14, Repoman-3.0.2 Signed-off-by: Georgy Yakovlev --- dev-lang/rust/Manifest | 15 + dev-lang/rust/rust-1.50.0.ebuild | 619 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 634 insertions(+) create mode 100644 dev-lang/rust/rust-1.50.0.ebuild (limited to 'dev-lang') diff --git a/dev-lang/rust/Manifest b/dev-lang/rust/Manifest index e296ab86edf5..74eff5ba8e9e 100644 --- a/dev-lang/rust/Manifest +++ b/dev-lang/rust/Manifest @@ -54,7 +54,22 @@ DIST rust-1.48.0-powerpc64le-unknown-linux-gnu.tar.xz 124335896 BLAKE2B fe95cb27 DIST rust-1.48.0-s390x-unknown-linux-gnu.tar.xz 127221600 BLAKE2B 08511be6aadc0feb36caa19df5914a207565eed3b4b3914cad7fc8f7170011a7431c14d50b1334f5d5e00b4c94e7e84ee59afad179286e889480cc9b21e1f402 SHA512 b2b1565f3b1cc0c3bf4aa06aba1da7df775c6e29c892ca7727d0e549f175b632080433be2586e799c5636231de6c678f0228dedee8358fbf167016a1f7d25389 DIST rust-1.48.0-x86_64-unknown-linux-gnu.tar.xz 155254844 BLAKE2B 37bce978eb297bb1732f9d513bb6fdcee4aefc42a578496a84b5f8abbb9f90f1c524c73f28c85f33c25a365bf5ba566253b1739009bb112c2e1d46a2ed978e10 SHA512 0784e156e70c47386abfa88ecfeb62b1109364459b1fee225de0749c30379c4eb443ff3ff7faa7dc1a6ff373bc6eb43997007f937889cb35daf940a74641753b DIST rust-1.48.0-x86_64-unknown-linux-musl.tar.xz 168361012 BLAKE2B efeb9a9812f2fa2cbf1cfd963b5b714cf18d73ca9b7a3de4efa701acf7e2e8fc3b610cd90f7391b10bddd1c9d44b8b0aa910f58ce739750d4e910b063825dc28 SHA512 7188fb0b1bf6fd6ab320089cd17f334867baefec1a9c57a81e6cb729276456e56850938dbd0eafbc52375266a87392ad3045a4dbd2c41689bba6b0da152e4034 +DIST rust-1.49.0-aarch64-unknown-linux-gnu.tar.xz 179627172 BLAKE2B 911fc176a7161bf3ca1a6ec01ec38d4f1792b11feb3c24c9587f8feb2923b42aa97f0e3391449ee1189507b9bdc2ef16be8f064ac3161f73aba18fd7b11c8f5d SHA512 fa81b618359c2952de941e094eabfe2966e3c1a39a1b20452a77f1a68a54dde9cc5cade18db911cf448ffe947d934461ce752112bd9b5b5430e1fcdabbd8b56a +DIST rust-1.49.0-arm-unknown-linux-gnueabi.tar.xz 172021916 BLAKE2B 69e80df9f8d582c8216adfcd27ce8a19a9af49f27423fc3ee478ccb8b60b489e36c1f38633c86c58a504b2110cebf4026dc418e55897caf60865c21209ea2366 SHA512 2ea1d8564577cb4f687384e0d933e6ed7e1e5c95aeb49410d660409a23867959bc175344fa00bdc342cf511ea867cb2d97507af117e7d5b34714e69d4b8ffaff +DIST rust-1.49.0-arm-unknown-linux-gnueabihf.tar.xz 173557760 BLAKE2B 63c1815b3bfdcb5bf1c745bd8b85cee052b2c85f42a800166da6ee66374716e899919fac7b9c75d0a6b0ddc963e22e2b842ac382eca431433cb1ef4c1d568ad4 SHA512 9c4a49b8a3bf11d5e0f3d54032e2dfee8779f3fb68676a219c9b8e344539a3dd840d912167783f3fbaa3bd3fbf73b6bdd5afa9343c042a67496ab57c9a9ca96e +DIST rust-1.49.0-armv7-unknown-linux-gnueabihf.tar.xz 176194076 BLAKE2B 1d2a1eca1d44d48cdd542411acc0f1a81767b6e62c744c800a840f3ecdcc060acd7552d342539230f85cf3e2771f8aa4a2c1ff88efaccf7021bbb2e0af71c222 SHA512 1cba85fc958371aeb1d521e8842ad576e65d244147e2c75c34eaa776552ed025434d10284fa976d901d6cede69f6db3e5fdd770005ca0b93bb5e3202b9f9392a +DIST rust-1.49.0-i686-unknown-linux-gnu.tar.xz 201492368 BLAKE2B b666693ffd3468330c3aaabc81556d3f6c907e136f98edde9ea4605bd95a5750e57432a51e5eba0643a816b4281129f1cc295cf9821d5f285cdfd8cb3cb68c3f SHA512 b4d39cb234314f013969b5db3d365d21719d7a01f2dc0816e4f221c5e6d4abecd7f9e83f54b8640173d00d3e701cb3cbb61cef32f00db9356139005a1ce3bd19 +DIST rust-1.49.0-mips-unknown-linux-gnu.tar.xz 134041460 BLAKE2B 0e779b3494221f22529ba7a4b9e1098186965d36f7cb94b5d76c84bd4703c354ebc57aa03a58fe3b5592c1543ac6193575f9d443cd8fa663a69d9af1ae7d0b82 SHA512 9293814a64d7382f97beb137ccb8beeeb76ae5f71d6db7d2c70f3c643a877f5991c0abc2d53270bccaa6aa5c8de4f0e46fe4b92ad09e2253e5cd5487a3f46d6c +DIST rust-1.49.0-mips64-unknown-linux-gnuabi64.tar.xz 143820152 BLAKE2B f22869487eac68f5ed698da1b05b1c53ae138cff79d2c5011008663b027858c5b91ce1b2f26924ecc17d13ca9559ff444e1b03a44a5b3b536e66753075c8d05a SHA512 ea1d90a388c44a2e5bd5f51dd5e8b95721e49c8284369cd638560e9c729c8a7c54ba6cccf55547f0b0b1731498623eaf743783cfd67e61c13f89f0ad9275c051 +DIST rust-1.49.0-mipsel-unknown-linux-gnu.tar.xz 140145252 BLAKE2B 5a26ca9e2af4a2d96c34da29e50c5c68b1fb0f2e6db20685853a4211042aee76f0f86b17c4697bcecce99de21ac7b60b055ed43cd2acf03dfa043eb5e3546692 SHA512 a2079d5068737cae36532c2922fc4aebf4aac723208804a128a1234ae78868f20a6559a967cf01a456ba7de2bf48ea3961fc9a31dd3bc45130b0de328a712295 +DIST rust-1.49.0-powerpc-unknown-linux-gnu.tar.xz 147163992 BLAKE2B 4822af4b54a22214425e0dd993081f0bc7b0ae0973c0e11d021a2a8671f05272b2cb6b3ca307eef9b3ad25db6a1eef7976f1e8e4ead8ac4c5226d9c7596c0f6d SHA512 905c624baccf0bbcd166407a8722909b2645c7e1993e80a37aa4cfe43d0dce5b92db2c5443295ecb79fa6c3c2cbe6e0e67ad7f8ba312075fb8960cbe50183a25 +DIST rust-1.49.0-powerpc64-unknown-linux-gnu.tar.xz 160585188 BLAKE2B f0e4a5da3767b1bfb633c899c1b9b2ee9725d8bea9154142037cbcc9212d67a364f0eb130ea4d2a4c62d0fe55a8d9d880faac2f6e167155a99a235f7ee28fc1d SHA512 36f94b0ae399f872a22c697225abcb35a893ae6e4ed369961edb693299cb58e294267b1d73a99555057618f179202a70ae2fdcff2b3bedbabf2774b3809a2a62 +DIST rust-1.49.0-powerpc64le-unknown-linux-gnu.tar.xz 169253520 BLAKE2B 4648467a84d7f81f63ddf610fce6e1e2388ce5c91a7ce73c8b8d054356bfcba379d4d0a543fdbc9bad9b689b10f8dffa4c145b83ff02ac1d77ede7f600bb5924 SHA512 c17eb27ec4dbcc56da3edffbc57e0edda99744d6a0d38369fa08af066894aeb13dd78c7b8055f2246fc3bf13c654842675ea4df44b7bc8852e0f9952acdf7e7c +DIST rust-1.49.0-s390x-unknown-linux-gnu.tar.xz 170753008 BLAKE2B a81618240d86d4a70bd27f3e33caf0258868539b3b081a8f8f461a3debf82ab1493fea18dd5a32083d1f34db268f4bff471f5f45fb3d4910dd9559f227dc3aab SHA512 25259ea2e499c89459b14571e2c54f230d642af9cfe539dc2b8be15eff0e23b8c6e60af4c567bcbb6c6c185b4537eaab19c3395fce48b1f6e5ef1234efc31e3a +DIST rust-1.49.0-x86_64-unknown-linux-gnu.tar.xz 144752500 BLAKE2B 188fafdbff02cbffae22e8a48d259119c59aa435252477ba3b4f4522cc00c90d9a242bd5ac76e8d8210bd032b8f78538e5f95606fe2c862ffd7477acdfb6e1a7 SHA512 c008aa50e17db6a0134fb85235a958258d345410f5063bc77175f7c28b2e35895427b9e68cd1ac9acb769769c83313cd59fe6465b453e891cf415a2514b7722d +DIST rust-1.49.0-x86_64-unknown-linux-musl.tar.xz 217795696 BLAKE2B 264348951db96a9f046e4bec599b92a5ee6d185d961f833f8d2127c1ac4578b91401834d09b5eed421f03d14933ff3b2e85961ff09927d19bf6c701d80eb1b67 SHA512 be165de42e3acd50f6e6a21fe386ea2333fd0f19abedbb059d6eb8ce8c80a8e79257eab8a7775e3b72307596b52e803bd8c4c46330a6e66acbadbe2f63cea42a DIST rustc-1.46.0-src.tar.xz 101868452 BLAKE2B da9798596b124a10d79c236a871228f05e5f571d22c2259328e7026c91e088c85f5de9c0536a16531e0cb10477bfcd16d3ac11467979f5561cb6199442b877ef SHA512 099857f1d295043587a4e2a65ef3e6a90e12c8b6958e98535a1656c113c553f9a9b621aba8a19cf21bd8d2c79d27cbfa4b8e6fabbcb3cbfee23b545be7b450b4 DIST rustc-1.47.0-src.tar.xz 104143736 BLAKE2B 0454094dde35275488046826da87655e51bf0795481d6d08fd70d644bfc12481bca8641166106ef32f20494906025244715b16ff21a1c023f4bd2818aab42521 SHA512 6ba83c0158f8130ddeae7e070417a2121d8a548c8fe97e28bce116d84048636c75aaee78e0c92cd43a50f5679a1223fc226cc8c5ba9bbd1465e84c5c6034d5c9 DIST rustc-1.48.0-src.tar.xz 105951736 BLAKE2B 42468fc5ac5e80c4793cfe0913cbb8e43a8def28cc8cf5ed25ab989561e2bf33e155c83e180183362535cbc9008f341eb1273087a2364672b1a4032ac2d6ca45 SHA512 4e12baa6893238a8d336ec9ebe891477d18676f271b32763474fa7a6a8b58fb3187dd4e2aa95bce482989b692cc2e1360221669d6811eec71b326f22a1756c23 DIST rustc-1.49.0-src.tar.xz 108330280 BLAKE2B 65e36253482ded2df225cbbf15253b6c9a8ae935053b071d9fb9e7b1d47d5d3ac47a138876e4a5cfeda455c655ac06ceff2658c8668cef7d2206116906740653 SHA512 fd8bc67ec0a73d3b6bf9c1fabb7ea981ef817644b4e6ced982fa90b12eae9b55de074634a670bdfb38bfee6588603e818ddcbcc2f2a05f83057c061b4194b4b7 +DIST rustc-1.50.0-src.tar.xz 108666272 BLAKE2B abb1b6f57093334bae5892dd99c964ffaf5e2b906cc92f0b92d5786cf80484cff923643169f24f4f92a5724c21b8bd671c72531c2cd1f6fbe0ea7107b5bd923b SHA512 df3c83c0fdc9ebce6fdccddda781dea0cdbd88d2b2a8220cac40cc3a8fa957923ae834d1fa45283d4ad227b334bd9e220e37a4a1ad7a1c7aeb806ed9ed387245 diff --git a/dev-lang/rust/rust-1.50.0.ebuild b/dev-lang/rust/rust-1.50.0.ebuild new file mode 100644 index 000000000000..e98848b6f30b --- /dev/null +++ b/dev-lang/rust/rust-1.50.0.ebuild @@ -0,0 +1,619 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{7..9} ) + +inherit bash-completion-r1 check-reqs estack flag-o-matic llvm multiprocessing multilib-build python-any-r1 rust-toolchain toolchain-funcs + +if [[ ${PV} = *beta* ]]; then + betaver=${PV//*beta} + BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}" + MY_P="rustc-beta" + SLOT="beta/${PV}" + SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz -> rustc-${PV}-src.tar.xz" +else + ABI_VER="$(ver_cut 1-2)" + SLOT="stable/${ABI_VER}" + MY_P="rustc-${PV}" + SRC="${MY_P}-src.tar.xz" + KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86" +fi + +RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0" + +DESCRIPTION="Systems programming language from Mozilla" +HOMEPAGE="https://www.rust-lang.org/" + +SRC_URI=" + https://static.rust-lang.org/dist/${SRC} + !system-bootstrap? ( $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION}) ) +" + +# keep in sync with llvm ebuild of the same version as bundled one. +ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430 + NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore ) +ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) +LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?} + +LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA" + +IUSE="clippy cpu_flags_x86_sse2 debug doc libressl miri nightly parallel-compiler rls rustfmt system-bootstrap system-llvm test wasm ${ALL_LLVM_TARGETS[*]}" + +# Please keep the LLVM dependency block separate. Since LLVM is slotted, +# we need to *really* make sure we're not pulling more than one slot +# simultaneously. + +# How to use it: +# 1. List all the working slots (with min versions) in ||, newest first. +# 2. Update the := to specify *max* version, e.g. < 12. +# 3. Specify LLVM_MAX_SLOT, e.g. 11. +LLVM_DEPEND=" + || ( + sys-devel/llvm:11[${LLVM_TARGET_USEDEPS// /,}] + ) + /dev/null) ) + rustc_version=${rustc_version[0]#rust-bin-} + rustc_version=${rustc_version#rust-} + + [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, check 'eselect rust' output" + + if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then + eerror "Rust >=${rustc_wanted} is required" + eerror "please run 'eselect rust' and set correct rust version" + die "selected rust version is too old" + elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then + eerror "Rust <${rustc_toonew} is required" + eerror "please run 'eselect rust' and set correct rust version" + die "selected rust version is too new" + else + einfo "Using rust ${rustc_version} to build" + fi +} + +pre_build_checks() { + local M=6144 + M=$(( $(usex clippy 128 0) + ${M} )) + M=$(( $(usex miri 128 0) + ${M} )) + M=$(( $(usex rls 512 0) + ${M} )) + M=$(( $(usex rustfmt 256 0) + ${M} )) + M=$(( $(usex system-llvm 0 2048) + ${M} )) + M=$(( $(usex wasm 256 0) + ${M} )) + M=$(( $(usex debug 15 10) * ${M} / 10 )) + eshopts_push -s extglob + if is-flagq '-g?(gdb)?([1-9])'; then + M=$(( 15 * ${M} / 10 )) + fi + eshopts_pop + M=$(( $(usex system-bootstrap 0 1024) + ${M} )) + M=$(( $(usex doc 256 0) + ${M} )) + CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE} +} + +pkg_pretend() { + pre_build_checks +} + +pkg_setup() { + pre_build_checks + python-any-r1_pkg_setup + + export LIBGIT2_NO_PKG_CONFIG=1 #749381 + + use system-bootstrap && boostrap_rust_version_check + + if use system-llvm; then + llvm_pkg_setup + + local llvm_config="$(get_llvm_prefix "$LLVM_MAX_SLOT")/bin/llvm-config" + export LLVM_LINK_SHARED=1 + export RUSTFLAGS="${RUSTFLAGS} -Lnative=$("${llvm_config}" --libdir)" + fi +} + +src_prepare() { + if ! use system-bootstrap; then + local rust_stage0_root="${WORKDIR}"/rust-stage0 + local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)" + + "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig \ + --destdir="${rust_stage0_root}" --prefix=/ || die + fi + + default +} + +src_configure() { + local rust_target="" rust_targets="" arch_cflags + + # Collect rust target names to compile standard libs for all ABIs. + for v in $(multilib_get_enabled_abi_pairs); do + rust_targets="${rust_targets},\"$(rust_abi $(get_abi_CHOST ${v##*.}))\"" + done + if use wasm; then + rust_targets="${rust_targets},\"wasm32-unknown-unknown\"" + if use system-llvm; then + # un-hardcode rust-lld linker for this target + # https://bugs.gentoo.org/715348 + sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/wasm32_base.rs || die + fi + fi + rust_targets="${rust_targets#,}" + + local tools="\"cargo\"," + if use clippy; then + tools="\"clippy\",$tools" + fi + if use miri; then + tools="\"miri\",$tools" + fi + if use rls; then + tools="\"rls\",\"analysis\",\"src\",$tools" + fi + if use rustfmt; then + tools="\"rustfmt\",$tools" + fi + + local rust_stage0_root + if use system-bootstrap; then + rust_stage0_root="$(rustc --print sysroot)" + else + rust_stage0_root="${WORKDIR}"/rust-stage0 + fi + + rust_target="$(rust_abi)" + + cat <<- _EOF_ > "${S}"/config.toml + [llvm] + optimize = $(toml_usex !debug) + release-debuginfo = $(toml_usex debug) + assertions = $(toml_usex debug) + ninja = true + targets = "${LLVM_TARGETS// /;}" + experimental-targets = "" + link-shared = $(toml_usex system-llvm) + [build] + build = "${rust_target}" + host = ["${rust_target}"] + target = [${rust_targets}] + cargo = "${rust_stage0_root}/bin/cargo" + rustc = "${rust_stage0_root}/bin/rustc" + docs = $(toml_usex doc) + compiler-docs = $(toml_usex doc) + submodules = false + python = "${EPYTHON}" + locked-deps = true + vendor = true + extended = true + tools = [${tools}] + verbose = 2 + sanitizers = false + profiler = false + cargo-native-static = false + [install] + prefix = "${EPREFIX}/usr/lib/${PN}/${PV}" + sysconfdir = "etc" + docdir = "share/doc/rust" + bindir = "bin" + libdir = "lib" + mandir = "share/man" + [rust] + # https://github.com/rust-lang/rust/issues/54872 + codegen-units-std = 1 + optimize = true + debug = $(toml_usex debug) + debug-assertions = $(toml_usex debug) + debuginfo-level-rustc = 0 + backtrace = true + incremental = false + default-linker = "$(tc-getCC)" + parallel-compiler = $(toml_usex parallel-compiler) + channel = "$(usex nightly nightly stable)" + rpath = false + verbose-tests = true + optimize-tests = $(toml_usex !debug) + codegen-tests = true + dist-src = false + remap-debuginfo = true + lld = $(usex system-llvm false $(toml_usex wasm)) + backtrace-on-ice = true + jemalloc = false + [dist] + src-tarball = false + _EOF_ + + for v in $(multilib_get_enabled_abi_pairs); do + rust_target=$(rust_abi $(get_abi_CHOST ${v##*.})) + arch_cflags="$(get_abi_CFLAGS ${v##*.})" + + cat <<- _EOF_ >> "${S}"/config.env + CFLAGS_${rust_target}=${arch_cflags} + _EOF_ + + cat <<- _EOF_ >> "${S}"/config.toml + [target.${rust_target}] + cc = "$(tc-getBUILD_CC)" + cxx = "$(tc-getBUILD_CXX)" + linker = "$(tc-getCC)" + ar = "$(tc-getAR)" + _EOF_ + # librustc_target/spec/linux_musl_base.rs sets base.crt_static_default = true; + if use elibc_musl; then + cat <<- _EOF_ >> "${S}"/config.toml + crt-static = false + _EOF_ + fi + if use system-llvm; then + cat <<- _EOF_ >> "${S}"/config.toml + llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config" + _EOF_ + fi + done + if use wasm; then + cat <<- _EOF_ >> "${S}"/config.toml + [target.wasm32-unknown-unknown] + linker = "$(usex system-llvm lld rust-lld)" + _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 + # extracts first element form :: + local cross_llvm_target="${cross_target_spec%%:*}" + # extracts toolchain triples, : + local cross_triples="${cross_target_spec#*:}" + # extracts first element after before : separator + local cross_rust_target="${cross_triples%%:*}" + # extracts last element after : separator + 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 + + # append cross target to "normal" target list + # example 'target = ["powerpc64le-unknown-linux-gnu"]' + # becomes 'target = ["powerpc64le-unknown-linux-gnu","aarch64-unknown-linux-gnu"]' + + rust_targets="${rust_targets},\"${cross_rust_target}\"" + sed -i "/^target = \[/ s#\[.*\]#\[${rust_targets}\]#" config.toml || die + + ewarn + ewarn "Enabled ${cross_rust_target} rust target" + ewarn "Using ${cross_toolchain} cross toolchain" + ewarn + if ! has_version -b 'sys-devel/binutils[multitarget]' ; then + ewarn "'sys-devel/binutils[multitarget]' is not installed" + ewarn "'strip' will be unable to strip cross libraries" + ewarn "cross targets will be installed with full debug information" + ewarn "enable 'multitarget' USE flag for binutils to be able to strip object files" + ewarn + ewarn "Alternatively llvm-strip can be used, it supports stripping any target" + ewarn "define STRIP=\"llvm-strip\" to use it (experimental)" + ewarn + fi + done + fi # I_KNOW_WHAT_I_AM_DOING_CROSS + + einfo "Rust configured with the following settings:" + cat "${S}"/config.toml || die +} + +src_compile() { + # we need \n IFS to have config.env with spaces loaded properly. #734018 + ( + IFS=$'\n' + env $(cat "${S}"/config.env) RUST_BACKTRACE=1\ + "${EPYTHON}" ./x.py dist -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die + ) +} + +src_test() { + # https://rustc-dev-guide.rust-lang.org/tests/intro.html + + # those are basic and codegen tests. + local tests=( + codegen + codegen-units + compile-fail + incremental + mir-opt + pretty + run-make + ) + + # fails if llvm is not built with ALL targets. + # and known to fail with system llvm sometimes. + use system-llvm || tests+=( assembly ) + + # fragile/expensive/less important tests + # or tests that require extra builds + # TODO: instead of skipping, just make some nonfatal. + if [[ ${ERUST_RUN_EXTRA_TESTS:-no} != no ]]; then + tests+=( + rustdoc + rustdoc-js + rustdoc-js-std + rustdoc-ui + run-make-fulldeps + ui + ui-fulldeps + ) + fi + + local i failed=() + einfo "rust_src_test: enabled tests ${tests[@]/#/src/test/}" + for i in "${tests[@]}"; do + local t="src/test/${i}" + einfo "rust_src_test: running ${t}" + if ! ( + IFS=$'\n' + env $(cat "${S}"/config.env) RUST_BACKTRACE=1 \ + "${EPYTHON}" ./x.py test -vv --config="${S}"/config.toml \ + -j$(makeopts_jobs) --no-doc --no-fail-fast "${t}" + ) + then + failed+=( "${t}" ) + eerror "rust_src_test: ${t} failed" + fi + done + + if [[ ${#failed[@]} -ne 0 ]]; then + eerror "rust_src_test: failure summary: ${failed[@]}" + die "aborting due to test failures" + fi +} + +src_install() { + # https://github.com/rust-lang/rust/issues/77721 + # also 1.46.0-don-t-create-prefix-at-time-of-check.patch + dodir "/usr/lib/${PN}/${PV}" + ( + IFS=$'\n' + env $(cat "${S}"/config.env) DESTDIR="${D}" \ + "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml || die + ) + + # bug #689562, #689160 + rm -v "${ED}/usr/lib/${PN}/${PV}/etc/bash_completion.d/cargo" || die + rmdir -v "${ED}/usr/lib/${PN}/${PV}"/etc{/bash_completion.d,} || die + newbashcomp src/tools/cargo/src/etc/cargo.bashcomp.sh cargo + + local symlinks=( + cargo + rustc + rustdoc + rust-gdb + rust-gdbgui + rust-lldb + ) + + use clippy && symlinks+=( clippy-driver cargo-clippy ) + use miri && symlinks+=( miri cargo-miri ) + use rls && symlinks+=( rls ) + use rustfmt && symlinks+=( rustfmt cargo-fmt ) + + einfo "installing eselect-rust symlinks and paths: ${symlinks[@]}" + local i + for i in "${symlinks[@]}"; do + # we need realpath on /usr/bin/* symlink return version-appended binary path. + # so /usr/bin/rustc should point to /usr/lib/rust//bin/rustc- + # need to fix eselect-rust to remove this hack. + local ver_i="${i}-${PV}" + if [[ -f "${ED}/usr/lib/${PN}/${PV}/bin/${i}" ]]; then + einfo "Installing ${i} symlink" + ln -v "${ED}/usr/lib/${PN}/${PV}/bin/${i}" "${ED}/usr/lib/${PN}/${PV}/bin/${ver_i}" || die + else + ewarn "${i} symlink requested, but source file not found" + ewarn "please report this" + fi + dosym "../lib/${PN}/${PV}/bin/${ver_i}" "/usr/bin/${ver_i}" + done + + # symlinks to switch components to active rust in eselect + dosym "${PV}/lib" "/usr/lib/${PN}/lib-${PV}" + dosym "${PV}/libexec" "/usr/lib/${PN}/libexec-${PV}" + dosym "${PV}/share/man" "/usr/lib/${PN}/man-${PV}" + dosym "rust/${PV}/lib/rustlib" "/usr/lib/rustlib-${PV}" + dosym "../../lib/${PN}/${PV}/share/doc/rust" "/usr/share/doc/${P}" + + newenvd - "50${P}" <<-_EOF_ + LDPATH="${EPREFIX}/usr/lib/rust/lib" + MANPATH="${EPREFIX}/usr/lib/rust/man" + $(use amd64 && usex elibc_musl 'CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=-crt-static"' '') + $(use arm64 && usex elibc_musl 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=-crt-static"' '') + _EOF_ + + rm -rf "${ED}/usr/lib/${PN}/${PV}"/*.old || die + rm -rf "${ED}/usr/lib/${PN}/${PV}/doc"/*.old || die + + # note: eselect-rust adds EROOT to all paths below + cat <<-_EOF_ > "${T}/provider-${P}" + /usr/bin/cargo + /usr/bin/rustdoc + /usr/bin/rust-gdb + /usr/bin/rust-gdbgui + /usr/bin/rust-lldb + /usr/lib/rustlib + /usr/lib/rust/lib + /usr/lib/rust/libexec + /usr/lib/rust/man + /usr/share/doc/rust + _EOF_ + + if use clippy; then + echo /usr/bin/clippy-driver >> "${T}/provider-${P}" + echo /usr/bin/cargo-clippy >> "${T}/provider-${P}" + fi + if use miri; then + echo /usr/bin/miri >> "${T}/provider-${P}" + echo /usr/bin/cargo-miri >> "${T}/provider-${P}" + fi + if use rls; then + echo /usr/bin/rls >> "${T}/provider-${P}" + fi + if use rustfmt; then + echo /usr/bin/rustfmt >> "${T}/provider-${P}" + echo /usr/bin/cargo-fmt >> "${T}/provider-${P}" + fi + + insinto /etc/env.d/rust + doins "${T}/provider-${P}" +} + +pkg_postinst() { + eselect rust update + + if has_version sys-devel/gdb || has_version dev-util/lldb; then + elog "Rust installs a helper script for calling GDB and LLDB," + elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}." + fi + + if has_version app-editors/emacs; then + elog "install app-emacs/rust-mode to get emacs support for rust." + fi + + if has_version app-editors/gvim || has_version app-editors/vim; then + elog "install app-vim/rust-vim to get vim support for rust." + fi +} + +pkg_postrm() { + eselect rust cleanup +} -- cgit v1.2.3-65-gdbad