summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgy Yakovlev <gyakovlev@gentoo.org>2020-06-11 15:12:30 -0700
committerGeorgy Yakovlev <gyakovlev@gentoo.org>2020-06-11 17:30:49 -0700
commit0326022d60e80c438d0ea90f489eebb722320417 (patch)
treeeedcff7135a2e5c46769b7986c72505e76d6257a /dev-lang
parentapp-emulation/wine-staging: Sync with ::sync (diff)
downloadgentoo-0326022d60e80c438d0ea90f489eebb722320417.tar.gz
gentoo-0326022d60e80c438d0ea90f489eebb722320417.tar.bz2
gentoo-0326022d60e80c438d0ea90f489eebb722320417.zip
dev-lang/rust: add experimental cross support to 1.44.0
Brief usage how-to in the ebuild Bug: https://bugs.gentoo.org/680652 Bug: https://bugs.gentoo.org/680652 Package-Manager: Portage-2.3.100, Repoman-2.3.22 Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Diffstat (limited to 'dev-lang')
-rw-r--r--dev-lang/rust/rust-1.44.0.ebuild57
1 files changed, 57 insertions, 0 deletions
diff --git a/dev-lang/rust/rust-1.44.0.ebuild b/dev-lang/rust/rust-1.44.0.ebuild
index 5deb73a5022e..1a6fdeabca6f 100644
--- a/dev-lang/rust/rust-1.44.0.ebuild
+++ b/dev-lang/rust/rust-1.44.0.ebuild
@@ -295,6 +295,63 @@ 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/<target>
+
+ # extra targets defined as a bash array
+ # spec format: <LLVM target>:<rust-target>:<CTARGET>
+ # 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
+ local cross_llvm_target="${cross_target_spec%%:*}"
+ local cross_triples="${cross_target_spec#*:}"
+ local cross_rust_target="${cross_triples#*:}"
+ 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
+
+ rust_targets="${rust_targets},\"${cross_rust_target}\""
+ sed -i "/^target = \[/ s#\[.*\]#\[${rust_targets}\]#" config.toml || die
+ ewarn
+ ewarn "enabled ${rust_target} rust target, using ${cross_toolchain} cross toolchain"
+ ewarn
+ done
+ fi # I_KNOW_WHAT_I_AM_DOING_CROSS
+
einfo "Rust configured with the following settings:"
cat "${S}"/config.toml || die
}