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.53.0 |
18 |
%global bootstrap_cargo 1.53.0 |
19 |
%global bootstrap_channel 1.53.0 |
20 |
%global bootstrap_date 2021-06-17 |
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.54.0 |
93 |
Release: %mkrel 2 |
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.53.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.0 |
222 |
%else |
223 |
BuildRequires: cmake >= 2.8.11 |
224 |
%if 0%{?epel} == 7 |
225 |
%global llvm llvm11 |
226 |
%endif |
227 |
%if %defined llvm |
228 |
%global llvm_root %{_libdir}/%{llvm} |
229 |
%else |
230 |
%global llvm llvm |
231 |
%global llvm_root %{_prefix} |
232 |
%endif |
233 |
BuildRequires: %{llvm}-devel >= 10.0 |
234 |
%if %with llvm_static |
235 |
BuildRequires: %{llvm}-static |
236 |
BuildRequires: libffi-devel |
237 |
%endif |
238 |
%endif |
239 |
|
240 |
# make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs |
241 |
BuildRequires: procps-ng |
242 |
|
243 |
# debuginfo-gdb tests need gdb |
244 |
BuildRequires: gdb |
245 |
|
246 |
# Virtual provides for folks who attempt "dnf install rustc" |
247 |
Provides: rustc = %{version}-%{release} |
248 |
Provides: rustc%{?_isa} = %{version}-%{release} |
249 |
|
250 |
# Always require our exact standard library |
251 |
Requires: %{name}-std-static%{?_isa} = %{version}-%{release} |
252 |
|
253 |
# The C compiler is needed at runtime just for linking. Someday rustc might |
254 |
# invoke the linker directly, and then we'll only need binutils. |
255 |
# https://github.com/rust-lang/rust/issues/11937 |
256 |
%if 0%{?mageia} |
257 |
Requires: gcc |
258 |
%else |
259 |
Requires: /usr/bin/cc |
260 |
%endif |
261 |
|
262 |
%if 0%{?epel} == 7 |
263 |
%global devtoolset_name devtoolset-9 |
264 |
BuildRequires: %{devtoolset_name}-gcc |
265 |
BuildRequires: %{devtoolset_name}-gcc-c++ |
266 |
%global __cc /opt/rh/%{devtoolset_name}/root/usr/bin/gcc |
267 |
%global __cxx /opt/rh/%{devtoolset_name}/root/usr/bin/g++ |
268 |
%endif |
269 |
|
270 |
# ALL Rust libraries are private, because they don't keep an ABI. |
271 |
%global _privatelibs lib(.*-[[:xdigit:]]{16}*|rustc.*)[.]so.* |
272 |
%global __provides_exclude ^(%{_privatelibs})$ |
273 |
%global __requires_exclude ^(%{_privatelibs})$ |
274 |
%global __provides_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$ |
275 |
%global __requires_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$ |
276 |
|
277 |
# While we don't want to encourage dynamic linking to Rust shared libraries, as |
278 |
# there's no stable ABI, we still need the unallocated metadata (.rustc) to |
279 |
# support custom-derive plugins like #[proc_macro_derive(Foo)]. |
280 |
%if 0%{?rhel} && 0%{?rhel} < 8 |
281 |
# eu-strip is very eager by default, so we have to limit it to -g, only debugging symbols. |
282 |
%global _find_debuginfo_opts -g |
283 |
%undefine _include_minidebuginfo |
284 |
%else |
285 |
# Newer find-debuginfo.sh supports --keep-section, which is preferable. rhbz1465997 |
286 |
%global _find_debuginfo_opts --keep-section .rustc |
287 |
%endif |
288 |
|
289 |
# Use hardening ldflags. |
290 |
%global rustflags -Clink-arg=-Wl,-z,relro,-z,now |
291 |
|
292 |
%if %{without bundled_llvm} |
293 |
%if "%{llvm_root}" == "%{_prefix}" || 0%{?scl:1} |
294 |
%global llvm_has_filecheck 1 |
295 |
%endif |
296 |
%endif |
297 |
|
298 |
# We're going to override --libdir when configuring to get rustlib into a |
299 |
# common path, but we'll fix the shared libraries during install. |
300 |
%global common_libdir %{_prefix}/lib |
301 |
%global rustlibdir %{common_libdir}/rustlib |
302 |
|
303 |
%if %defined cross_targets |
304 |
# brp-strip-static-archive breaks the archive index for wasm |
305 |
%global __os_install_post \ |
306 |
%__os_install_post \ |
307 |
find %{buildroot}%{rustlibdir} -type f -path '*/wasm*/lib/*.rlib' -exec ranlib '{}' ';' \ |
308 |
%{nil} |
309 |
%endif |
310 |
|
311 |
%description |
312 |
Rust is a systems programming language that runs blazingly fast, prevents |
313 |
segfaults, and guarantees thread safety. |
314 |
|
315 |
This package includes the Rust compiler and documentation generator. |
316 |
|
317 |
|
318 |
%package std-static |
319 |
Summary: Standard library for Rust |
320 |
|
321 |
%description std-static |
322 |
This package includes the standard libraries for building applications |
323 |
written in Rust. |
324 |
|
325 |
%if %defined cross_targets |
326 |
%{lua: do |
327 |
for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do |
328 |
local requires = rpm.expand("Requires: rust = %{version}-%{release}") |
329 |
if string.sub(triple, 1, 4) == "wasm" then |
330 |
requires = requires .. "\nRequires: lld >= 8.0" |
331 |
end |
332 |
local subs = { |
333 |
triple = triple, |
334 |
requires = requires, |
335 |
} |
336 |
local s = string.gsub([[ |
337 |
%package std-static-{{triple}} |
338 |
Summary: Standard library for Rust |
339 |
BuildArch: noarch |
340 |
{{requires}} |
341 |
|
342 |
%description std-static-{{triple}} |
343 |
This package includes the standard libraries for building applications |
344 |
written in Rust for the {{triple}} target. |
345 |
]], "{{(%w+)}}", subs) |
346 |
print(s) |
347 |
end |
348 |
end} |
349 |
%endif |
350 |
|
351 |
|
352 |
%package debugger-common |
353 |
Summary: Common debugger pretty printers for Rust |
354 |
BuildArch: noarch |
355 |
|
356 |
%description debugger-common |
357 |
This package includes the common functionality for %{name}-gdb and %{name}-lldb. |
358 |
|
359 |
|
360 |
%package gdb |
361 |
Summary: GDB pretty printers for Rust |
362 |
BuildArch: noarch |
363 |
Requires: gdb |
364 |
Requires: %{name}-debugger-common = %{version}-%{release} |
365 |
|
366 |
%description gdb |
367 |
This package includes the rust-gdb script, which allows easier debugging of Rust |
368 |
programs. |
369 |
|
370 |
|
371 |
%if %with lldb |
372 |
|
373 |
%package lldb |
374 |
Summary: LLDB pretty printers for Rust |
375 |
BuildArch: noarch |
376 |
Requires: lldb |
377 |
Requires: %{python}-lldb |
378 |
Requires: %{name}-debugger-common = %{version}-%{release} |
379 |
|
380 |
%description lldb |
381 |
This package includes the rust-lldb script, which allows easier debugging of Rust |
382 |
programs. |
383 |
|
384 |
%endif |
385 |
|
386 |
|
387 |
%package doc |
388 |
Summary: Documentation for Rust |
389 |
# NOT BuildArch: noarch |
390 |
# Note, while docs are mostly noarch, some things do vary by target_arch. |
391 |
# Koji will fail the build in rpmdiff if two architectures build a noarch |
392 |
# subpackage differently, so instead we have to keep its arch. |
393 |
|
394 |
%description doc |
395 |
This package includes HTML documentation for the Rust programming language and |
396 |
its standard library. |
397 |
|
398 |
|
399 |
%package -n cargo |
400 |
Summary: Rust's package manager and build tool |
401 |
%if %with bundled_libgit2 |
402 |
Provides: bundled(libgit2) = 1.1.0 |
403 |
%endif |
404 |
# For tests: |
405 |
BuildRequires: git |
406 |
# Cargo is not much use without Rust |
407 |
Requires: rust |
408 |
|
409 |
# "cargo vendor" is a builtin command starting with 1.37. The Obsoletes and |
410 |
# Provides are mostly relevant to RHEL, but harmless to have on Fedora/etc. too |
411 |
Obsoletes: cargo-vendor <= 0.1.23 |
412 |
Provides: cargo-vendor = %{version}-%{release} |
413 |
|
414 |
%description -n cargo |
415 |
Cargo is a tool that allows Rust projects to declare their various dependencies |
416 |
and ensure that you'll always get a repeatable build. |
417 |
|
418 |
|
419 |
%package -n cargo-doc |
420 |
Summary: Documentation for Cargo |
421 |
BuildArch: noarch |
422 |
# Cargo no longer builds its own documentation |
423 |
# https://github.com/rust-lang/cargo/pull/4904 |
424 |
Requires: rust-doc = %{version}-%{release} |
425 |
|
426 |
%description -n cargo-doc |
427 |
This package includes HTML documentation for Cargo. |
428 |
|
429 |
|
430 |
%package -n rustfmt |
431 |
Summary: Tool to find and fix Rust formatting issues |
432 |
Requires: cargo |
433 |
|
434 |
# The component/package was rustfmt-preview until Rust 1.31. |
435 |
Obsoletes: rustfmt-preview < 1.0.0 |
436 |
Provides: rustfmt-preview = %{version}-%{release} |
437 |
|
438 |
%description -n rustfmt |
439 |
A tool for formatting Rust code according to style guidelines. |
440 |
|
441 |
|
442 |
%package -n rls |
443 |
Summary: Rust Language Server for IDE integration |
444 |
%if %with bundled_libgit2 |
445 |
Provides: bundled(libgit2) = 1.1.0 |
446 |
%endif |
447 |
Requires: rust-analysis |
448 |
# /usr/bin/rls is dynamically linked against internal rustc libs |
449 |
Requires: %{name}%{?_isa} = %{version}-%{release} |
450 |
|
451 |
# The component/package was rls-preview until Rust 1.31. |
452 |
Obsoletes: rls-preview < 1.31.6 |
453 |
Provides: rls-preview = %{version}-%{release} |
454 |
|
455 |
%description -n rls |
456 |
The Rust Language Server provides a server that runs in the background, |
457 |
providing IDEs, editors, and other tools with information about Rust programs. |
458 |
It supports functionality such as 'goto definition', symbol search, |
459 |
reformatting, and code completion, and enables renaming and refactorings. |
460 |
|
461 |
|
462 |
%package -n clippy |
463 |
Summary: Lints to catch common mistakes and improve your Rust code |
464 |
Requires: cargo |
465 |
# /usr/bin/clippy-driver is dynamically linked against internal rustc libs |
466 |
Requires: %{name}%{?_isa} = %{version}-%{release} |
467 |
|
468 |
# The component/package was clippy-preview until Rust 1.31. |
469 |
Obsoletes: clippy-preview <= 0.0.212 |
470 |
Provides: clippy-preview = %{version}-%{release} |
471 |
|
472 |
%description -n clippy |
473 |
A collection of lints to catch common mistakes and improve your Rust code. |
474 |
|
475 |
|
476 |
%package src |
477 |
Summary: Sources for the Rust standard library |
478 |
BuildArch: noarch |
479 |
|
480 |
%description src |
481 |
This package includes source files for the Rust standard library. It may be |
482 |
useful as a reference for code completion tools in various editors. |
483 |
|
484 |
|
485 |
%package analysis |
486 |
Summary: Compiler analysis data for the Rust standard library |
487 |
Requires: rust-std-static%{?_isa} = %{version}-%{release} |
488 |
|
489 |
%description analysis |
490 |
This package contains analysis data files produced with rustc's -Zsave-analysis |
491 |
feature for the Rust standard library. The RLS (Rust Language Server) uses this |
492 |
data to provide information about the Rust standard library. |
493 |
|
494 |
|
495 |
%prep |
496 |
|
497 |
%ifarch %{bootstrap_arches} |
498 |
%setup -q -n %{bootstrap_root} -T -b %{bootstrap_source} |
499 |
./install.sh --components=cargo,rustc,rust-std-%{rust_triple} \ |
500 |
--prefix=%{local_rust_root} --disable-ldconfig |
501 |
test -f '%{local_rust_root}/bin/cargo' |
502 |
test -f '%{local_rust_root}/bin/rustc' |
503 |
%endif |
504 |
|
505 |
%setup -q -n %{rustc_package} |
506 |
|
507 |
%patch1 -p1 |
508 |
%patch2 -p1 |
509 |
|
510 |
%patch11 -p1 |
511 |
|
512 |
%if %with disabled_libssh2 |
513 |
%patch100 -p1 |
514 |
%endif |
515 |
|
516 |
%if %without curl_http2 |
517 |
%patch101 -p1 |
518 |
rm -rf vendor/libnghttp2-sys/ |
519 |
%endif |
520 |
|
521 |
%if 0%{?rhel} && 0%{?rhel} < 8 |
522 |
%patch102 -p1 |
523 |
%endif |
524 |
|
525 |
%if "%{python}" != "python3" |
526 |
# Use our preferred python first |
527 |
sed -i.try-python -e '/^try python3 /i try "%{python}" "$@"' ./configure |
528 |
%endif |
529 |
|
530 |
%if %without bundled_llvm |
531 |
rm -rf src/llvm-project/ |
532 |
mkdir -p src/llvm-project/libunwind/ |
533 |
%endif |
534 |
|
535 |
# Remove other unused vendored libraries |
536 |
rm -rf vendor/curl-sys/curl/ |
537 |
rm -rf vendor/jemalloc-sys/jemalloc/ |
538 |
rm -rf vendor/libssh2-sys/libssh2/ |
539 |
rm -rf vendor/libz-sys/src/zlib/ |
540 |
rm -rf vendor/libz-sys/src/zlib-ng/ |
541 |
rm -rf vendor/lzma-sys/xz-*/ |
542 |
rm -rf vendor/openssl-src/openssl/ |
543 |
|
544 |
%if %without bundled_libgit2 |
545 |
rm -rf vendor/libgit2-sys/libgit2/ |
546 |
%endif |
547 |
|
548 |
%if %with disabled_libssh2 |
549 |
rm -rf vendor/libssh2-sys/ |
550 |
%endif |
551 |
|
552 |
# This only affects the transient rust-installer, but let it use our dynamic xz-libs |
553 |
sed -i.lzma -e '/LZMA_API_STATIC/d' src/bootstrap/tool.rs |
554 |
|
555 |
%if %{with bundled_llvm} && 0%{?epel} == 7 |
556 |
mkdir -p cmake-bin |
557 |
ln -s /usr/bin/cmake3 cmake-bin/cmake |
558 |
%global cmake_path $PWD/cmake-bin |
559 |
%endif |
560 |
|
561 |
%if %{without bundled_llvm} && %{with llvm_static} |
562 |
# Static linking to distro LLVM needs to add -lffi |
563 |
# https://github.com/rust-lang/rust/issues/34486 |
564 |
sed -i.ffi -e '$a #[link(name = "ffi")] extern {}' \ |
565 |
compiler/rustc_llvm/src/lib.rs |
566 |
%endif |
567 |
|
568 |
# The configure macro will modify some autoconf-related files, which upsets |
569 |
# cargo when it tries to verify checksums in those files. If we just truncate |
570 |
# that file list, cargo won't have anything to complain about. |
571 |
find vendor -name .cargo-checksum.json \ |
572 |
-exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+' |
573 |
|
574 |
# Sometimes Rust sources start with #![...] attributes, and "smart" editors think |
575 |
# it's a shebang and make them executable. Then brp-mangle-shebangs gets upset... |
576 |
find -name '*.rs' -type f -perm /111 -exec chmod -v -x '{}' '+' |
577 |
|
578 |
# Set up shared environment variables for build/install/check |
579 |
%global rust_env RUSTFLAGS="%{rustflags}" |
580 |
%if 0%{?cmake_path:1} |
581 |
%global rust_env %{rust_env} PATH="%{cmake_path}:$PATH" |
582 |
%endif |
583 |
%if %without bundled_libgit2 |
584 |
# convince libgit2-sys to use the distro libgit2 |
585 |
%global rust_env %{rust_env} LIBGIT2_SYS_USE_PKG_CONFIG=1 |
586 |
%endif |
587 |
%if %without disabled_libssh2 |
588 |
# convince libssh2-sys to use the distro libssh2 |
589 |
%global rust_env %{rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1 |
590 |
%endif |
591 |
|
592 |
|
593 |
%build |
594 |
export %{rust_env} |
595 |
|
596 |
%ifarch aarch64 %{arm} %{ix86} s390x |
597 |
# full debuginfo is exhausting memory; just do libstd for now |
598 |
# https://github.com/rust-lang/rust/issues/45854 |
599 |
%if 0%{?rhel} && 0%{?rhel} < 8 |
600 |
# Older rpmbuild didn't work with partial debuginfo coverage. |
601 |
%global debug_package %{nil} |
602 |
%define enable_debuginfo --debuginfo-level=0 |
603 |
%else |
604 |
%define enable_debuginfo --debuginfo-level=0 --debuginfo-level-std=2 |
605 |
%endif |
606 |
%else |
607 |
%define enable_debuginfo --debuginfo-level=2 |
608 |
%endif |
609 |
|
610 |
# Some builders have relatively little memory for their CPU count. |
611 |
# At least 2GB per CPU is a good rule of thumb for building rustc. |
612 |
ncpus=$(/usr/bin/getconf _NPROCESSORS_ONLN) |
613 |
max_cpus=$(( ($(free -g | awk '/^Mem:/{print $2}') + 1) / 2 )) |
614 |
if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then |
615 |
ncpus="$max_cpus" |
616 |
fi |
617 |
|
618 |
%configure --disable-option-checking \ |
619 |
--libdir=%{common_libdir} \ |
620 |
--build=%{rust_triple} --host=%{rust_triple} --target=%{target_triple} \ |
621 |
--set target.%{rust_triple}.linker=%{__cc} \ |
622 |
--set target.%{rust_triple}.cc=%{__cc} \ |
623 |
--set target.%{rust_triple}.cxx=%{__cxx} \ |
624 |
--python=%{python} \ |
625 |
--local-rust-root=%{local_rust_root} \ |
626 |
%{!?with_bundled_llvm: --llvm-root=%{llvm_root} \ |
627 |
%{!?llvm_has_filecheck: --disable-codegen-tests} \ |
628 |
%{!?with_llvm_static: --enable-llvm-link-shared } } \ |
629 |
--disable-rpath \ |
630 |
%{enable_debuginfo} \ |
631 |
--set rust.codegen-units-std=1 \ |
632 |
--enable-extended \ |
633 |
--tools=analysis,cargo,clippy,rls,rustfmt,src \ |
634 |
--enable-vendor \ |
635 |
--enable-verbose-tests \ |
636 |
%{?codegen_units_std} \ |
637 |
--release-channel=%{channel} \ |
638 |
--release-description="%{?mageia:Mageia }%{?fedora:Fedora }%{?rhel:Red Hat }%{version}-%{release}" |
639 |
|
640 |
%{python} ./x.py build -j "$ncpus" --stage 2 |
641 |
%{python} ./x.py doc --stage 2 |
642 |
|
643 |
%if %defined cross_targets |
644 |
for triple in %{cross_targets}; do |
645 |
%{python} ./x.py build --stage 2 --target=$triple std |
646 |
done |
647 |
%endif |
648 |
|
649 |
%install |
650 |
export %{rust_env} |
651 |
|
652 |
DESTDIR=%{buildroot} %{python} ./x.py install |
653 |
|
654 |
%if %defined cross_targets |
655 |
for triple in %{cross_targets}; do |
656 |
DESTDIR=%{buildroot} %{python} ./x.py install --target=$triple std |
657 |
done |
658 |
%endif |
659 |
|
660 |
# These are transient files used by x.py dist and install |
661 |
rm -rf ./build/dist/ ./build/tmp/ |
662 |
|
663 |
# Make sure the shared libraries are in the proper libdir |
664 |
%if "%{_libdir}" != "%{common_libdir}" |
665 |
mkdir -p %{buildroot}%{_libdir} |
666 |
find %{buildroot}%{common_libdir} -maxdepth 1 -type f -name '*.so' \ |
667 |
-exec mv -v -t %{buildroot}%{_libdir} '{}' '+' |
668 |
%endif |
669 |
|
670 |
# The shared libraries should be executable for debuginfo extraction. |
671 |
find %{buildroot}%{_libdir} -maxdepth 1 -type f -name '*.so' \ |
672 |
-exec chmod -v +x '{}' '+' |
673 |
|
674 |
# The libdir libraries are identical to those under rustlib/. It's easier on |
675 |
# library loading if we keep them in libdir, but we do need them in rustlib/ |
676 |
# to support dynamic linking for compiler plugins, so we'll symlink. |
677 |
(cd "%{buildroot}%{rustlibdir}/%{rust_triple}/lib" && |
678 |
find ../../../../%{_lib} -maxdepth 1 -name '*.so' | |
679 |
while read lib; do |
680 |
if [ -f "${lib##*/}" ]; then |
681 |
# make sure they're actually identical! |
682 |
cmp "$lib" "${lib##*/}" |
683 |
ln -v -f -s -t . "$lib" |
684 |
fi |
685 |
done) |
686 |
|
687 |
# Remove installer artifacts (manifests, uninstall scripts, etc.) |
688 |
find %{buildroot}%{rustlibdir} -maxdepth 1 -type f -exec rm -v '{}' '+' |
689 |
|
690 |
# Remove backup files from %%configure munging |
691 |
find %{buildroot}%{rustlibdir} -type f -name '*.orig' -exec rm -v '{}' '+' |
692 |
|
693 |
# https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error |
694 |
# We don't actually need to ship any of those python scripts in rust-src anyway. |
695 |
find %{buildroot}%{rustlibdir}/src -type f -name '*.py' -exec rm -v '{}' '+' |
696 |
|
697 |
# FIXME: __os_install_post will strip the rlibs |
698 |
# -- should we find a way to preserve debuginfo? |
699 |
|
700 |
# Remove unwanted documentation files (we already package them) |
701 |
rm -f %{buildroot}%{_docdir}/%{name}/README.md |
702 |
rm -f %{buildroot}%{_docdir}/%{name}/COPYRIGHT |
703 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE |
704 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-APACHE |
705 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-MIT |
706 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-THIRD-PARTY |
707 |
rm -f %{buildroot}%{_docdir}/%{name}/*.old |
708 |
|
709 |
# Sanitize the HTML documentation |
710 |
find %{buildroot}%{_docdir}/%{name}/html -empty -delete |
711 |
find %{buildroot}%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+' |
712 |
|
713 |
# Create the path for crate-devel packages |
714 |
mkdir -p %{buildroot}%{_datadir}/cargo/registry |
715 |
|
716 |
# Cargo no longer builds its own documentation |
717 |
# https://github.com/rust-lang/cargo/pull/4904 |
718 |
mkdir -p %{buildroot}%{_docdir}/cargo |
719 |
ln -sT ../rust/html/cargo/ %{buildroot}%{_docdir}/cargo/html |
720 |
|
721 |
%if %without lldb |
722 |
rm -f %{buildroot}%{_bindir}/rust-lldb |
723 |
rm -f %{buildroot}%{rustlibdir}/etc/lldb_* |
724 |
%endif |
725 |
|
726 |
# We don't want Rust copies of LLVM tools (rust-lld, rust-llvm-dwp) |
727 |
rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll* |
728 |
|
729 |
|
730 |
%check |
731 |
export %{rust_env} |
732 |
|
733 |
# The results are not stable on koji, so mask errors and just log it. |
734 |
# Some of the larger test artifacts are manually cleaned to save space. |
735 |
%{python} ./x.py test --no-fail-fast --stage 2 || : |
736 |
rm -rf "./build/%{rust_triple}/test/" |
737 |
|
738 |
%{python} ./x.py test --no-fail-fast --stage 2 cargo || : |
739 |
rm -rf "./build/%{rust_triple}/stage2-tools/%{rust_triple}/cit/" |
740 |
|
741 |
%{python} ./x.py test --no-fail-fast --stage 2 clippy || : |
742 |
%{python} ./x.py test --no-fail-fast --stage 2 rls || : |
743 |
%{python} ./x.py test --no-fail-fast --stage 2 rustfmt || : |
744 |
|
745 |
|
746 |
%{?ldconfig_scriptlets} |
747 |
|
748 |
|
749 |
%files |
750 |
%license COPYRIGHT LICENSE-APACHE LICENSE-MIT |
751 |
%doc README.md |
752 |
%{_bindir}/rustc |
753 |
%{_bindir}/rustdoc |
754 |
%{_libdir}/*.so |
755 |
%{_mandir}/man1/rustc.1* |
756 |
%{_mandir}/man1/rustdoc.1* |
757 |
%dir %{rustlibdir} |
758 |
%dir %{rustlibdir}/%{rust_triple} |
759 |
%dir %{rustlibdir}/%{rust_triple}/lib |
760 |
%{rustlibdir}/%{rust_triple}/lib/*.so |
761 |
%if %defined bootstrap_build_arch |
762 |
%dir %{rustlibdir}/%{target_triple} |
763 |
%dir %{rustlibdir}/%{target_triple}/lib |
764 |
%{rustlibdir}/%{target_triple}/lib/*.so |
765 |
%endif |
766 |
|
767 |
|
768 |
%files std-static |
769 |
%dir %{rustlibdir} |
770 |
%dir %{rustlibdir}/%{rust_triple} |
771 |
%dir %{rustlibdir}/%{rust_triple}/lib |
772 |
%{rustlibdir}/%{rust_triple}/lib/*.rlib |
773 |
%if %defined bootstrap_build_arch |
774 |
%dir %{rustlibdir}/%{target_triple} |
775 |
%dir %{rustlibdir}/%{target_triple}/lib |
776 |
%{rustlibdir}/%{target_triple}/lib/*.rlib |
777 |
%endif |
778 |
|
779 |
|
780 |
%if %defined cross_targets |
781 |
%{lua: do |
782 |
for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do |
783 |
local subs = { |
784 |
triple = triple, |
785 |
rustlibdir = rpm.expand("%{rustlibdir}"), |
786 |
} |
787 |
local s = string.gsub([[ |
788 |
%files std-static-{{triple}} |
789 |
%dir {{rustlibdir}} |
790 |
%dir {{rustlibdir}}/{{triple}} |
791 |
%dir {{rustlibdir}}/{{triple}}/lib |
792 |
{{rustlibdir}}/{{triple}}/lib/*.rlib |
793 |
]], "{{(%w+)}}", subs) |
794 |
print(s) |
795 |
end |
796 |
end} |
797 |
%endif |
798 |
|
799 |
|
800 |
%files debugger-common |
801 |
%dir %{rustlibdir} |
802 |
%dir %{rustlibdir}/etc |
803 |
%{rustlibdir}/etc/rust_*.py* |
804 |
|
805 |
|
806 |
%files gdb |
807 |
%{_bindir}/rust-gdb |
808 |
%{rustlibdir}/etc/gdb_* |
809 |
%exclude %{_bindir}/rust-gdbgui |
810 |
|
811 |
|
812 |
%if %with lldb |
813 |
%files lldb |
814 |
%{_bindir}/rust-lldb |
815 |
%{rustlibdir}/etc/lldb_* |
816 |
%endif |
817 |
|
818 |
|
819 |
%files doc |
820 |
%docdir %{_docdir}/%{name} |
821 |
%dir %{_docdir}/%{name} |
822 |
%dir %{_docdir}/%{name}/html |
823 |
%{_docdir}/%{name}/html/*/ |
824 |
%{_docdir}/%{name}/html/*.html |
825 |
%{_docdir}/%{name}/html/*.css |
826 |
%{_docdir}/%{name}/html/*.js |
827 |
%{_docdir}/%{name}/html/*.png |
828 |
%{_docdir}/%{name}/html/*.svg |
829 |
%{_docdir}/%{name}/html/*.woff |
830 |
%{_docdir}/%{name}/html/*.woff2 |
831 |
%license %{_docdir}/%{name}/html/*.txt |
832 |
%license %{_docdir}/%{name}/html/*.md |
833 |
|
834 |
|
835 |
%files -n cargo |
836 |
%license src/tools/cargo/LICENSE-APACHE src/tools/cargo/LICENSE-MIT src/tools/cargo/LICENSE-THIRD-PARTY |
837 |
%doc src/tools/cargo/README.md |
838 |
%{_bindir}/cargo |
839 |
%{_libexecdir}/cargo* |
840 |
%{_mandir}/man1/cargo*.1* |
841 |
%{_sysconfdir}/bash_completion.d/cargo |
842 |
%{_datadir}/zsh/site-functions/_cargo |
843 |
%dir %{_datadir}/cargo |
844 |
%dir %{_datadir}/cargo/registry |
845 |
|
846 |
|
847 |
%files -n cargo-doc |
848 |
%docdir %{_docdir}/cargo |
849 |
%dir %{_docdir}/cargo |
850 |
%{_docdir}/cargo/html |
851 |
|
852 |
|
853 |
%files -n rustfmt |
854 |
%{_bindir}/rustfmt |
855 |
%{_bindir}/cargo-fmt |
856 |
%doc src/tools/rustfmt/{README,CHANGELOG,Configurations}.md |
857 |
%license src/tools/rustfmt/LICENSE-{APACHE,MIT} |
858 |
|
859 |
|
860 |
%files -n rls |
861 |
%{_bindir}/rls |
862 |
%doc src/tools/rls/{README.md,COPYRIGHT,debugging.md} |
863 |
%license src/tools/rls/LICENSE-{APACHE,MIT} |
864 |
|
865 |
|
866 |
%files -n clippy |
867 |
%{_bindir}/cargo-clippy |
868 |
%{_bindir}/clippy-driver |
869 |
%doc src/tools/clippy/{README.md,CHANGELOG.md} |
870 |
%license src/tools/clippy/LICENSE-{APACHE,MIT} |
871 |
|
872 |
|
873 |
%files src |
874 |
%dir %{rustlibdir} |
875 |
%{rustlibdir}/src |
876 |
|
877 |
|
878 |
%files analysis |
879 |
%{rustlibdir}/%{rust_triple}/analysis/ |
880 |
%if %defined bootstrap_build_arch |
881 |
%{rustlibdir}/%{target_triple}/analysis/ |
882 |
%endif |