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