1 |
# (akien) This package is synced with Fedora / Josh Stone's spec. |
2 |
# The aim is to work with them on a rust packaging policy we could share, |
3 |
# so that we can ensure a good packaging and share the workload. |
4 |
|
5 |
|
6 |
# Only x86_64 and i686 are Tier 1 platforms at this time. |
7 |
# https://doc.rust-lang.org/nightly/rustc/platform-support.html |
8 |
%global rust_arches x86_64 %ix86 armv7hl aarch64 ppc64 ppc64le s390x |
9 |
|
10 |
# The channel can be stable, beta, or nightly |
11 |
%{!?channel: %global channel stable} |
12 |
|
13 |
# To bootstrap from scratch, set the channel and date from src/stage0.txt |
14 |
# e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24 |
15 |
# or nightly wants some beta-YYYY-MM-DD |
16 |
# Note that cargo matches the program version here, not its crate version. |
17 |
%global bootstrap_rust 1.54.0 |
18 |
%global bootstrap_cargo 1.54.0 |
19 |
%global bootstrap_channel 1.54.0 |
20 |
%global bootstrap_date 2021-07-29 |
21 |
|
22 |
# Only the specified arches will use bootstrap binaries. |
23 |
#global bootstrap_arches %%{rust_arches} |
24 |
|
25 |
# To bootstrap a compiler for a Tier 2 platform, we first need to build a |
26 |
# compiler for a Tier 1 platform that targets the Tier 2 platform, then use |
27 |
# the resulting compiler in a second build. Set bootstrap_build_arch to the |
28 |
# Tier 1 arch for the first build, leave it undefined for the second build. |
29 |
%bcond_with bootstrap_i586 |
30 |
%if %with bootstrap_i586 |
31 |
%ifarch i586 |
32 |
%global bootstrap_build_arch i686 |
33 |
%endif |
34 |
%endif |
35 |
|
36 |
# Define a space-separated list of targets to ship rust-std-static-$triple for |
37 |
# cross-compilation. The packages are noarch, but they're not fully |
38 |
# reproducible between hosts, so only x86_64 actually builds it. |
39 |
%ifarch x86_64 |
40 |
%if 0%{?fedora} || 0%{?mageia} |
41 |
%global cross_targets wasm32-unknown-unknown |
42 |
%endif |
43 |
%endif |
44 |
|
45 |
# Using llvm-static may be helpful as an opt-in, e.g. to aid LLVM rebases. |
46 |
%bcond_with llvm_static |
47 |
|
48 |
# We can also choose to just use Rust's bundled LLVM, in case the system LLVM |
49 |
# is insufficient. Rust currently requires LLVM 10.0+. |
50 |
%bcond_with bundled_llvm |
51 |
# (akien) Hacks below are needed on mga's buildsystem when we have to rebootstrap llvm. |
52 |
## Bundled LLVM has underlinking issues: |
53 |
#%%global _disable_ld_no_undefined 1 |
54 |
#%%ifarch %%{arm} %%ix86 |
55 |
## Decrease debuginfo verbosity to reduce memory consumption during final library linking |
56 |
#%%global optflags %%(echo %%{optflags} | sed 's/-g /-g1 /') |
57 |
#%%endif |
58 |
|
59 |
# Requires stable libgit2 1.1 |
60 |
%if 0%{?fedora} >= 34 || 0%{?mageia} >= 8 |
61 |
%bcond_with bundled_libgit2 |
62 |
%else |
63 |
%bcond_without bundled_libgit2 |
64 |
%endif |
65 |
|
66 |
%if 0%{?rhel} |
67 |
# Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949) |
68 |
%bcond_without disabled_libssh2 |
69 |
%else |
70 |
%bcond_with disabled_libssh2 |
71 |
%endif |
72 |
|
73 |
%if 0%{?rhel} && 0%{?rhel} < 8 |
74 |
%bcond_with curl_http2 |
75 |
%else |
76 |
%bcond_without curl_http2 |
77 |
%endif |
78 |
|
79 |
# LLDB isn't available everywhere... |
80 |
%if 0%{?rhel} && 0%{?rhel} < 8 |
81 |
%bcond_with lldb |
82 |
%else |
83 |
%bcond_without lldb |
84 |
%endif |
85 |
|
86 |
%if 0%{?mageia} |
87 |
# (akien) Added by tv in mga8/rust 1.37.0. |
88 |
%global _python_bytecompile_extra 0 |
89 |
%endif |
90 |
|
91 |
Name: rust |
92 |
Version: 1.55.0 |
93 |
Release: %mkrel 1 |
94 |
Summary: The Rust Programming Language |
95 |
%if 0%{?mageia} |
96 |
Group: Development/Other |
97 |
%endif |
98 |
License: (ASL 2.0 or MIT) and (BSD and MIT) |
99 |
# ^ written as: (rust itself) and (bundled libraries) |
100 |
URL: https://www.rust-lang.org |
101 |
ExclusiveArch: %{rust_arches} |
102 |
|
103 |
%if "%{channel}" == "stable" |
104 |
%global rustc_package rustc-%{version}-src |
105 |
%else |
106 |
%global rustc_package rustc-%{channel}-src |
107 |
%endif |
108 |
Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz |
109 |
|
110 |
# This internal rust-abi change broke s390x -- revert for now. |
111 |
# https://github.com/rust-lang/rust/issues/80810#issuecomment-781784032 |
112 |
Patch1: 0001-Revert-Auto-merge-of-79547.patch |
113 |
|
114 |
# By default, rust tries to use "rust-lld" as a linker for WebAssembly. |
115 |
Patch2: 0001-Use-lld-provided-by-system-for-wasm.patch |
116 |
|
117 |
# (akien) Those tests fail on armv7 - on Fedora too, and jistone ignores them |
118 |
# https://github.com/rust-lang/rust/issues/83453 |
119 |
Patch11: rustc-1.50.0-allow_fail-armv7-instruction_set.patch |
120 |
|
121 |
### RHEL-specific patches below ### |
122 |
|
123 |
# Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949) |
124 |
Patch100: rustc-1.48.0-disable-libssh2.patch |
125 |
|
126 |
# libcurl on RHEL7 doesn't have http2, but since cargo requests it, curl-sys |
127 |
# will try to build it statically -- instead we turn off the feature. |
128 |
Patch101: rustc-1.55.0-disable-http2.patch |
129 |
|
130 |
# kernel rh1410097 causes too-small stacks for PIE. |
131 |
# (affects RHEL6 kernels when building for RHEL7) |
132 |
Patch102: rustc-1.51.0-no-default-pie.patch |
133 |
|
134 |
|
135 |
# Get the Rust triple for any arch. |
136 |
%{lua: function rust_triple(arch) |
137 |
local abi = "gnu" |
138 |
if arch == "armv7hl" then |
139 |
arch = "armv7" |
140 |
abi = "gnueabihf" |
141 |
elseif arch == "ppc64" then |
142 |
arch = "powerpc64" |
143 |
elseif arch == "ppc64le" then |
144 |
arch = "powerpc64le" |
145 |
elseif arch == "riscv64" then |
146 |
arch = "riscv64gc" |
147 |
end |
148 |
return arch.."-unknown-linux-"..abi |
149 |
end} |
150 |
|
151 |
%if %defined bootstrap_build_arch |
152 |
%global rust_triple %{lua: print(rust_triple(rpm.expand("%{bootstrap_build_arch}")))} |
153 |
%global target_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))} |
154 |
%else |
155 |
%global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))} |
156 |
%global target_triple %{rust_triple} |
157 |
%endif |
158 |
|
159 |
%if %defined bootstrap_arches |
160 |
# For each bootstrap arch, add an additional binary Source. |
161 |
# Also define bootstrap_source just for the current target. |
162 |
%{lua: do |
163 |
local bootstrap_arches = {} |
164 |
for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do |
165 |
table.insert(bootstrap_arches, arch) |
166 |
end |
167 |
local base = rpm.expand("https://static.rust-lang.org/dist/%{bootstrap_date}" |
168 |
.."/rust-%{bootstrap_channel}") |
169 |
local target_arch = rpm.expand("%{_target_cpu}") |
170 |
for i, arch in ipairs(bootstrap_arches) do |
171 |
print(string.format("Source%d: %s-%s.tar.xz\n", |
172 |
i, base, rust_triple(arch))) |
173 |
if arch == target_arch then |
174 |
rpm.define("bootstrap_source "..i) |
175 |
end |
176 |
end |
177 |
end} |
178 |
%endif |
179 |
|
180 |
%ifarch %{bootstrap_arches} |
181 |
%global bootstrap_root rust-%{bootstrap_channel}-%{rust_triple} |
182 |
%global local_rust_root %{_builddir}/%{bootstrap_root}/usr |
183 |
Provides: bundled(%{name}-bootstrap) = %{bootstrap_rust} |
184 |
%else |
185 |
BuildRequires: cargo >= %{bootstrap_cargo} |
186 |
%if (0%{?rhel} && 0%{?rhel} < 8) || 0%{?mageia} |
187 |
BuildRequires: %{name} >= %{bootstrap_rust} |
188 |
BuildConflicts: %{name} > %{version} |
189 |
%else |
190 |
BuildRequires: (%{name} >= %{bootstrap_rust} with %{name} <= %{version}) |
191 |
%endif |
192 |
%global local_rust_root %{_prefix} |
193 |
%endif |
194 |
|
195 |
BuildRequires: make |
196 |
BuildRequires: gcc |
197 |
BuildRequires: gcc-c++ |
198 |
BuildRequires: ncurses-devel |
199 |
BuildRequires: curl |
200 |
# explicit curl-devel to avoid httpd24-curl (rhbz1540167) |
201 |
BuildRequires: curl-devel |
202 |
BuildRequires: pkgconfig(libcurl) |
203 |
BuildRequires: pkgconfig(liblzma) |
204 |
BuildRequires: pkgconfig(openssl) |
205 |
BuildRequires: pkgconfig(zlib) |
206 |
|
207 |
%if %without bundled_libgit2 |
208 |
BuildRequires: pkgconfig(libgit2) >= 1.1.0 |
209 |
%endif |
210 |
|
211 |
%if %{without disabled_libssh2} |
212 |
# needs libssh2_userauth_publickey_frommemory |
213 |
BuildRequires: pkgconfig(libssh2) >= 1.6.0 |
214 |
%endif |
215 |
|
216 |
%global python python3 |
217 |
BuildRequires: %{python} |
218 |
|
219 |
%if %with bundled_llvm |
220 |
BuildRequires: cmake3 >= 3.13.4 |
221 |
Provides: bundled(llvm) = 12.0.1 |
222 |
%else |
223 |
BuildRequires: cmake >= 2.8.11 |
224 |
%if 0%{?epel} == 7 |
225 |
%global llvm llvm11 |
226 |
%endif |
227 |
# Rust isn't ready for LLVM 13 yet |
228 |
%if 0%{?fedora} >= 35 || 0%{?mageia} >= 9 |
229 |
%global llvm llvm12 |
230 |
%endif |
231 |
%if %defined llvm |
232 |
%global llvm_root %{_libdir}/%{llvm} |
233 |
%else |
234 |
%global llvm llvm |
235 |
%global llvm_root %{_prefix} |
236 |
%endif |
237 |
BuildRequires: %{llvm}-devel >= 10.0 |
238 |
%if %with llvm_static |
239 |
BuildRequires: %{llvm}-static |
240 |
BuildRequires: libffi-devel |
241 |
%endif |
242 |
%endif |
243 |
|
244 |
# make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs |
245 |
BuildRequires: procps-ng |
246 |
|
247 |
# debuginfo-gdb tests need gdb |
248 |
BuildRequires: gdb |
249 |
|
250 |
# Virtual provides for folks who attempt "dnf install rustc" |
251 |
Provides: rustc = %{version}-%{release} |
252 |
Provides: rustc%{?_isa} = %{version}-%{release} |
253 |
|
254 |
# Always require our exact standard library |
255 |
Requires: %{name}-std-static%{?_isa} = %{version}-%{release} |
256 |
|
257 |
# The C compiler is needed at runtime just for linking. Someday rustc might |
258 |
# invoke the linker directly, and then we'll only need binutils. |
259 |
# https://github.com/rust-lang/rust/issues/11937 |
260 |
%if 0%{?mageia} |
261 |
Requires: gcc |
262 |
%else |
263 |
Requires: /usr/bin/cc |
264 |
%endif |
265 |
|
266 |
%if 0%{?epel} == 7 |
267 |
%global devtoolset_name devtoolset-9 |
268 |
BuildRequires: %{devtoolset_name}-gcc |
269 |
BuildRequires: %{devtoolset_name}-gcc-c++ |
270 |
%global __cc /opt/rh/%{devtoolset_name}/root/usr/bin/gcc |
271 |
%global __cxx /opt/rh/%{devtoolset_name}/root/usr/bin/g++ |
272 |
%endif |
273 |
|
274 |
# ALL Rust libraries are private, because they don't keep an ABI. |
275 |
%global _privatelibs lib(.*-[[:xdigit:]]{16}*|rustc.*)[.]so.* |
276 |
%global __provides_exclude ^(%{_privatelibs})$ |
277 |
%global __requires_exclude ^(%{_privatelibs})$ |
278 |
%global __provides_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$ |
279 |
%global __requires_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$ |
280 |
|
281 |
# While we don't want to encourage dynamic linking to Rust shared libraries, as |
282 |
# there's no stable ABI, we still need the unallocated metadata (.rustc) to |
283 |
# support custom-derive plugins like #[proc_macro_derive(Foo)]. |
284 |
%if 0%{?rhel} && 0%{?rhel} < 8 |
285 |
# eu-strip is very eager by default, so we have to limit it to -g, only debugging symbols. |
286 |
%global _find_debuginfo_opts -g |
287 |
%undefine _include_minidebuginfo |
288 |
%else |
289 |
# Newer find-debuginfo.sh supports --keep-section, which is preferable. rhbz1465997 |
290 |
%global _find_debuginfo_opts --keep-section .rustc |
291 |
%endif |
292 |
|
293 |
# Use hardening ldflags. |
294 |
%global rustflags -Clink-arg=-Wl,-z,relro,-z,now |
295 |
|
296 |
%if %{without bundled_llvm} |
297 |
%if "%{llvm_root}" == "%{_prefix}" || 0%{?scl:1} |
298 |
%global llvm_has_filecheck 1 |
299 |
%endif |
300 |
%endif |
301 |
|
302 |
# We're going to override --libdir when configuring to get rustlib into a |
303 |
# common path, but we'll fix the shared libraries during install. |
304 |
%global common_libdir %{_prefix}/lib |
305 |
%global rustlibdir %{common_libdir}/rustlib |
306 |
|
307 |
%if %defined cross_targets |
308 |
# brp-strip-static-archive breaks the archive index for wasm |
309 |
%global __os_install_post \ |
310 |
%__os_install_post \ |
311 |
find '%{buildroot}%{rustlibdir}' -type f -path '*/wasm*/lib/*.rlib' -print -exec '%{llvm_root}/bin/llvm-ranlib' '{}' ';' \ |
312 |
%{nil} |
313 |
%endif |
314 |
|
315 |
%description |
316 |
Rust is a systems programming language that runs blazingly fast, prevents |
317 |
segfaults, and guarantees thread safety. |
318 |
|
319 |
This package includes the Rust compiler and documentation generator. |
320 |
|
321 |
|
322 |
%package std-static |
323 |
Summary: Standard library for Rust |
324 |
|
325 |
%description std-static |
326 |
This package includes the standard libraries for building applications |
327 |
written in Rust. |
328 |
|
329 |
%if %defined cross_targets |
330 |
%{lua: do |
331 |
for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do |
332 |
local requires = rpm.expand("Requires: rust = %{version}-%{release}") |
333 |
if string.sub(triple, 1, 4) == "wasm" then |
334 |
requires = requires .. "\nRequires: lld >= 8.0" |
335 |
end |
336 |
local subs = { |
337 |
triple = triple, |
338 |
requires = requires, |
339 |
} |
340 |
local s = string.gsub([[ |
341 |
%package std-static-{{triple}} |
342 |
Summary: Standard library for Rust |
343 |
BuildArch: noarch |
344 |
{{requires}} |
345 |
|
346 |
%description std-static-{{triple}} |
347 |
This package includes the standard libraries for building applications |
348 |
written in Rust for the {{triple}} target. |
349 |
]], "{{(%w+)}}", subs) |
350 |
print(s) |
351 |
end |
352 |
end} |
353 |
%endif |
354 |
|
355 |
|
356 |
%package debugger-common |
357 |
Summary: Common debugger pretty printers for Rust |
358 |
BuildArch: noarch |
359 |
|
360 |
%description debugger-common |
361 |
This package includes the common functionality for %{name}-gdb and %{name}-lldb. |
362 |
|
363 |
|
364 |
%package gdb |
365 |
Summary: GDB pretty printers for Rust |
366 |
BuildArch: noarch |
367 |
Requires: gdb |
368 |
Requires: %{name}-debugger-common = %{version}-%{release} |
369 |
|
370 |
%description gdb |
371 |
This package includes the rust-gdb script, which allows easier debugging of Rust |
372 |
programs. |
373 |
|
374 |
|
375 |
%if %with lldb |
376 |
|
377 |
%package lldb |
378 |
Summary: LLDB pretty printers for Rust |
379 |
BuildArch: noarch |
380 |
Requires: lldb |
381 |
Requires: %{python}-lldb |
382 |
Requires: %{name}-debugger-common = %{version}-%{release} |
383 |
|
384 |
%description lldb |
385 |
This package includes the rust-lldb script, which allows easier debugging of Rust |
386 |
programs. |
387 |
|
388 |
%endif |
389 |
|
390 |
|
391 |
%package doc |
392 |
Summary: Documentation for Rust |
393 |
# NOT BuildArch: noarch |
394 |
# Note, while docs are mostly noarch, some things do vary by target_arch. |
395 |
# Koji will fail the build in rpmdiff if two architectures build a noarch |
396 |
# subpackage differently, so instead we have to keep its arch. |
397 |
|
398 |
%description doc |
399 |
This package includes HTML documentation for the Rust programming language and |
400 |
its standard library. |
401 |
|
402 |
|
403 |
%package -n cargo |
404 |
Summary: Rust's package manager and build tool |
405 |
%if %with bundled_libgit2 |
406 |
Provides: bundled(libgit2) = 1.1.0 |
407 |
%endif |
408 |
# For tests: |
409 |
BuildRequires: git |
410 |
# Cargo is not much use without Rust |
411 |
Requires: rust |
412 |
|
413 |
# "cargo vendor" is a builtin command starting with 1.37. The Obsoletes and |
414 |
# Provides are mostly relevant to RHEL, but harmless to have on Fedora/etc. too |
415 |
Obsoletes: cargo-vendor <= 0.1.23 |
416 |
Provides: cargo-vendor = %{version}-%{release} |
417 |
|
418 |
%description -n cargo |
419 |
Cargo is a tool that allows Rust projects to declare their various dependencies |
420 |
and ensure that you'll always get a repeatable build. |
421 |
|
422 |
|
423 |
%package -n cargo-doc |
424 |
Summary: Documentation for Cargo |
425 |
BuildArch: noarch |
426 |
# Cargo no longer builds its own documentation |
427 |
# https://github.com/rust-lang/cargo/pull/4904 |
428 |
Requires: rust-doc = %{version}-%{release} |
429 |
|
430 |
%description -n cargo-doc |
431 |
This package includes HTML documentation for Cargo. |
432 |
|
433 |
|
434 |
%package -n rustfmt |
435 |
Summary: Tool to find and fix Rust formatting issues |
436 |
Requires: cargo |
437 |
|
438 |
# The component/package was rustfmt-preview until Rust 1.31. |
439 |
Obsoletes: rustfmt-preview < 1.0.0 |
440 |
Provides: rustfmt-preview = %{version}-%{release} |
441 |
|
442 |
%description -n rustfmt |
443 |
A tool for formatting Rust code according to style guidelines. |
444 |
|
445 |
|
446 |
%package -n rls |
447 |
Summary: Rust Language Server for IDE integration |
448 |
%if %with bundled_libgit2 |
449 |
Provides: bundled(libgit2) = 1.1.0 |
450 |
%endif |
451 |
Requires: rust-analysis |
452 |
# /usr/bin/rls is dynamically linked against internal rustc libs |
453 |
Requires: %{name}%{?_isa} = %{version}-%{release} |
454 |
|
455 |
# The component/package was rls-preview until Rust 1.31. |
456 |
Obsoletes: rls-preview < 1.31.6 |
457 |
Provides: rls-preview = %{version}-%{release} |
458 |
|
459 |
%description -n rls |
460 |
The Rust Language Server provides a server that runs in the background, |
461 |
providing IDEs, editors, and other tools with information about Rust programs. |
462 |
It supports functionality such as 'goto definition', symbol search, |
463 |
reformatting, and code completion, and enables renaming and refactorings. |
464 |
|
465 |
|
466 |
%package -n clippy |
467 |
Summary: Lints to catch common mistakes and improve your Rust code |
468 |
Requires: cargo |
469 |
# /usr/bin/clippy-driver is dynamically linked against internal rustc libs |
470 |
Requires: %{name}%{?_isa} = %{version}-%{release} |
471 |
|
472 |
# The component/package was clippy-preview until Rust 1.31. |
473 |
Obsoletes: clippy-preview <= 0.0.212 |
474 |
Provides: clippy-preview = %{version}-%{release} |
475 |
|
476 |
%description -n clippy |
477 |
A collection of lints to catch common mistakes and improve your Rust code. |
478 |
|
479 |
|
480 |
%package src |
481 |
Summary: Sources for the Rust standard library |
482 |
BuildArch: noarch |
483 |
|
484 |
%description src |
485 |
This package includes source files for the Rust standard library. It may be |
486 |
useful as a reference for code completion tools in various editors. |
487 |
|
488 |
|
489 |
%package analysis |
490 |
Summary: Compiler analysis data for the Rust standard library |
491 |
Requires: rust-std-static%{?_isa} = %{version}-%{release} |
492 |
|
493 |
%description analysis |
494 |
This package contains analysis data files produced with rustc's -Zsave-analysis |
495 |
feature for the Rust standard library. The RLS (Rust Language Server) uses this |
496 |
data to provide information about the Rust standard library. |
497 |
|
498 |
|
499 |
%prep |
500 |
|
501 |
%ifarch %{bootstrap_arches} |
502 |
%setup -q -n %{bootstrap_root} -T -b %{bootstrap_source} |
503 |
./install.sh --components=cargo,rustc,rust-std-%{rust_triple} \ |
504 |
--prefix=%{local_rust_root} --disable-ldconfig |
505 |
test -f '%{local_rust_root}/bin/cargo' |
506 |
test -f '%{local_rust_root}/bin/rustc' |
507 |
%endif |
508 |
|
509 |
%setup -q -n %{rustc_package} |
510 |
|
511 |
%patch1 -p1 |
512 |
%patch2 -p1 |
513 |
|
514 |
%patch11 -p1 |
515 |
|
516 |
%if %with disabled_libssh2 |
517 |
%patch100 -p1 |
518 |
%endif |
519 |
|
520 |
%if %without curl_http2 |
521 |
%patch101 -p1 |
522 |
rm -rf vendor/libnghttp2-sys/ |
523 |
%endif |
524 |
|
525 |
%if 0%{?rhel} && 0%{?rhel} < 8 |
526 |
%patch102 -p1 |
527 |
%endif |
528 |
|
529 |
%if "%{python}" != "python3" |
530 |
# Use our preferred python first |
531 |
sed -i.try-python -e '/^try python3 /i try "%{python}" "$@"' ./configure |
532 |
%endif |
533 |
|
534 |
%if %without bundled_llvm |
535 |
rm -rf src/llvm-project/ |
536 |
mkdir -p src/llvm-project/libunwind/ |
537 |
%endif |
538 |
|
539 |
# Remove other unused vendored libraries |
540 |
rm -rf vendor/curl-sys/curl/ |
541 |
rm -rf vendor/jemalloc-sys/jemalloc/ |
542 |
rm -rf vendor/libssh2-sys/libssh2/ |
543 |
rm -rf vendor/libz-sys/src/zlib/ |
544 |
rm -rf vendor/libz-sys/src/zlib-ng/ |
545 |
rm -rf vendor/lzma-sys/xz-*/ |
546 |
rm -rf vendor/openssl-src/openssl/ |
547 |
|
548 |
%if %without bundled_libgit2 |
549 |
rm -rf vendor/libgit2-sys/libgit2/ |
550 |
%endif |
551 |
|
552 |
%if %with disabled_libssh2 |
553 |
rm -rf vendor/libssh2-sys/ |
554 |
%endif |
555 |
|
556 |
# This only affects the transient rust-installer, but let it use our dynamic xz-libs |
557 |
sed -i.lzma -e '/LZMA_API_STATIC/d' src/bootstrap/tool.rs |
558 |
|
559 |
%if %{with bundled_llvm} && 0%{?epel} == 7 |
560 |
mkdir -p cmake-bin |
561 |
ln -s /usr/bin/cmake3 cmake-bin/cmake |
562 |
%global cmake_path $PWD/cmake-bin |
563 |
%endif |
564 |
|
565 |
%if %{without bundled_llvm} && %{with llvm_static} |
566 |
# Static linking to distro LLVM needs to add -lffi |
567 |
# https://github.com/rust-lang/rust/issues/34486 |
568 |
sed -i.ffi -e '$a #[link(name = "ffi")] extern {}' \ |
569 |
compiler/rustc_llvm/src/lib.rs |
570 |
%endif |
571 |
|
572 |
# The configure macro will modify some autoconf-related files, which upsets |
573 |
# cargo when it tries to verify checksums in those files. If we just truncate |
574 |
# that file list, cargo won't have anything to complain about. |
575 |
find vendor -name .cargo-checksum.json \ |
576 |
-exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+' |
577 |
|
578 |
# Sometimes Rust sources start with #![...] attributes, and "smart" editors think |
579 |
# it's a shebang and make them executable. Then brp-mangle-shebangs gets upset... |
580 |
find -name '*.rs' -type f -perm /111 -exec chmod -v -x '{}' '+' |
581 |
|
582 |
# Set up shared environment variables for build/install/check |
583 |
%global rust_env RUSTFLAGS="%{rustflags}" |
584 |
%if 0%{?cmake_path:1} |
585 |
%global rust_env %{rust_env} PATH="%{cmake_path}:$PATH" |
586 |
%endif |
587 |
%if %without bundled_libgit2 |
588 |
# convince libgit2-sys to use the distro libgit2 |
589 |
%global rust_env %{rust_env} LIBGIT2_SYS_USE_PKG_CONFIG=1 |
590 |
%endif |
591 |
%if %without disabled_libssh2 |
592 |
# convince libssh2-sys to use the distro libssh2 |
593 |
%global rust_env %{rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1 |
594 |
%endif |
595 |
|
596 |
|
597 |
%build |
598 |
export %{rust_env} |
599 |
|
600 |
%ifarch aarch64 %{arm} %{ix86} s390x |
601 |
# full debuginfo is exhausting memory; just do libstd for now |
602 |
# https://github.com/rust-lang/rust/issues/45854 |
603 |
%if 0%{?rhel} && 0%{?rhel} < 8 |
604 |
# Older rpmbuild didn't work with partial debuginfo coverage. |
605 |
%global debug_package %{nil} |
606 |
%define enable_debuginfo --debuginfo-level=0 |
607 |
%else |
608 |
%define enable_debuginfo --debuginfo-level=0 --debuginfo-level-std=2 |
609 |
%endif |
610 |
%else |
611 |
%define enable_debuginfo --debuginfo-level=2 |
612 |
%endif |
613 |
|
614 |
# Some builders have relatively little memory for their CPU count. |
615 |
# At least 2GB per CPU is a good rule of thumb for building rustc. |
616 |
ncpus=$(/usr/bin/getconf _NPROCESSORS_ONLN) |
617 |
max_cpus=$(( ($(free -g | awk '/^Mem:/{print $2}') + 1) / 2 )) |
618 |
if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then |
619 |
ncpus="$max_cpus" |
620 |
fi |
621 |
|
622 |
%configure --disable-option-checking \ |
623 |
--libdir=%{common_libdir} \ |
624 |
--build=%{rust_triple} --host=%{rust_triple} --target=%{target_triple} \ |
625 |
--set target.%{rust_triple}.linker=%{__cc} \ |
626 |
--set target.%{rust_triple}.cc=%{__cc} \ |
627 |
--set target.%{rust_triple}.cxx=%{__cxx} \ |
628 |
--python=%{python} \ |
629 |
--local-rust-root=%{local_rust_root} \ |
630 |
%{!?with_bundled_llvm: --llvm-root=%{llvm_root} \ |
631 |
%{!?llvm_has_filecheck: --disable-codegen-tests} \ |
632 |
%{!?with_llvm_static: --enable-llvm-link-shared } } \ |
633 |
--disable-rpath \ |
634 |
%{enable_debuginfo} \ |
635 |
--set rust.codegen-units-std=1 \ |
636 |
--enable-extended \ |
637 |
--tools=analysis,cargo,clippy,rls,rustfmt,src \ |
638 |
--enable-vendor \ |
639 |
--enable-verbose-tests \ |
640 |
%{?codegen_units_std} \ |
641 |
--dist-compression-formats=gz \ |
642 |
--release-channel=%{channel} \ |
643 |
--release-description="%{?mageia:Mageia }%{?fedora:Fedora }%{?rhel:Red Hat }%{version}-%{release}" |
644 |
|
645 |
%{python} ./x.py build -j "$ncpus" --stage 2 |
646 |
%{python} ./x.py doc --stage 2 |
647 |
|
648 |
%if %defined cross_targets |
649 |
for triple in %{cross_targets}; do |
650 |
%{python} ./x.py build --stage 2 --target=$triple std |
651 |
done |
652 |
%endif |
653 |
|
654 |
%install |
655 |
export %{rust_env} |
656 |
|
657 |
DESTDIR=%{buildroot} %{python} ./x.py install |
658 |
|
659 |
%if %defined cross_targets |
660 |
for triple in %{cross_targets}; do |
661 |
DESTDIR=%{buildroot} %{python} ./x.py install --target=$triple std |
662 |
done |
663 |
%endif |
664 |
|
665 |
# These are transient files used by x.py dist and install |
666 |
rm -rf ./build/dist/ ./build/tmp/ |
667 |
|
668 |
# Make sure the shared libraries are in the proper libdir |
669 |
%if "%{_libdir}" != "%{common_libdir}" |
670 |
mkdir -p %{buildroot}%{_libdir} |
671 |
find %{buildroot}%{common_libdir} -maxdepth 1 -type f -name '*.so' \ |
672 |
-exec mv -v -t %{buildroot}%{_libdir} '{}' '+' |
673 |
%endif |
674 |
|
675 |
# The shared libraries should be executable for debuginfo extraction. |
676 |
find %{buildroot}%{_libdir} -maxdepth 1 -type f -name '*.so' \ |
677 |
-exec chmod -v +x '{}' '+' |
678 |
|
679 |
# The libdir libraries are identical to those under rustlib/. It's easier on |
680 |
# library loading if we keep them in libdir, but we do need them in rustlib/ |
681 |
# to support dynamic linking for compiler plugins, so we'll symlink. |
682 |
(cd "%{buildroot}%{rustlibdir}/%{rust_triple}/lib" && |
683 |
find ../../../../%{_lib} -maxdepth 1 -name '*.so' | |
684 |
while read lib; do |
685 |
if [ -f "${lib##*/}" ]; then |
686 |
# make sure they're actually identical! |
687 |
cmp "$lib" "${lib##*/}" |
688 |
ln -v -f -s -t . "$lib" |
689 |
fi |
690 |
done) |
691 |
|
692 |
# Remove installer artifacts (manifests, uninstall scripts, etc.) |
693 |
find %{buildroot}%{rustlibdir} -maxdepth 1 -type f -exec rm -v '{}' '+' |
694 |
|
695 |
# Remove backup files from %%configure munging |
696 |
find %{buildroot}%{rustlibdir} -type f -name '*.orig' -exec rm -v '{}' '+' |
697 |
|
698 |
# https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error |
699 |
# We don't actually need to ship any of those python scripts in rust-src anyway. |
700 |
find %{buildroot}%{rustlibdir}/src -type f -name '*.py' -exec rm -v '{}' '+' |
701 |
|
702 |
# FIXME: __os_install_post will strip the rlibs |
703 |
# -- should we find a way to preserve debuginfo? |
704 |
|
705 |
# Remove unwanted documentation files (we already package them) |
706 |
rm -f %{buildroot}%{_docdir}/%{name}/README.md |
707 |
rm -f %{buildroot}%{_docdir}/%{name}/COPYRIGHT |
708 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE |
709 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-APACHE |
710 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-MIT |
711 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-THIRD-PARTY |
712 |
rm -f %{buildroot}%{_docdir}/%{name}/*.old |
713 |
|
714 |
# Sanitize the HTML documentation |
715 |
find %{buildroot}%{_docdir}/%{name}/html -empty -delete |
716 |
find %{buildroot}%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+' |
717 |
|
718 |
# Create the path for crate-devel packages |
719 |
mkdir -p %{buildroot}%{_datadir}/cargo/registry |
720 |
|
721 |
# Cargo no longer builds its own documentation |
722 |
# https://github.com/rust-lang/cargo/pull/4904 |
723 |
mkdir -p %{buildroot}%{_docdir}/cargo |
724 |
ln -sT ../rust/html/cargo/ %{buildroot}%{_docdir}/cargo/html |
725 |
|
726 |
%if %without lldb |
727 |
rm -f %{buildroot}%{_bindir}/rust-lldb |
728 |
rm -f %{buildroot}%{rustlibdir}/etc/lldb_* |
729 |
%endif |
730 |
|
731 |
# We don't want Rust copies of LLVM tools (rust-lld, rust-llvm-dwp) |
732 |
rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll* |
733 |
|
734 |
|
735 |
%check |
736 |
export %{rust_env} |
737 |
|
738 |
# The results are not stable on koji, so mask errors and just log it. |
739 |
# Some of the larger test artifacts are manually cleaned to save space. |
740 |
%{python} ./x.py test --no-fail-fast --stage 2 || : |
741 |
rm -rf "./build/%{rust_triple}/test/" |
742 |
|
743 |
%{python} ./x.py test --no-fail-fast --stage 2 cargo || : |
744 |
rm -rf "./build/%{rust_triple}/stage2-tools/%{rust_triple}/cit/" |
745 |
|
746 |
env RLS_TEST_WAIT_FOR_AGES=1 \ |
747 |
%{python} ./x.py test --no-fail-fast --stage 2 clippy || : |
748 |
|
749 |
%{python} ./x.py test --no-fail-fast --stage 2 rls || : |
750 |
|
751 |
%{python} ./x.py test --no-fail-fast --stage 2 rustfmt || : |
752 |
|
753 |
|
754 |
%{?ldconfig_scriptlets} |
755 |
|
756 |
|
757 |
%files |
758 |
%license COPYRIGHT LICENSE-APACHE LICENSE-MIT |
759 |
%doc README.md |
760 |
%{_bindir}/rustc |
761 |
%{_bindir}/rustdoc |
762 |
%{_libdir}/*.so |
763 |
%{_mandir}/man1/rustc.1* |
764 |
%{_mandir}/man1/rustdoc.1* |
765 |
%dir %{rustlibdir} |
766 |
%dir %{rustlibdir}/%{rust_triple} |
767 |
%dir %{rustlibdir}/%{rust_triple}/lib |
768 |
%{rustlibdir}/%{rust_triple}/lib/*.so |
769 |
%if %defined bootstrap_build_arch |
770 |
%dir %{rustlibdir}/%{target_triple} |
771 |
%dir %{rustlibdir}/%{target_triple}/lib |
772 |
%{rustlibdir}/%{target_triple}/lib/*.so |
773 |
%endif |
774 |
|
775 |
|
776 |
%files std-static |
777 |
%dir %{rustlibdir} |
778 |
%dir %{rustlibdir}/%{rust_triple} |
779 |
%dir %{rustlibdir}/%{rust_triple}/lib |
780 |
%{rustlibdir}/%{rust_triple}/lib/*.rlib |
781 |
%if %defined bootstrap_build_arch |
782 |
%dir %{rustlibdir}/%{target_triple} |
783 |
%dir %{rustlibdir}/%{target_triple}/lib |
784 |
%{rustlibdir}/%{target_triple}/lib/*.rlib |
785 |
%endif |
786 |
|
787 |
|
788 |
%if %defined cross_targets |
789 |
%{lua: do |
790 |
for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do |
791 |
local subs = { |
792 |
triple = triple, |
793 |
rustlibdir = rpm.expand("%{rustlibdir}"), |
794 |
} |
795 |
local s = string.gsub([[ |
796 |
%files std-static-{{triple}} |
797 |
%dir {{rustlibdir}} |
798 |
%dir {{rustlibdir}}/{{triple}} |
799 |
%dir {{rustlibdir}}/{{triple}}/lib |
800 |
{{rustlibdir}}/{{triple}}/lib/*.rlib |
801 |
]], "{{(%w+)}}", subs) |
802 |
print(s) |
803 |
end |
804 |
end} |
805 |
%endif |
806 |
|
807 |
|
808 |
%files debugger-common |
809 |
%dir %{rustlibdir} |
810 |
%dir %{rustlibdir}/etc |
811 |
%{rustlibdir}/etc/rust_*.py* |
812 |
|
813 |
|
814 |
%files gdb |
815 |
%{_bindir}/rust-gdb |
816 |
%{rustlibdir}/etc/gdb_* |
817 |
%exclude %{_bindir}/rust-gdbgui |
818 |
|
819 |
|
820 |
%if %with lldb |
821 |
%files lldb |
822 |
%{_bindir}/rust-lldb |
823 |
%{rustlibdir}/etc/lldb_* |
824 |
%endif |
825 |
|
826 |
|
827 |
%files doc |
828 |
%docdir %{_docdir}/%{name} |
829 |
%dir %{_docdir}/%{name} |
830 |
%dir %{_docdir}/%{name}/html |
831 |
%{_docdir}/%{name}/html/*/ |
832 |
%{_docdir}/%{name}/html/*.html |
833 |
%{_docdir}/%{name}/html/*.css |
834 |
%{_docdir}/%{name}/html/*.js |
835 |
%{_docdir}/%{name}/html/*.png |
836 |
%{_docdir}/%{name}/html/*.svg |
837 |
%{_docdir}/%{name}/html/*.woff |
838 |
%{_docdir}/%{name}/html/*.woff2 |
839 |
%license %{_docdir}/%{name}/html/*.txt |
840 |
%license %{_docdir}/%{name}/html/*.md |
841 |
|
842 |
|
843 |
%files -n cargo |
844 |
%license src/tools/cargo/LICENSE-APACHE src/tools/cargo/LICENSE-MIT src/tools/cargo/LICENSE-THIRD-PARTY |
845 |
%doc src/tools/cargo/README.md |
846 |
%{_bindir}/cargo |
847 |
%{_libexecdir}/cargo* |
848 |
%{_mandir}/man1/cargo*.1* |
849 |
%{_sysconfdir}/bash_completion.d/cargo |
850 |
%{_datadir}/zsh/site-functions/_cargo |
851 |
%dir %{_datadir}/cargo |
852 |
%dir %{_datadir}/cargo/registry |
853 |
|
854 |
|
855 |
%files -n cargo-doc |
856 |
%docdir %{_docdir}/cargo |
857 |
%dir %{_docdir}/cargo |
858 |
%{_docdir}/cargo/html |
859 |
|
860 |
|
861 |
%files -n rustfmt |
862 |
%{_bindir}/rustfmt |
863 |
%{_bindir}/cargo-fmt |
864 |
%doc src/tools/rustfmt/{README,CHANGELOG,Configurations}.md |
865 |
%license src/tools/rustfmt/LICENSE-{APACHE,MIT} |
866 |
|
867 |
|
868 |
%files -n rls |
869 |
%{_bindir}/rls |
870 |
%doc src/tools/rls/{README.md,COPYRIGHT,debugging.md} |
871 |
%license src/tools/rls/LICENSE-{APACHE,MIT} |
872 |
|
873 |
|
874 |
%files -n clippy |
875 |
%{_bindir}/cargo-clippy |
876 |
%{_bindir}/clippy-driver |
877 |
%doc src/tools/clippy/{README.md,CHANGELOG.md} |
878 |
%license src/tools/clippy/LICENSE-{APACHE,MIT} |
879 |
|
880 |
|
881 |
%files src |
882 |
%dir %{rustlibdir} |
883 |
%{rustlibdir}/src |
884 |
|
885 |
|
886 |
%files analysis |
887 |
%{rustlibdir}/%{rust_triple}/analysis/ |
888 |
%if %defined bootstrap_build_arch |
889 |
%{rustlibdir}/%{target_triple}/analysis/ |
890 |
%endif |