From cc2208c51917e8e0ce9104f5d79a3100fc504dd4 Mon Sep 17 00:00:00 2001 From: o01eg Date: Mon, 31 Aug 2020 22:06:38 +0300 Subject: Update dev-lang/rust-9999 and virtual/rust-9999 Closes: https://github.com/gentoo/gentoo-rust/pull/501 Signed-off-by: Mikhail Pukhlikov --- dev-lang/rust/files/1.43.1-fix-libdir.patch | 70 ---------- dev-lang/rust/rust-9999.ebuild | 191 +++++++++++++++++++++------- 2 files changed, 146 insertions(+), 115 deletions(-) delete mode 100644 dev-lang/rust/files/1.43.1-fix-libdir.patch (limited to 'dev-lang') diff --git a/dev-lang/rust/files/1.43.1-fix-libdir.patch b/dev-lang/rust/files/1.43.1-fix-libdir.patch deleted file mode 100644 index e1dccf3..0000000 --- a/dev-lang/rust/files/1.43.1-fix-libdir.patch +++ /dev/null @@ -1,70 +0,0 @@ -diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs -index eb0199fd020..c33657549ba 100644 ---- a/src/bootstrap/builder.rs -+++ b/src/bootstrap/builder.rs -@@ -646,6 +646,7 @@ impl<'a> Builder<'a> { - pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path { - match self.config.libdir_relative() { - Some(relative_libdir) if compiler.stage >= 1 => relative_libdir, -+ _ if compiler.stage == 0 => &self.build.initial_libdir, - _ => Path::new("lib"), - } - } -diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs -index a476d25f102..7fe4496ca45 100644 ---- a/src/bootstrap/lib.rs -+++ b/src/bootstrap/lib.rs -@@ -242,6 +242,7 @@ pub struct Build { - initial_rustc: PathBuf, - initial_cargo: PathBuf, - initial_lld: PathBuf, -+ initial_libdir: PathBuf, - - // Runtime state filled in later on - // C/C++ compilers and archiver for all targets -@@ -343,18 +344,38 @@ impl Build { - // we always try to use git for LLVM builds - let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project")); - -- let initial_sysroot = config.initial_rustc.parent().unwrap().parent().unwrap(); -- let initial_lld = initial_sysroot -- .join("lib") -- .join("rustlib") -- .join(config.build) -- .join("bin") -- .join("rust-lld"); -+ let initial_target_libdir_str = output( -+ Command::new(&config.initial_rustc) -+ .arg("--target") -+ .arg(config.build) -+ .arg("--print") -+ .arg("target-libdir"), -+ ); -+ let initial_target_dir = Path::new(&initial_target_libdir_str).parent().unwrap(); -+ let initial_lld = initial_target_dir.join("bin").join("rust-lld"); -+ -+ let initial_sysroot = output( -+ Command::new(&config.initial_rustc) -+ .arg("--print") -+ .arg("sysroot"), -+ ); -+ println!("stage0 sysroot: {}", initial_sysroot); -+ let initial_libdir_full = initial_target_dir -+ .parent() -+ .unwrap() -+ .parent() -+ .unwrap(); -+ println!("stage0 libdir: {}", initial_libdir_full.display()); -+ let initial_libdir = initial_libdir_full -+ .strip_prefix(initial_sysroot.trim()) -+ .unwrap() -+ .to_path_buf(); - - let mut build = Build { - initial_rustc: config.initial_rustc.clone(), - initial_cargo: config.initial_cargo.clone(), - initial_lld, -+ initial_libdir, - local_rebuild: config.local_rebuild, - fail_fast: config.cmd.fail_fast(), - doc_tests: config.cmd.doc_tests(), diff --git a/dev-lang/rust/rust-9999.ebuild b/dev-lang/rust/rust-9999.ebuild index b96c023..ab98c35 100644 --- a/dev-lang/rust/rust-9999.ebuild +++ b/dev-lang/rust/rust-9999.ebuild @@ -50,12 +50,24 @@ LLVM_DEPEND=" " LLVM_MAX_SLOT=10 -# libgit2 should be at least same as bungled into libgit-sys #707746 -COMMON_DEPEND=" +BDEPEND="${PYTHON_DEPS} + app-eselect/eselect-rust + || ( + >=sys-devel/gcc-4.7 + >=sys-devel/clang-3.5 + ) + !system-llvm? ( + dev-util/cmake + dev-util/ninja + ) +" + +# libgit2 should be at least same as bundled into libgit-sys #707746 +DEPEND=" >=dev-libs/libgit2-0.99:= net-libs/libssh2:= net-libs/http-parser:= - net-misc/curl:=[ssl] + net-misc/curl:=[http2,ssl] sys-libs/zlib:= !libressl? ( dev-libs/openssl:0= ) libressl? ( dev-libs/libressl:0= ) @@ -65,20 +77,8 @@ COMMON_DEPEND=" ) " -DEPEND="${COMMON_DEPEND} - ${PYTHON_DEPS} - || ( - >=sys-devel/gcc-4.7 - >=sys-devel/clang-3.5 - ) - !system-llvm? ( - dev-util/cmake - dev-util/ninja - ) -" - -RDEPEND="${COMMON_DEPEND} - >=app-eselect/eselect-rust-20190311 +RDEPEND="${DEPEND} + app-eselect/eselect-rust " REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} ) @@ -87,22 +87,25 @@ REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} ) ?? ( system-llvm sanitize ) " +# we don't use cmake.eclass, but can get a warnin -l +CMAKE_WARN_UNUSED_CLI=no + QA_FLAGS_IGNORED=" usr/bin/.*-${PV} - usr/lib.*/lib.*.so - usr/lib.*/${P}/rustlib/.*/codegen-backends/librustc_codegen_llvm-llvm.so - usr/lib.*/${P}/rustlib/.*/lib/lib.*.so + usr/lib.*/${P}/lib.*.so.* + usr/lib.*/${P}/rustlib/.*/bin/.* + usr/lib.*/${P}/rustlib/.*/lib/lib.*.so.* +" + +QA_SONAME=" + usr/lib.*/${P}/lib.*.so.* + usr/lib.*/${P}/rustlib/.*/lib/lib.*.so.* " # tests need a bit more work, currently they are causing multiple # re-compilations and somewhat fragile. RESTRICT="test network-sandbox" -QA_SONAME="usr/lib.*/librustc_macros.*.so" - -PATCHES=( - "${FILESDIR}"/1.43.1-fix-libdir.patch -) S="${WORKDIR}/${MY_P}-src" @@ -111,13 +114,21 @@ toml_usex() { } pre_build_checks() { - CHECKREQS_DISK_BUILD="9G" + 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 - CHECKREQS_DISK_BUILD="15G" + M=$(( 15 * ${M} / 10 )) fi eshopts_pop - check-reqs_pkg_setup + M=$(( $(usex doc 256 0) + ${M} )) + CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE} } pkg_pretend() { @@ -167,6 +178,11 @@ src_configure() { 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/' src/librustc_target/spec/wasm32_base.rs || die + fi fi rust_targets="${rust_targets#,}" @@ -184,8 +200,6 @@ src_configure() { tools="\"rustfmt\",$tools" fi - local rust_stage0_root="${WORKDIR}"/rust-stage0 - rust_target="$(rust_abi)" cat <<- EOF > "${S}"/config.toml @@ -274,6 +288,83 @@ src_configure() { EOF fi + if [[ -n ${I_KNOW_WHAT_I_AM_DOING_CROSS} ]]; then #whitespace intentionally shifted below + # experimental cross support + # discussion: https://bugs.gentoo.org/679878 + # TODO: c*flags, clang, system-llvm, cargo.eclass target support + # it would be much better if we could split out stdlib + # complilation to separate ebuild and abuse CATEGORY to + # just install to /usr/lib/rustlib/ + + # extra targets defined as a bash array + # spec format: :: + # best place would be /etc/portage/env/dev-lang/rust + # Example: + # RUST_CROSS_TARGETS=( + # "AArch64:aarch64-unknown-linux-gnu:aarch64-unknown-linux-gnu" + # ) + # no extra hand holding is done, no target transformations, all + # values are passed as-is with just basic checks, so it's up to user to supply correct values + # valid rust targets can be obtained with + # rustc --print target-list + # matching cross toolchain has to be installed + # matching LLVM_TARGET has to be enabled for both rust and llvm (if using system one) + # only gcc toolchains installed with crossdev are checked for now. + + # BUG: we can't pass host flags to cross compiler, so just filter for now + # BUG: this should be more fine-grained. + filter-flags '-mcpu=*' '-march=*' '-mtune=*' + + local cross_target_spec + for cross_target_spec in "${RUST_CROSS_TARGETS[@]}";do + # 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 } @@ -300,8 +391,6 @@ src_test() { } src_install() { - local rust_target abi_libdir - env $(cat "${S}"/config.env) DESTDIR="${D}" \ "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die @@ -311,8 +400,8 @@ src_install() { dobashcomp build/tmp/dist/cargo-image/etc/bash_completion.d/cargo # fix collision with stable rust #675026 - rmdir "${ED}"/usr/share/bash-completion/completions/cargo || die - rmdir "${ED}"/usr/share/zsh/site-functions/_cargo || die + rm "${ED}"/usr/share/bash-completion/completions/cargo || die + rm "${ED}"/usr/share/zsh/site-functions/_cargo || die mv "${ED}/usr/bin/rustc" "${ED}/usr/bin/rustc-${PV}" || die mv "${ED}/usr/bin/rustdoc" "${ED}/usr/bin/rustdoc-${PV}" || die @@ -336,22 +425,34 @@ src_install() { mv "${ED}/usr/bin/cargo-fmt" "${ED}/usr/bin/cargo-fmt-${PV}" || die fi + # Copy shared library versions of standard libraries for all targets + # into the system's abi-dependent lib directories because the rust + # installer only does so for the native ABI. + + local abi_libdir rust_target + for v in $(multilib_get_enabled_abi_pairs); do + if [ ${v##*.} = ${DEFAULT_ABI} ]; then + continue + fi + abi_libdir=$(get_abi_LIBDIR ${v##*.}) + rust_target=$(rust_abi $(get_abi_CHOST ${v##*.})) + mkdir -p "${ED}/usr/${abi_libdir}/${P}" + cp "${ED}/usr/$(get_libdir)/${P}/rustlib/${rust_target}/lib"/*.so \ + "${ED}/usr/${abi_libdir}/${P}" || die + done + + # versioned libdir/mandir support + newenvd - "50${P}" <<-_EOF_ + LDPATH="${EPREFIX}/usr/$(get_libdir)/${P}" + MANPATH="${EPREFIX}/usr/share/${P}/man" + _EOF_ + dodoc COPYRIGHT + rm -rf "${ED}/usr/$(get_libdir)/${P}"/*.old || die rm "${ED}/usr/share/doc/${P}"/*.old || die rm "${ED}/usr/share/doc/${P}/LICENSE-APACHE" || die rm "${ED}/usr/share/doc/${P}/LICENSE-MIT" || die - cat <<-EOF > "${T}"/50${P} - LDPATH="${EPREFIX}/usr/$(get_libdir)/${P}" - MANPATH="${EPREFIX}/usr/share/${P}/man" - EOF - if use rls; then - cat <<-EOF >> "${T}"/50${P} - RUST_SRC_PATH="${EPREFIX}/usr/lib/${P}/rustlib/src/rust/src/" - EOF - fi - doenvd "${T}"/50${P} - # note: eselect-rust adds EROOT to all paths below cat <<-EOF > "${T}/provider-${P}" /usr/bin/cargo -- cgit v1.2.3-65-gdbad