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