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