!32 add support for musl target

From: @lijiajie128
Reviewed-by: @flyking001,@jingxiaolu
Signed-off-by: @jingxiaolu
This commit is contained in:
openeuler-ci-bot 2021-07-07 01:52:58 +00:00 committed by Gitee
commit 685b93d9a7

View File

@ -5,14 +5,14 @@
%global bootstrap_channel 1.50.0 %global bootstrap_channel 1.50.0
%global bootstrap_date 2021-02-11 %global bootstrap_date 2021-02-11
%bcond_with llvm_static %bcond_with llvm_static
%bcond_with bundled_llvm %bcond_without bundled_llvm
%bcond_without bundled_libgit2 %bcond_without bundled_libgit2
%bcond_with disabled_libssh2 %bcond_with disabled_libssh2
%bcond_without curl_http2 %bcond_without curl_http2
%bcond_without lldb %bcond_without lldb
Name: rust Name: rust
Version: 1.51.0 Version: 1.51.0
Release: 4 Release: 5
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
@ -52,7 +52,16 @@ Patch0012: fix-a-println-wrong-format.patch
end end
return arch.."-unknown-linux-"..abi return arch.."-unknown-linux-"..abi
end} end}
%{lua: function rust_musl_triple(arch)
local abi = "musl"
return arch.."-unknown-linux-"..abi
end}
%{lua: function rust_musl_root(arch)
return "--musl-root-"..arch
end}
%global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))} %global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))}
%global rust_musl_triple %{lua: print(rust_musl_triple(rpm.expand("%{_target_cpu}")))}
%global rust_musl_root %{lua: print(rust_musl_root(rpm.expand("%{_target_cpu}")))}
%if %defined bootstrap_arches %if %defined bootstrap_arches
%{lua: do %{lua: do
local bootstrap_arches = {} local bootstrap_arches = {}
@ -80,7 +89,7 @@ BuildRequires: cargo >= %{bootstrap_cargo}
BuildRequires: (%{name} >= %{bootstrap_rust} with %{name} <= %{version}) BuildRequires: (%{name} >= %{bootstrap_rust} with %{name} <= %{version})
%global local_rust_root %{_prefix} %global local_rust_root %{_prefix}
%endif %endif
BuildRequires: make gcc gcc-c++ ncurses-devel curl curl-devel pkgconfig(libcurl) pkgconfig(liblzma) BuildRequires: make gcc gcc-c++ ncurses-devel curl curl-devel musl-libc-static musl-gcc pkgconfig(libcurl) pkgconfig(liblzma)
BuildRequires: pkgconfig(openssl) pkgconfig(zlib) pkgconfig(libssh2) >= 1.6.0 BuildRequires: pkgconfig(openssl) pkgconfig(zlib) pkgconfig(libssh2) >= 1.6.0
%global python python3 %global python python3
BuildRequires: %{python} BuildRequires: %{python}
@ -117,6 +126,8 @@ Requires: /usr/bin/cc
%global llvm_has_filecheck 1 %global llvm_has_filecheck 1
%endif %endif
%endif %endif
%global musl_root %{_prefix}/musl
%description %description
Rust is a systems programming language that runs blazingly fast, prevents Rust is a systems programming language that runs blazingly fast, prevents
segfaults, and guarantees thread safety. segfaults, and guarantees thread safety.
@ -311,7 +322,8 @@ if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then
fi fi
%configure --disable-option-checking \ %configure --disable-option-checking \
--libdir=%{common_libdir} \ --libdir=%{common_libdir} \
--build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \ %{rust_musl_root}=%{musl_root} \
--build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple},%{rust_musl_triple} \
--python=%{python} \ --python=%{python} \
--local-rust-root=%{local_rust_root} \ --local-rust-root=%{local_rust_root} \
%{!?with_bundled_llvm: --llvm-root=%{llvm_root} \ %{!?with_bundled_llvm: --llvm-root=%{llvm_root} \
@ -388,12 +400,18 @@ export %{rust_env}
%dir %{rustlibdir}/%{rust_triple} %dir %{rustlibdir}/%{rust_triple}
%dir %{rustlibdir}/%{rust_triple}/lib %dir %{rustlibdir}/%{rust_triple}/lib
%{rustlibdir}/%{rust_triple}/lib/*.so %{rustlibdir}/%{rust_triple}/lib/*.so
%dir %{rustlibdir}/%{rust_musl_triple}
%dir %{rustlibdir}/%{rust_musl_triple}/lib
%files std-static %files std-static
%dir %{rustlibdir} %dir %{rustlibdir}
%dir %{rustlibdir}/%{rust_triple} %dir %{rustlibdir}/%{rust_triple}
%dir %{rustlibdir}/%{rust_triple}/lib %dir %{rustlibdir}/%{rust_triple}/lib
%{rustlibdir}/%{rust_triple}/lib/*.rlib %{rustlibdir}/%{rust_triple}/lib/*.rlib
%dir %{rustlibdir}/%{rust_musl_triple}
%dir %{rustlibdir}/%{rust_musl_triple}/lib
%{rustlibdir}/%{rust_musl_triple}/lib/*.rlib
%{rustlibdir}/%{rust_musl_triple}/lib/self-contained/*.o
%files debugger-common %files debugger-common
%dir %{rustlibdir} %dir %{rustlibdir}
@ -444,6 +462,7 @@ export %{rust_env}
%files analysis %files analysis
%{rustlibdir}/%{rust_triple}/analysis/ %{rustlibdir}/%{rust_triple}/analysis/
%{rustlibdir}/%{rust_musl_triple}/analysis/
%files help %files help
%dir %{_docdir}/%{name} %dir %{_docdir}/%{name}
@ -465,6 +484,9 @@ export %{rust_env}
%{_mandir}/man1/cargo*.1* %{_mandir}/man1/cargo*.1*
%changelog %changelog
* Thu 01 Jul 2021 Jiajie Li <lijiajie11@huawei.com> - 1.51.0-5
- Add support for musl target
* Thu 24 Jun 2021 sunguoshuai <sunguoshuai@huawei.com> - 1.51.0-4 * Thu 24 Jun 2021 sunguoshuai <sunguoshuai@huawei.com> - 1.51.0-4
- fix a println wrong format - fix a println wrong format