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