The Rust 1.47 release includes full support for the riscv64gc-unknown-linux-gnu target, including upstream shipping a binary compiler. Gentoo uses upstream's lack of a binary compiler as the reason to not enable Rust support for certain architectures, but since this no longer applies to riscv, can it start being implemented in the profile and elsewhere? That would open the door to keywording Rust-based packages. My assumption of what will be required for Gentoo-approved support is to add llvm_targets_RISCV entries for package.use.force and unmask Rust-specific USE flags in the riscv profile, which requires keywording virtual/rust and its dependencies for ~riscv, which requires adding bootstrap binaries for dev-lang/rust. (So far I've only tested rust-bin by adding ~riscv to virtual/rust, dev-lang/rust-bin, and app-eselect/eselect-rust; I haven't compiled everything natively yet.) Here is the eclass change to set up bootstrap binaries. (It should also probably be conditional on abi_riscv_lp64d since the G implies D, but the multilib profiles changed recently, so I left it nonspecific.) --- eclass/rust-toolchain.eclass +++ eclass/rust-toolchain.eclass @@ -48,6 +48,7 @@ mipsel*) echo mipsel-unknown-linux-gnu;; mips*) echo mips-unknown-linux-gnu;; powerpc*) echo powerpc-unknown-linux-gnu;; + riscv64*) echo riscv64gc-unknown-linux-gnu;; s390x*) echo s390x-unknown-linux-gnu;; *) echo ${CTARGET};; esac @@ -116,6 +117,8 @@ uris+="ppc? ( $(rust_arch_uri powerpc-unknown-linux-gnu "$@") ) " uris+="ppc64? ( $(rust_arch_uri powerpc64-unknown-linux-gnu "$@") $(rust_arch_uri powerpc64le-unknown-linux-gnu "$@") ) " + [[ $EAPI != 6 ]] && ver_test "${1#rust-}" -ge 1.47 && + uris+="riscv? ( $(rust_arch_uri riscv64gc-unknown-linux-gnu "$@") ) " uris+="s390? ( $(rust_arch_uri s390x-unknown-linux-gnu "$@") ) " uris+="abi_x86_32? ( $(rust_arch_uri i686-unknown-linux-gnu "$@") ) " echo "${uris}"
In favour of it, but I need to get up to speed with insane RISCV abi variety. looks like dilfridge did some changes to RISCV recently, need his input on what stays and what goes away. can you provide some insight about all the abis it has? it may need match by abi flag not by keyword (like it's done for amd64) btw, rust-toolchain.eclass triple matching is horrible, it needs more flexible matcher in the spirit of tc-ninja_magic_to_arch() from toolchain-funcs.eclass, but even more flexible. possibly connected to rustc --print target-list in case it's installed. or just hardcode values from there and update every once in a while. ^ is not a prerequisite to add riscv, just general rant.
OK so basically we dropped multilib support recently, and all supported profiles are single-abi... (there's an exp profile with full multilib left, but that is only for my own internal purposes and cannot be considered fully functional. just enough for stage building.) we have 2 profiles right now: riscv64/lp64d ( -march=rv64gc -mabi=lp64d ) riscv64/lp64 ( -march=rv64gc -mabi=lp64 ) we will likely have 2 additional profiles in the future: riscv32/ilp32d ( -march=rv32imafdc -mabi=ilp32d ) riscv32/ilp32 ( -march=rv32imac -mabi=ilp32 ) I suspect the upstream rust binary is for riscv64/lp64d. And yes the detailed matching is complicated.
thanks. my concern right know is that it will be similar arm subprofile problem, where we have single arm keyword and have to mask rust-dependent things on every damn low arch sub-arch profile. if rust somehow managed to ship dist tarball means llvm will need riscv keywords for system-llvm flag or I can just mask it for now. I don't have any kind of real risvc equipment and my best guess that native rust compilation will take good week in qemu =)
Since RUST_STAGE0_VERSION points at the previous version and Rust 1.48 was just released, this should be possible to implement now with no special casing for the bootstrap version.
*** Bug 779619 has been marked as a duplicate of this bug. ***
rust upstream only provide riscv64/lp64d tier2 support for 64bit port[0]: riscv64gc-unknown-linux-gnu check code here [1], which effectively means no 'riscv64/lp64' support for now for the profile side # grep -Rn CHOST_ profiles/arch/riscv/make.defaults 22:CHOST_lp64d="riscv64-unknown-linux-gnu" 28:CHOST_lp64="riscv64-unknown-linux-gnu" 34:CHOST_ilp32d="riscv32-unknown-linux-gnu" 40:CHOST_ilp32="riscv32-unknown-linux-gnu" currently, rust_abi() from rust-toolchain.eclass can't distinguish lp64 from lp64d, we might have to fix.. current status: rust should work only for riscv64/lp64d 1) riscv64/lp64: lack rust upstream support 2) riscv32/ilp32, riscv32/ilp32d: upstream isn't even ready for now the patches from David in comment#c0 should work, yes? [0] https://doc.rust-lang.org/nightly/rustc/platform-support.html [1] https://github.com/rust-lang/rust/blob/master/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs
Created attachment 696909 [details] fail build log with rust-1.50.0 this is my initial venture with rust-1.50.0, got segment fault (signal 11) .. == part of related error message: == sysroot: "/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1" libdir: "/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1/lib" rustc exited with signal: 11 Did not run successfully: signal: 11 error: could not compile `compiler_builtins` Caused by: process didn't exit successfully: `/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/bootstrap/debug/rustc --crate-n ame compiler_builtins /var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/vendor/compiler_builtins/src/lib.rs --error-format=j son --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C cod egen-units=10000 -C debuginfo=0 --cfg 'feature="c"' --cfg 'feature="cc"' --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' -- cfg 'feature="default"' --cfg 'feature="rustc-dep-of-std"' -C metadata=52a87332b2b8b4bb -C extra-filename=-52a87332b2b8b4bb --out-dir /var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1-std/riscv64gc-unknown-linux-gnu/r elease/deps --target riscv64gc-unknown-linux-gnu -C linker=riscv64-unknown-linux-gnu-gcc -L dependency=/var/tmp/portage/dev-lang/rust- 1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1-std/riscv64gc-unknown-linux-gnu/release/deps -L dependency=/var/ tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1-std/release/deps --extern core=/var/tm p/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1-std/riscv64gc-unknown-linux-gnu/release/ deps/librustc_std_workspace_core-6fe80048b31c08a9.rmeta --cap-lints allow -Zmacro-backtrace -Zsave-analysis -Cprefer-dynamic -Cembed-b itcode=yes -Cforce-unwind-tables=yes -Z binary-dep-depinfo --cfg 'feature="unstable"'` (exit code: 254) warning:"/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1/bin/rustc" "--crate-name " "compiler_builtins" "/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/vendor/compiler_builtins/src/lib.rs" "--error-forma t=json" "--json=diagnostic-rendered-ansi,artifacts" "--crate-type" "lib" "--emit=dep-info,metadata,link" "-C" "opt-level=3" "-C" "embe d-bitcode=no" "-C" "codegen-units=10000" "-C" "debuginfo=0" "--cfg" "feature=\"c\"" "--cfg" "feature=\"cc\"" "--cfg" "feature=\"compil er-builtins\"" "--cfg" "feature=\"core\"" "--cfg" "feature=\"default\"" "--cfg" "feature=\"rustc-dep-of-std\"" "-C" "metadata=52a87332 b2b8b4bb" "-C" "extra-filename=-52a87332b2b8b4bb" "--out-dir" "/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv 64gc-unknown-linux-gnu/stage1-std/riscv64gc-unknown-linux-gnu/release/deps" "--target" "riscv64gc-unknown-linux-gnu" "-C" "linker=risc v64-unknown-linux-gnu-gcc" "-L" "dependency=/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1-std/riscv64gc-unknown-linux-gnu/release/deps" "-L" "dependency=/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1-std/release/deps" "--extern" "core=/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1-std/riscv64gc-unknown-linux-gnu/release/deps/librustc_std_workspace_core-6fe80048b31c08a9.rmeta" "--cap-lints" "allow" "-Zmacro-backtrace" "-Zsave-analysis" "-Cprefer-dynamic" "-Cembed-bitcode=yes" "-Cforce-unwind-tables=yes" "-Z" "binary-dep-depinfo" "--cfg" "feature=\"unstable\"" "-Wrust_2018_idioms" "-Wunused_lifetimes" "-Dwarnings" "--sysroot" "/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src/build/riscv64gc-unknown-linux-gnu/stage1" "-C" "panic=abort" "--remap-path-prefix" "/var/tmp/portage/dev-lang/rust-1.50.0/work/rustc-1.50.0-src=/rustc/1.50.0" "-Z" "force-unstable-if-unmarked" build failed, waiting for other jobs to finish... ------------- rustc exited with signal: 11
Created attachment 698247 [details] full build log for rust-1.51.0
Created attachment 707076 [details, diff] rust eclass patch
(In reply to Yixun Lan from comment #9) > Created attachment 707076 [details, diff] [details, diff] > rust eclass patch
ping @rust @riscv I'd like to push rust support for riscv64/lp64d for now, I don't think we should wait for riscv32 or other ABIs.. because that would take much longer time (may depend on upstream) getting riscv64/lp64d support is actually a progress
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3f480fff7a274860e6a44611c53a23569ba9976f commit 3f480fff7a274860e6a44611c53a23569ba9976f Author: Yixun Lan <dlan@gentoo.org> AuthorDate: 2021-05-11 14:08:38 +0000 Commit: Yixun Lan <dlan@gentoo.org> CommitDate: 2021-05-13 15:06:41 +0000 dev-lang/rust: add riscv support Bug: https://bugs.gentoo.org/747460 Package-Manager: Portage-3.0.18, Repoman-3.0.3 Signed-off-by: Yixun Lan <dlan@gentoo.org> dev-lang/rust/Manifest | 4 ++++ dev-lang/rust/rust-1.51.0-r2.ebuild | 2 +- dev-lang/rust/rust-1.52.1.ebuild | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d71f2fa85b4d6c65bc30e8cd88e7973de05070c1 commit d71f2fa85b4d6c65bc30e8cd88e7973de05070c1 Author: Yixun Lan <dlan@gentoo.org> AuthorDate: 2021-05-11 13:59:22 +0000 Commit: Yixun Lan <dlan@gentoo.org> CommitDate: 2021-05-13 15:06:31 +0000 rust: enable support for ARCH=riscv, only for riscv64/lp64d Bug: https://bugs.gentoo.org/747460 Signed-off-by: Yixun Lan <dlan@gentoo.org> eclass/rust-toolchain.eclass | 2 ++ 1 file changed, 2 insertions(+)
Gentoo has Rust support for riscv now.