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