Add riscv64 specific changes

This commit is contained in:
jchzhou 2023-04-24 23:20:27 +08:00
parent d87c460314
commit ffe664f147
2 changed files with 58 additions and 2 deletions

View File

@ -0,0 +1,25 @@
From a216df759724049385b729f038de2cb49c580cd2 Mon Sep 17 00:00:00 2001
From: jchzhou <zhoujiacheng@iscas.ac.cn>
Date: Wed, 8 Mar 2023 00:10:42 +0800
Subject: [PATCH] add musl-root-riscv64gc detection in configure.py
---
src/bootstrap/configure.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index 6b139decb..55855f8a1 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -140,6 +140,8 @@ v("musl-root-mips64", "target.mips64-unknown-linux-muslabi64.musl-root",
"mips64-unknown-linux-muslabi64 install directory")
v("musl-root-mips64el", "target.mips64el-unknown-linux-muslabi64.musl-root",
"mips64el-unknown-linux-muslabi64 install directory")
+v("musl-root-riscv64gc", "target.riscv64gc-unknown-linux-musl.musl-root",
+ "riscv64gc-unknown-linux-musl install directory")
v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
"rootfs in qemu testing, you probably don't want to use this")
v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
--
2.39.2

View File

@ -8,9 +8,13 @@
%bcond_with disabled_libssh2 %bcond_with disabled_libssh2
%bcond_without curl_http2 %bcond_without curl_http2
%bcond_without lldb %bcond_without lldb
%ifnarch riscv64
%bcond_without analyzer
%endif
Name: rust Name: rust
Version: 1.69.0 Version: 1.69.0
Release: 1 Release: 2
Summary: The Rust Programming Language Summary: The Rust Programming Language
License: (ASL 2.0 or MIT) and (BSD and MIT) License: (ASL 2.0 or MIT) and (BSD and MIT)
URL: https://www.rust-lang.org URL: https://www.rust-lang.org
@ -26,6 +30,7 @@ Patch0005: compile-with-llvm-15.patch
Patch0006: 0001-Use-lld-provided-by-system-for-wasm.patch Patch0006: 0001-Use-lld-provided-by-system-for-wasm.patch
# Set a substitute-path in rust-gdb for standard library sources. # Set a substitute-path in rust-gdb for standard library sources.
Patch0007: rustc-1.61.0-rust-gdb-substitute-path.patch Patch0007: rustc-1.61.0-rust-gdb-substitute-path.patch
Patch0008: 0001-add-musl-root-riscv64gc-detection-in-configure.py.patch
%{lua: function rust_triple(arch) %{lua: function rust_triple(arch)
local abi = "gnu" local abi = "gnu"
@ -43,9 +48,15 @@ Patch0007: rustc-1.61.0-rust-gdb-substitute-path.patch
end} end}
%{lua: function rust_musl_triple(arch) %{lua: function rust_musl_triple(arch)
local abi = "musl" local abi = "musl"
if arch == "riscv64" then
arch = "riscv64gc"
end
return arch.."-unknown-linux-"..abi return arch.."-unknown-linux-"..abi
end} end}
%{lua: function rust_musl_root(arch) %{lua: function rust_musl_root(arch)
if arch == "riscv64" then
arch = "riscv64gc"
end
return "--musl-root-"..arch return "--musl-root-"..arch
end} end}
%global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))} %global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))}
@ -90,7 +101,12 @@ BuildRequires: cmake >= 2.8.11
%if %defined llvm %if %defined llvm
%global llvm_root %{_libdir}/%{llvm} %global llvm_root %{_libdir}/%{llvm}
%else %else
# default llvm is decent enough on riscv64
%ifnarch riscv64
%global llvm llvm15 %global llvm llvm15
%else
%global llvm llvm
%endif
%global llvm_root %{_prefix} %global llvm_root %{_prefix}
%endif %endif
# rust currently requires llvm 14.0+ # rust currently requires llvm 14.0+
@ -181,6 +197,7 @@ Conflicts: rustfmt-preview < 1.0.0
%description -n rustfmt %description -n rustfmt
A tool for formatting Rust code according to style guidelines. A tool for formatting Rust code according to style guidelines.
%if %{with analyzer}
%package analyzer %package analyzer
Summary:Rust implementation of the Language Server Protocol Summary:Rust implementation of the Language Server Protocol
Requires: %{name}-src Requires: %{name}-src
@ -193,6 +210,7 @@ Obsoletes: rls-preview < 1.31.6
rust-analyzer is an implementation of Language Server Protocol for the Rust rust-analyzer is an implementation of Language Server Protocol for the Rust
programming language. It provides features like completion and goto definition programming language. It provides features like completion and goto definition
for many code editors, including VS Code, Emacs and Vim. for many code editors, including VS Code, Emacs and Vim.
%endif
%package -n clippy %package -n clippy
Summary: Lints to catch common mistakes and improve your Rust code Summary: Lints to catch common mistakes and improve your Rust code
@ -241,9 +259,13 @@ sed -i.try-python -e '/^try python3 /i try "%{python}" "$@"' ./configure
%patch0002 -p1 %patch0002 -p1
%patch0003 -p1 %patch0003 -p1
%patch0004 -p1 %patch0004 -p1
# default llvm is decent enough on riscv64
%ifnarch riscv64
%patch0005 -p1 %patch0005 -p1
%endif
%patch0006 -p1 %patch0006 -p1
%patch0007 -p1 %patch0007 -p1
%patch0008 -p1
rm -rf vendor/curl-sys/curl/ rm -rf vendor/curl-sys/curl/
rm -rf vendor/jemalloc-sys/jemalloc/ rm -rf vendor/jemalloc-sys/jemalloc/
rm -rf vendor/libssh2-sys/libssh2/ rm -rf vendor/libssh2-sys/libssh2/
@ -305,7 +327,7 @@ fi
--disable-rpath \ --disable-rpath \
%{enable_debuginfo} \ %{enable_debuginfo} \
--enable-extended \ --enable-extended \
--tools=cargo,clippy,rls,rust-analyzer,rustfmt,src \ --tools=cargo,clippy,%{?with_analyzer:rls,rust-analyzer,}rustfmt,src \
--enable-vendor \ --enable-vendor \
--enable-verbose-tests \ --enable-verbose-tests \
%{?codegen_units_std} \ %{?codegen_units_std} \
@ -348,8 +370,10 @@ mkdir -p %{buildroot}%{_datadir}/cargo/registry
mkdir -p %{buildroot}%{_docdir}/cargo mkdir -p %{buildroot}%{_docdir}/cargo
ln -sT ../rust/html/cargo/ %{buildroot}%{_docdir}/cargo/html ln -sT ../rust/html/cargo/ %{buildroot}%{_docdir}/cargo/html
%if %{with analyzer}
# The rls stub doesn't have an install target, but we can just copy it. # The rls stub doesn't have an install target, but we can just copy it.
%{__install} -t %{buildroot}%{_bindir} build/%{rust_triple}/stage2-tools-bin/rls %{__install} -t %{buildroot}%{_bindir} build/%{rust_triple}/stage2-tools-bin/rls
%endif
%if %without lldb %if %without lldb
rm -f %{buildroot}%{_bindir}/rust-lldb rm -f %{buildroot}%{_bindir}/rust-lldb
@ -362,7 +386,9 @@ export %{rust_env}
%{python} ./x.py test --no-fail-fast --stage 2 || : %{python} ./x.py test --no-fail-fast --stage 2 || :
%{python} ./x.py test --no-fail-fast --stage 2 cargo || : %{python} ./x.py test --no-fail-fast --stage 2 cargo || :
%{python} ./x.py test --no-fail-fast --stage 2 clippy || : %{python} ./x.py test --no-fail-fast --stage 2 clippy || :
%if %{with analyzer}
%{python} ./x.py test --no-fail-fast --stage 2 rust-analyzer || : %{python} ./x.py test --no-fail-fast --stage 2 rust-analyzer || :
%endif
%{python} ./x.py test --no-fail-fast --stage 2 rustfmt || : %{python} ./x.py test --no-fail-fast --stage 2 rustfmt || :
%ldconfig_scriptlets %ldconfig_scriptlets
@ -425,11 +451,13 @@ export %{rust_env}
%doc src/tools/rustfmt/{README,CHANGELOG,Configurations}.md %doc src/tools/rustfmt/{README,CHANGELOG,Configurations}.md
%license src/tools/rustfmt/LICENSE-{APACHE,MIT} %license src/tools/rustfmt/LICENSE-{APACHE,MIT}
%if %{with analyzer}
%files analyzer %files analyzer
%{_bindir}/rls %{_bindir}/rls
%{_bindir}/rust-analyzer %{_bindir}/rust-analyzer
%doc src/tools/rust-analyzer/README.md %doc src/tools/rust-analyzer/README.md
%license src/tools/rust-analyzer/LICENSE-{APACHE,MIT} %license src/tools/rust-analyzer/LICENSE-{APACHE,MIT}
%endif
%files -n clippy %files -n clippy
%{_bindir}/cargo-clippy %{_bindir}/cargo-clippy
@ -453,6 +481,9 @@ export %{rust_env}
%{_mandir}/man1/cargo*.1* %{_mandir}/man1/cargo*.1*
%changelog %changelog
* Mon Apr 24 2023 jchzhou <zhoujiacheng@iscas.ac.cn> - 1.69.0-2
- Add riscv64 specific changes
* Mon Apr 24 2023 jchzhou <zhoujiacheng@iscas.ac.cn> - 1.69.0-1 * Mon Apr 24 2023 jchzhou <zhoujiacheng@iscas.ac.cn> - 1.69.0-1
- Update to 1.69.0 - Update to 1.69.0
- Obsolete the removed rust-analysis subpackage - Obsolete the removed rust-analysis subpackage