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