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