diff options
Diffstat (limited to 'dev-lang/rust/rust-1.74.1.ebuild')
-rw-r--r-- | dev-lang/rust/rust-1.74.1.ebuild | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/dev-lang/rust/rust-1.74.1.ebuild b/dev-lang/rust/rust-1.74.1.ebuild index 956ce4016716..b37b1fd78ff5 100644 --- a/dev-lang/rust/rust-1.74.1.ebuild +++ b/dev-lang/rust/rust-1.74.1.ebuild @@ -163,6 +163,7 @@ RESTRICT="test" VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/rust.asc PATCHES=( + "${FILESDIR}"/1.74.1-cross-compile-libz.patch #"${FILESDIR}"/1.72.0-bump-libc-deps-to-0.2.146.patch # pending refresh "${FILESDIR}"/1.70.0-ignore-broken-and-non-applicable-tests.patch "${FILESDIR}"/1.62.1-musl-dynamic-linking.patch @@ -184,7 +185,7 @@ bootstrap_rust_version_check() { [[ ${MERGE_TYPE} == binary ]] && return local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))" local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))" - local rustc_version=( $(eselect --brief rust show 2>/dev/null) ) + local rustc_version=( $(eselect --brief --root="${BROOT}" rust show 2>/dev/null) ) rustc_version=${rustc_version[0]#rust-bin-} rustc_version=${rustc_version#rust-} @@ -256,6 +257,18 @@ pkg_setup() { python-any-r1_pkg_setup export LIBGIT2_NO_PKG_CONFIG=1 #749381 + if tc-is-cross-compiler; then + export PKG_CONFIG_ALLOW_CROSS=1 + export PKG_CONFIG_PATH="${ROOT}/usr/$(get_libdir)/pkgconfig" + export OPENSSL_INCLUDE_DIR="${ROOT}/usr/include" + export OPENSSL_LIB_DIR="${ROOT}/usr/$(get_libdir)" + + use system-bootstrap || die "USE=system-bootstrap is required when cross-compiling" + use system-llvm && die "USE=system-llvm not allowed when cross-compiling" + local cross_llvm_target="$(llvm_tuple_to_target "${CBUILD}")" + use "llvm_targets_${cross_llvm_target}" || \ + die "Must enable LLVM_TARGETS=${cross_llvm_target} matching CBUILD=${CBUILD} when cross-compiling" + fi use system-bootstrap && bootstrap_rust_version_check @@ -298,7 +311,7 @@ src_prepare() { if ! use system-bootstrap; then has_version sys-devel/gcc || esetup_unwind_hack local rust_stage0_root="${WORKDIR}"/rust-stage0 - local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)" + local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi "${CBUILD}")" "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig \ --without=rust-docs-json-preview,rust-docs --destdir="${rust_stage0_root}" --prefix=/ || die @@ -347,6 +360,8 @@ src_configure() { [[ -d ${rust_stage0_root} ]] || die "${rust_stage0_root} is not a directory" rust_target="$(rust_abi)" + rust_build="$(rust_abi "${CBUILD}")" + rust_host="$(rust_abi "${CHOST}")" local cm_btype="$(usex debug DEBUG RELEASE)" cat <<- _EOF_ > "${S}"/config.toml @@ -378,17 +393,24 @@ src_configure() { enable-warnings = false [llvm.build-config] CMAKE_VERBOSE_MAKEFILE = "ON" - CMAKE_C_FLAGS_${cm_btype} = "${CFLAGS}" - CMAKE_CXX_FLAGS_${cm_btype} = "${CXXFLAGS}" - CMAKE_EXE_LINKER_FLAGS_${cm_btype} = "${LDFLAGS}" - CMAKE_MODULE_LINKER_FLAGS_${cm_btype} = "${LDFLAGS}" - CMAKE_SHARED_LINKER_FLAGS_${cm_btype} = "${LDFLAGS}" - CMAKE_STATIC_LINKER_FLAGS_${cm_btype} = "${ARFLAGS}" + $(if ! tc-is-cross-compiler; then + # When cross-compiling, LLVM is compiled twice, once for host and + # once for target. Unfortunately, this build configuration applies + # to both, which means any flags applicable to one target but not + # the other will break. Conditionally disable respecting user + # flags when cross-compiling. + echo "CMAKE_C_FLAGS_${cm_btype} = \"${CFLAGS}\"" + echo "CMAKE_CXX_FLAGS_${cm_btype} = \"${CXXFLAGS}\"" + echo "CMAKE_EXE_LINKER_FLAGS_${cm_btype} = \"${LDFLAGS}\"" + echo "CMAKE_MODULE_LINKER_FLAGS_${cm_btype} = \"${LDFLAGS}\"" + echo "CMAKE_SHARED_LINKER_FLAGS_${cm_btype} = \"${LDFLAGS}\"" + echo "CMAKE_STATIC_LINKER_FLAGS_${cm_btype} = \"${ARFLAGS}\"" + fi) [build] build-stage = 2 test-stage = 2 - build = "${rust_target}" - host = ["${rust_target}"] + build = "${rust_build}" + host = ["${rust_host}"] target = [${rust_targets}] cargo = "${rust_stage0_root}/bin/cargo" rustc = "${rust_stage0_root}/bin/rustc" @@ -426,7 +448,9 @@ src_configure() { debuginfo-level-tests = 0 backtrace = true incremental = false - default-linker = "$(tc-getCC)" + $(if ! tc-is-cross-compiler; then + echo "default-linker = \"$(tc-getCC)\"" + fi) parallel-compiler = $(toml_usex parallel-compiler) channel = "$(usex nightly nightly stable)" description = "gentoo" |