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