5 |
|
|
6 |
# Only x86_64 and i686 are Tier 1 platforms at this time. |
# Only x86_64 and i686 are Tier 1 platforms at this time. |
7 |
# https://doc.rust-lang.org/nightly/rustc/platform-support.html |
# https://doc.rust-lang.org/nightly/rustc/platform-support.html |
8 |
%global rust_arches x86_64 %ix86 armv7hl aarch64 ppc64 ppc64le s390x |
%global rust_arches x86_64 %ix86 armv7hl aarch64 ppc64le s390x |
9 |
|
|
10 |
# The channel can be stable, beta, or nightly |
# The channel can be stable, beta, or nightly |
11 |
%{!?channel: %global channel stable} |
%{!?channel: %global channel stable} |
14 |
# e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24 |
# e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24 |
15 |
# or nightly wants some beta-YYYY-MM-DD |
# or nightly wants some beta-YYYY-MM-DD |
16 |
# Note that cargo matches the program version here, not its crate version. |
# Note that cargo matches the program version here, not its crate version. |
17 |
%global bootstrap_rust 1.55.0 |
%global bootstrap_rust 1.56.1 |
18 |
%global bootstrap_cargo 1.55.0 |
%global bootstrap_cargo 1.56.1 |
19 |
%global bootstrap_channel 1.55.0 |
%global bootstrap_channel 1.56.1 |
20 |
%global bootstrap_date 2021-09-09 |
%global bootstrap_date 2021-11-01 |
21 |
|
|
22 |
# Only the specified arches will use bootstrap binaries. |
# Only the specified arches will use bootstrap binaries. |
23 |
#global bootstrap_arches %%{rust_arches} |
#global bootstrap_arches %%{rust_arches} |
38 |
# reproducible between hosts, so only x86_64 actually builds it. |
# reproducible between hosts, so only x86_64 actually builds it. |
39 |
%ifarch x86_64 |
%ifarch x86_64 |
40 |
%if 0%{?fedora} || 0%{?mageia} |
%if 0%{?fedora} || 0%{?mageia} |
41 |
%global cross_targets wasm32-unknown-unknown |
%global cross_targets wasm32-unknown-unknown wasm32-wasi |
42 |
%endif |
%endif |
43 |
%endif |
%endif |
44 |
|
|
45 |
|
# We need CRT files for *-wasi targets, at least as new as the commit in |
46 |
|
# src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh |
47 |
|
%global forgeurl1 https://github.com/WebAssembly/wasi-libc |
48 |
|
%global commit1 ad5133410f66b93a2381db5b542aad5e0964db96 |
49 |
|
%forgemeta -z 1 |
50 |
|
%undefine distprefix1 |
51 |
|
%global wasi_libc_source %{forgesource1} |
52 |
|
%global wasi_libc_dir %{_builddir}/%{extractdir1} |
53 |
|
|
54 |
# Using llvm-static may be helpful as an opt-in, e.g. to aid LLVM rebases. |
# Using llvm-static may be helpful as an opt-in, e.g. to aid LLVM rebases. |
55 |
%bcond_with llvm_static |
%bcond_with llvm_static |
56 |
|
|
65 |
#%%global optflags %%(echo %%{optflags} | sed 's/-g /-g1 /') |
#%%global optflags %%(echo %%{optflags} | sed 's/-g /-g1 /') |
66 |
#%%endif |
#%%endif |
67 |
|
|
68 |
# Requires stable libgit2 1.1 |
# Requires stable libgit2 1.3 |
69 |
%if 0%{?fedora} >= 34 || 0%{?mageia} >= 8 |
# (akien) TODO: enable for mga9 once packaged. |
70 |
|
%if 0%{?fedora} >= 36 |
71 |
%bcond_with bundled_libgit2 |
%bcond_with bundled_libgit2 |
72 |
%else |
%else |
73 |
%bcond_without bundled_libgit2 |
%bcond_without bundled_libgit2 |
99 |
%endif |
%endif |
100 |
|
|
101 |
Name: rust |
Name: rust |
102 |
Version: 1.56.1 |
Version: 1.57.0 |
103 |
Release: %mkrel 1 |
Release: %mkrel 1 |
104 |
Summary: The Rust Programming Language |
Summary: The Rust Programming Language |
105 |
%if 0%{?mageia} |
%if 0%{?mageia} |
116 |
%global rustc_package rustc-%{channel}-src |
%global rustc_package rustc-%{channel}-src |
117 |
%endif |
%endif |
118 |
Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz |
Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz |
119 |
|
Source1: %{wasi_libc_source} |
120 |
|
# Sources for bootstrap_arches are inserted by lua below |
121 |
|
|
122 |
# An internal rust-abi change broke s390x, but it's fixed in LLVM 12.0.1. |
# Fix a bad typecast for LLVM globals, rhbz#1990657 |
123 |
# We'll revert the change on Fedora 33 that has an unpatched LLVM 11. |
# https://github.com/rust-lang/rust/pull/91070 |
124 |
# https://github.com/rust-lang/rust/issues/80810#issuecomment-781784032 |
Patch1: rust-pr91070.patch |
|
Patch1: 0001-Revert-Auto-merge-of-79547.patch |
|
125 |
|
|
126 |
# By default, rust tries to use "rust-lld" as a linker for WebAssembly. |
# By default, rust tries to use "rust-lld" as a linker for WebAssembly. |
127 |
Patch2: 0001-Use-lld-provided-by-system-for-wasm.patch |
Patch2: 0001-Use-lld-provided-by-system-for-wasm.patch |
137 |
|
|
138 |
# libcurl on RHEL7 doesn't have http2, but since cargo requests it, curl-sys |
# libcurl on RHEL7 doesn't have http2, but since cargo requests it, curl-sys |
139 |
# will try to build it statically -- instead we turn off the feature. |
# will try to build it statically -- instead we turn off the feature. |
140 |
Patch101: rustc-1.56.0-disable-http2.patch |
Patch101: rustc-1.57.0-disable-http2.patch |
141 |
|
|
142 |
# kernel rh1410097 causes too-small stacks for PIE. |
# kernel rh1410097 causes too-small stacks for PIE. |
143 |
# (affects RHEL6 kernels when building for RHEL7) |
# (affects RHEL6 kernels when building for RHEL7) |
144 |
Patch102: rustc-1.51.0-no-default-pie.patch |
Patch102: rustc-1.57.0-no-default-pie.patch |
145 |
|
|
146 |
|
|
147 |
# Get the Rust triple for any arch. |
# Get the Rust triple for any arch. |
180 |
.."/rust-%{bootstrap_channel}") |
.."/rust-%{bootstrap_channel}") |
181 |
local target_arch = rpm.expand("%{_target_cpu}") |
local target_arch = rpm.expand("%{_target_cpu}") |
182 |
for i, arch in ipairs(bootstrap_arches) do |
for i, arch in ipairs(bootstrap_arches) do |
183 |
|
i = 100 + i |
184 |
print(string.format("Source%d: %s-%s.tar.xz\n", |
print(string.format("Source%d: %s-%s.tar.xz\n", |
185 |
i, base, rust_triple(arch))) |
i, base, rust_triple(arch))) |
186 |
if arch == target_arch then |
if arch == target_arch then |
217 |
BuildRequires: pkgconfig(openssl) |
BuildRequires: pkgconfig(openssl) |
218 |
BuildRequires: pkgconfig(zlib) |
BuildRequires: pkgconfig(zlib) |
219 |
|
|
220 |
%if %without bundled_libgit2 |
%if %{without bundled_libgit2} |
221 |
BuildRequires: pkgconfig(libgit2) >= 1.1.0 |
BuildRequires: pkgconfig(libgit2) >= 1.3.0 |
222 |
%endif |
%endif |
223 |
|
|
224 |
%if %{without disabled_libssh2} |
%if %{without disabled_libssh2} |
238 |
%if 0%{?epel} == 7 |
%if 0%{?epel} == 7 |
239 |
%global llvm llvm11 |
%global llvm llvm11 |
240 |
%endif |
%endif |
|
%if 0%{?fedora} == 35 |
|
|
# f35 still only has 13.0.0~rc1 |
|
|
%global llvm llvm12 |
|
|
%endif |
|
241 |
%if %defined llvm |
%if %defined llvm |
242 |
%global llvm_root %{_libdir}/%{llvm} |
%global llvm_root %{_libdir}/%{llvm} |
243 |
%else |
%else |
315 |
%global rustlibdir %{common_libdir}/rustlib |
%global rustlibdir %{common_libdir}/rustlib |
316 |
|
|
317 |
%if %defined cross_targets |
%if %defined cross_targets |
318 |
|
BuildRequires: clang |
319 |
# brp-strip-static-archive breaks the archive index for wasm |
# brp-strip-static-archive breaks the archive index for wasm |
320 |
%global __os_install_post \ |
%global __os_install_post \ |
321 |
%__os_install_post \ |
%__os_install_post \ |
340 |
%if %defined cross_targets |
%if %defined cross_targets |
341 |
%{lua: do |
%{lua: do |
342 |
for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do |
for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do |
|
local requires = rpm.expand("Requires: rust = %{version}-%{release}") |
|
|
if string.sub(triple, 1, 4) == "wasm" then |
|
|
requires = requires .. "\nRequires: lld >= 8.0" |
|
|
end |
|
343 |
local subs = { |
local subs = { |
344 |
triple = triple, |
triple = triple, |
345 |
requires = requires, |
verrel = rpm.expand("%{version}-%{release}"), |
346 |
|
wasm = string.sub(triple, 1, 4) == "wasm" and 1 or 0, |
347 |
|
wasi = string.find(triple, "-wasi") and 1 or 0, |
348 |
} |
} |
349 |
local s = string.gsub([[ |
local s = string.gsub([[ |
350 |
|
|
351 |
%package std-static-{{triple}} |
%package std-static-{{triple}} |
352 |
Summary: Standard library for Rust |
Summary: Standard library for Rust |
353 |
BuildArch: noarch |
BuildArch: noarch |
354 |
{{requires}} |
Requires: rust = {{verrel}} |
355 |
|
%if {{wasm}} |
356 |
|
Requires: lld >= 8.0 |
357 |
|
%endif |
358 |
|
%if {{wasi}} |
359 |
|
Provides: bundled(wasi-libc) |
360 |
|
%endif |
361 |
|
|
362 |
%description std-static-{{triple}} |
%description std-static-{{triple}} |
363 |
This package includes the standard libraries for building applications |
This package includes the standard libraries for building applications |
364 |
written in Rust for the {{triple}} target. |
written in Rust for the {{triple}} target. |
365 |
|
|
366 |
]], "{{(%w+)}}", subs) |
]], "{{(%w+)}}", subs) |
367 |
print(s) |
print(s) |
368 |
end |
end |
420 |
%package -n cargo |
%package -n cargo |
421 |
Summary: Rust's package manager and build tool |
Summary: Rust's package manager and build tool |
422 |
%if %with bundled_libgit2 |
%if %with bundled_libgit2 |
423 |
Provides: bundled(libgit2) = 1.1.0 |
Provides: bundled(libgit2) = 1.3.0 |
424 |
%endif |
%endif |
425 |
# For tests: |
# For tests: |
426 |
BuildRequires: git |
BuildRequires: git |
463 |
%package -n rls |
%package -n rls |
464 |
Summary: Rust Language Server for IDE integration |
Summary: Rust Language Server for IDE integration |
465 |
%if %with bundled_libgit2 |
%if %with bundled_libgit2 |
466 |
Provides: bundled(libgit2) = 1.1.0 |
Provides: bundled(libgit2) = 1.3.0 |
467 |
%endif |
%endif |
468 |
Requires: rust-analysis |
Requires: rust-analysis |
469 |
# /usr/bin/rls is dynamically linked against internal rustc libs |
# /usr/bin/rls is dynamically linked against internal rustc libs |
523 |
test -f '%{local_rust_root}/bin/rustc' |
test -f '%{local_rust_root}/bin/rustc' |
524 |
%endif |
%endif |
525 |
|
|
526 |
|
%if %defined cross_targets |
527 |
|
%forgesetup -z 1 |
528 |
|
%endif |
529 |
|
|
530 |
%setup -q -n %{rustc_package} |
%setup -q -n %{rustc_package} |
531 |
|
|
|
%if 0%{?fedora} == 33 |
|
|
# revert only for LLVM 11 |
|
532 |
%patch1 -p1 |
%patch1 -p1 |
|
%endif |
|
|
|
|
533 |
%patch2 -p1 |
%patch2 -p1 |
534 |
|
|
535 |
%patch11 -p1 |
%patch11 -p1 |
605 |
%if 0%{?cmake_path:1} |
%if 0%{?cmake_path:1} |
606 |
%global rust_env %{rust_env} PATH="%{cmake_path}:$PATH" |
%global rust_env %{rust_env} PATH="%{cmake_path}:$PATH" |
607 |
%endif |
%endif |
|
%if %without bundled_libgit2 |
|
|
# convince libgit2-sys to use the distro libgit2 |
|
|
%global rust_env %{rust_env} LIBGIT2_SYS_USE_PKG_CONFIG=1 |
|
|
%endif |
|
608 |
%if %without disabled_libssh2 |
%if %without disabled_libssh2 |
609 |
# convince libssh2-sys to use the distro libssh2 |
# convince libssh2-sys to use the distro libssh2 |
610 |
%global rust_env %{rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1 |
%global rust_env %{rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1 |
636 |
ncpus="$max_cpus" |
ncpus="$max_cpus" |
637 |
fi |
fi |
638 |
|
|
639 |
|
%if %defined cross_targets |
640 |
|
%make_build -C %{wasi_libc_dir} |
641 |
|
%{lua: do |
642 |
|
local wasi_root = rpm.expand("%{wasi_libc_dir}") .. "/sysroot" |
643 |
|
local set_wasi_root = "" |
644 |
|
for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do |
645 |
|
if string.find(triple, "-wasi") then |
646 |
|
set_wasi_root = set_wasi_root .. " --set target." .. triple .. ".wasi-root=" .. wasi_root |
647 |
|
end |
648 |
|
end |
649 |
|
if wasi_root ~= "" then |
650 |
|
rpm.define("set_wasi_root "..set_wasi_root) |
651 |
|
end |
652 |
|
end} |
653 |
|
%endif |
654 |
|
|
655 |
%configure --disable-option-checking \ |
%configure --disable-option-checking \ |
656 |
--libdir=%{common_libdir} \ |
--libdir=%{common_libdir} \ |
657 |
--build=%{rust_triple} --host=%{rust_triple} --target=%{target_triple} \ |
--build=%{rust_triple} --host=%{rust_triple} --target=%{target_triple} \ |
670 |
--tools=analysis,cargo,clippy,rls,rustfmt,src \ |
--tools=analysis,cargo,clippy,rls,rustfmt,src \ |
671 |
--enable-vendor \ |
--enable-vendor \ |
672 |
--enable-verbose-tests \ |
--enable-verbose-tests \ |
673 |
%{?codegen_units_std} \ |
%{?set_wasi_root} \ |
674 |
--dist-compression-formats=gz \ |
--dist-compression-formats=gz \ |
675 |
--release-channel=%{channel} \ |
--release-channel=%{channel} \ |
676 |
--release-description="%{?mageia:Mageia }%{?fedora:Fedora }%{?rhel:Red Hat }%{version}-%{release}" |
--release-description="%{?mageia:Mageia }%{?fedora:Fedora }%{?rhel:Red Hat }%{version}-%{release}" |
768 |
%check |
%check |
769 |
export %{rust_env} |
export %{rust_env} |
770 |
|
|
771 |
|
# Sanity-check the installed binaries, debuginfo-stripped and all. |
772 |
|
%{buildroot}%{_bindir}/cargo new build/hello-world |
773 |
|
env RUSTC=%{buildroot}%{_bindir}/rustc \ |
774 |
|
LD_LIBRARY_PATH="%{buildroot}%{_libdir}:$LD_LIBRARY_PATH" \ |
775 |
|
%{buildroot}%{_bindir}/cargo run --manifest-path build/hello-world/Cargo.toml |
776 |
|
|
777 |
# The results are not stable on koji, so mask errors and just log it. |
# The results are not stable on koji, so mask errors and just log it. |
778 |
# Some of the larger test artifacts are manually cleaned to save space. |
# Some of the larger test artifacts are manually cleaned to save space. |
779 |
%{python} ./x.py test --no-fail-fast --stage 2 || : |
%{python} ./x.py test --no-fail-fast --stage 2 || : |
830 |
local subs = { |
local subs = { |
831 |
triple = triple, |
triple = triple, |
832 |
rustlibdir = rpm.expand("%{rustlibdir}"), |
rustlibdir = rpm.expand("%{rustlibdir}"), |
833 |
|
wasi = string.find(triple, "-wasi") and 1 or 0, |
834 |
} |
} |
835 |
local s = string.gsub([[ |
local s = string.gsub([[ |
836 |
|
|
837 |
%files std-static-{{triple}} |
%files std-static-{{triple}} |
838 |
%dir {{rustlibdir}} |
%dir {{rustlibdir}} |
839 |
%dir {{rustlibdir}}/{{triple}} |
%dir {{rustlibdir}}/{{triple}} |
840 |
%dir {{rustlibdir}}/{{triple}}/lib |
%dir {{rustlibdir}}/{{triple}}/lib |
841 |
{{rustlibdir}}/{{triple}}/lib/*.rlib |
{{rustlibdir}}/{{triple}}/lib/*.rlib |
842 |
|
%if {{wasi}} |
843 |
|
%dir {{rustlibdir}}/{{triple}}/lib/self-contained |
844 |
|
{{rustlibdir}}/{{triple}}/lib/self-contained/crt*.o |
845 |
|
%endif |
846 |
|
|
847 |
]], "{{(%w+)}}", subs) |
]], "{{(%w+)}}", subs) |
848 |
print(s) |
print(s) |
849 |
end |
end |