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 |
%global bootstrap_rust 1.21.0 |
17 |
%global bootstrap_cargo 0.22.0 |
18 |
%global bootstrap_channel %{bootstrap_rust} |
19 |
%global bootstrap_date 2017-10-12 |
20 |
|
21 |
# Only the specified arches will use bootstrap binaries. |
22 |
#global bootstrap_arches %%{rust_arches} |
23 |
|
24 |
# We generally don't want llvm-static present at all, since llvm-config will |
25 |
# make us link statically. But we can opt in, e.g. to aid LLVM rebases. |
26 |
# FIXME: LLVM 3.9 prefers shared linking now! Which is good, but next time we |
27 |
# *want* static we'll have to force it with "llvm-config --link-static". |
28 |
# See also https://github.com/rust-lang/rust/issues/36854 |
29 |
# The new rustbuild accepts `--enable-llvm-link-shared`, else links static. |
30 |
%bcond_with llvm_static |
31 |
|
32 |
# We can also choose to just use Rust's bundled LLVM, in case the system LLVM |
33 |
# is insufficient. Rust currently requires LLVM 3.7+. |
34 |
%if 0%{?mageia} || 0%{?rhel} && !0%{?epel} |
35 |
# (akien) FIXME before mga7 is released |
36 |
# Bundled LLVM has underlinking issues: |
37 |
# CMakeFiles/LLVMHello.dir/Hello.cpp.o: In function `llvm::FunctionPass::~FunctionPass()': |
38 |
# /home/iurt/rpmbuild/BUILD/rustc-1.22.1-src/src/llvm/include/llvm/Pass.h:298: undefined reference to `vtable for llvm::FunctionPass' |
39 |
# /home/iurt/rpmbuild/BUILD/rustc-1.22.1-src/src/llvm/include/llvm/Pass.h:298: undefined reference to `llvm::Pass::~Pass()' |
40 |
%global _disable_ld_no_undefined 1 |
41 |
%bcond_without bundled_llvm |
42 |
%else |
43 |
%bcond_with bundled_llvm |
44 |
%endif |
45 |
|
46 |
# LLDB only works on some architectures |
47 |
%ifarch %{arm} aarch64 %{ix86} x86_64 |
48 |
# LLDB isn't available everywhere... |
49 |
%if !0%{?rhel} |
50 |
%bcond_without lldb |
51 |
%else |
52 |
%bcond_with lldb |
53 |
%endif |
54 |
%else |
55 |
%bcond_with lldb |
56 |
%endif |
57 |
|
58 |
|
59 |
|
60 |
Name: rust |
61 |
Version: 1.22.1 |
62 |
Release: %mkrel 3 |
63 |
Summary: The Rust Programming Language |
64 |
%if 0%{?mageia} |
65 |
Group: Development/Other |
66 |
%endif |
67 |
License: (ASL 2.0 or MIT) and (BSD and ISC and MIT) |
68 |
# ^ written as: (rust itself) and (bundled libraries) |
69 |
URL: https://www.rust-lang.org |
70 |
ExclusiveArch: %{rust_arches} |
71 |
|
72 |
%if "%{channel}" == "stable" |
73 |
%global rustc_package rustc-%{version}-src |
74 |
%else |
75 |
%global rustc_package rustc-%{channel}-src |
76 |
%endif |
77 |
Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz |
78 |
|
79 |
Patch1: rust-1.22.0-45566-option-checking.patch |
80 |
|
81 |
# This patch has to be *reverted* on ix86 to work around |
82 |
# https://github.com/rust-lang/rust-installer/issues/75 |
83 |
Patch2: rust-installer-Create-xz-gz-files-in-parallel.patch |
84 |
|
85 |
# Get the Rust triple for any arch. |
86 |
%{lua: function rust_triple(arch) |
87 |
local abi = "gnu" |
88 |
if arch == "armv7hl" then |
89 |
arch = "armv7" |
90 |
abi = "gnueabihf" |
91 |
elseif arch == "ppc64" then |
92 |
arch = "powerpc64" |
93 |
elseif arch == "ppc64le" then |
94 |
arch = "powerpc64le" |
95 |
elseif arch == "i586" then |
96 |
arch = "i686" |
97 |
end |
98 |
return arch.."-unknown-linux-"..abi |
99 |
end} |
100 |
|
101 |
%global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))} |
102 |
|
103 |
%if %defined bootstrap_arches |
104 |
# For each bootstrap arch, add an additional binary Source. |
105 |
# Also define bootstrap_source just for the current target. |
106 |
%{lua: do |
107 |
local bootstrap_arches = {} |
108 |
for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do |
109 |
table.insert(bootstrap_arches, arch) |
110 |
end |
111 |
local base = rpm.expand("https://static.rust-lang.org/dist/%{bootstrap_date}" |
112 |
.."/rust-%{bootstrap_channel}") |
113 |
local target_arch = rpm.expand("%{_target_cpu}") |
114 |
for i, arch in ipairs(bootstrap_arches) do |
115 |
print(string.format("Source%d: %s-%s.tar.xz\n", |
116 |
i, base, rust_triple(arch))) |
117 |
if arch == target_arch then |
118 |
rpm.define("bootstrap_source "..i) |
119 |
end |
120 |
end |
121 |
end} |
122 |
%endif |
123 |
|
124 |
%ifarch %{bootstrap_arches} |
125 |
%global bootstrap_root rust-%{bootstrap_channel}-%{rust_triple} |
126 |
%global local_rust_root %{_builddir}/%{bootstrap_root}/usr |
127 |
Provides: bundled(%{name}-bootstrap) = %{bootstrap_rust} |
128 |
%else |
129 |
BuildRequires: cargo >= %{bootstrap_cargo} |
130 |
BuildRequires: %{name} >= %{bootstrap_rust} |
131 |
BuildConflicts: %{name} > %{version} |
132 |
%global local_rust_root %{_prefix} |
133 |
%endif |
134 |
|
135 |
BuildRequires: make |
136 |
BuildRequires: gcc |
137 |
BuildRequires: gcc-c++ |
138 |
BuildRequires: ncurses-devel |
139 |
BuildRequires: zlib-devel |
140 |
BuildRequires: python2 |
141 |
BuildRequires: curl |
142 |
|
143 |
%if %with bundled_llvm |
144 |
BuildRequires: cmake3 |
145 |
Provides: bundled(llvm) = 4.0 |
146 |
%else |
147 |
%if 0%{?epel} |
148 |
%global llvm llvm3.9 |
149 |
%endif |
150 |
%if 0%{?fedora} >= 28 |
151 |
%global llvm llvm4.0 |
152 |
%endif |
153 |
%if %defined llvm |
154 |
%global llvm_root %{_libdir}/%{llvm} |
155 |
%else |
156 |
%global llvm llvm |
157 |
%global llvm_root %{_prefix} |
158 |
%endif |
159 |
BuildRequires: %{llvm}-devel >= 3.7 |
160 |
%if %with llvm_static |
161 |
BuildRequires: %{llvm}-static |
162 |
BuildRequires: libffi-devel |
163 |
%else |
164 |
# Make sure llvm-config doesn't see it. |
165 |
BuildConflicts: %{llvm}-static |
166 |
%endif |
167 |
%endif |
168 |
|
169 |
# make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs |
170 |
BuildRequires: procps-ng |
171 |
|
172 |
# debuginfo-gdb tests need gdb |
173 |
BuildRequires: gdb |
174 |
|
175 |
# TODO: work on unbundling these! |
176 |
Provides: bundled(hoedown) = 3.0.5 |
177 |
Provides: bundled(jquery) = 2.1.4 |
178 |
Provides: bundled(libbacktrace) = 6.1.0 |
179 |
Provides: bundled(miniz) = 1.14 |
180 |
|
181 |
# Virtual provides for folks who attempt "dnf install rustc" |
182 |
Provides: rustc = %{version}-%{release} |
183 |
Provides: rustc%{?_isa} = %{version}-%{release} |
184 |
|
185 |
# Always require our exact standard library |
186 |
Requires: %{name}-std-static%{?_isa} = %{version}-%{release} |
187 |
|
188 |
# The C compiler is needed at runtime just for linking. Someday rustc might |
189 |
# invoke the linker directly, and then we'll only need binutils. |
190 |
# https://github.com/rust-lang/rust/issues/11937 |
191 |
%if 0%{?mageia} |
192 |
Requires: gcc |
193 |
%else |
194 |
Requires: /usr/bin/cc |
195 |
%endif |
196 |
|
197 |
# ALL Rust libraries are private, because they don't keep an ABI. |
198 |
%global _privatelibs lib.*-[[:xdigit:]]*[.]so.* |
199 |
%global __provides_exclude ^(%{_privatelibs})$ |
200 |
%global __requires_exclude ^(%{_privatelibs})$ |
201 |
%global __provides_exclude_from ^%{_docdir}/.*$ |
202 |
%global __requires_exclude_from ^%{_docdir}/.*$ |
203 |
|
204 |
# While we don't want to encourage dynamic linking to Rust shared libraries, as |
205 |
# there's no stable ABI, we still need the unallocated metadata (.rustc) to |
206 |
# support custom-derive plugins like #[proc_macro_derive(Foo)]. But eu-strip is |
207 |
# very eager by default, so we have to limit it to -g, only debugging symbols. |
208 |
%if 0%{?fedora} >= 27 || 0%{?mageia} >= 7 |
209 |
# Newer find-debuginfo.sh supports --keep-section, which is preferable. rhbz1465997 |
210 |
%global _find_debuginfo_opts --keep-section .rustc |
211 |
%else |
212 |
%global _find_debuginfo_opts -g |
213 |
%undefine _include_minidebuginfo |
214 |
%endif |
215 |
|
216 |
# Use hardening ldflags. |
217 |
%global rustflags -Clink-arg=-Wl,-z,relro,-z,now |
218 |
|
219 |
%if %{without bundled_llvm} && "%{llvm_root}" != "%{_prefix}" |
220 |
# https://github.com/rust-lang/rust/issues/40717 |
221 |
%global library_path $(%{llvm_root}/bin/llvm-config --libdir) |
222 |
%endif |
223 |
|
224 |
%description |
225 |
Rust is a systems programming language that runs blazingly fast, prevents |
226 |
segfaults, and guarantees thread safety. |
227 |
|
228 |
This package includes the Rust compiler and documentation generator. |
229 |
|
230 |
|
231 |
%package std-static |
232 |
Summary: Standard library for Rust |
233 |
|
234 |
%description std-static |
235 |
This package includes the standard libraries for building applications |
236 |
written in Rust. |
237 |
|
238 |
|
239 |
%package debugger-common |
240 |
Summary: Common debugger pretty printers for Rust |
241 |
BuildArch: noarch |
242 |
|
243 |
%description debugger-common |
244 |
This package includes the common functionality for %{name}-gdb and %{name}-lldb. |
245 |
|
246 |
|
247 |
%package gdb |
248 |
Summary: GDB pretty printers for Rust |
249 |
BuildArch: noarch |
250 |
Requires: gdb |
251 |
Requires: %{name}-debugger-common = %{version}-%{release} |
252 |
|
253 |
%if 0%{?mageia} == 6 |
254 |
# (akien) Handle moved files between our old Mageia package and this Fedora-based one |
255 |
Conflicts: rust < 1.11.0-3 |
256 |
%endif |
257 |
|
258 |
%description gdb |
259 |
This package includes the rust-gdb script, which allows easier debugging of Rust |
260 |
programs. |
261 |
|
262 |
|
263 |
%if %with lldb |
264 |
|
265 |
%package lldb |
266 |
Summary: LLDB pretty printers for Rust |
267 |
|
268 |
# It could be noarch, but lldb has limited availability |
269 |
#BuildArch: noarch |
270 |
|
271 |
Requires: lldb |
272 |
Requires: python-lldb |
273 |
Requires: %{name}-debugger-common = %{version}-%{release} |
274 |
|
275 |
%description lldb |
276 |
This package includes the rust-lldb script, which allows easier debugging of Rust |
277 |
programs. |
278 |
|
279 |
%endif |
280 |
|
281 |
|
282 |
%package doc |
283 |
Summary: Documentation for Rust |
284 |
# NOT BuildArch: noarch |
285 |
# Note, while docs are mostly noarch, some things do vary by target_arch. |
286 |
# Koji will fail the build in rpmdiff if two architectures build a noarch |
287 |
# subpackage differently, so instead we have to keep its arch. |
288 |
|
289 |
%description doc |
290 |
This package includes HTML documentation for the Rust programming language and |
291 |
its standard library. |
292 |
|
293 |
|
294 |
%package src |
295 |
Summary: Sources for the Rust standard library |
296 |
BuildArch: noarch |
297 |
|
298 |
%description src |
299 |
This package includes source files for the Rust standard library. It may be |
300 |
useful as a reference for code completion tools in various editors. |
301 |
|
302 |
|
303 |
%prep |
304 |
|
305 |
%ifarch %{bootstrap_arches} |
306 |
%setup -q -n %{bootstrap_root} -T -b %{bootstrap_source} |
307 |
./install.sh --components=cargo,rustc,rust-std-%{rust_triple} \ |
308 |
--prefix=%{local_rust_root} --disable-ldconfig |
309 |
test -f '%{local_rust_root}/bin/cargo' |
310 |
test -f '%{local_rust_root}/bin/rustc' |
311 |
%endif |
312 |
|
313 |
%setup -q -n %{rustc_package} |
314 |
|
315 |
# We're disabling jemalloc, but rust-src still wants it. |
316 |
# rm -rf src/jemalloc/ |
317 |
|
318 |
%if %without bundled_llvm |
319 |
rm -rf src/llvm/ |
320 |
%endif |
321 |
|
322 |
# extract bundled licenses for packaging |
323 |
cp src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown |
324 |
sed -e '/*\//q' src/libbacktrace/backtrace.h \ |
325 |
>src/libbacktrace/LICENSE-libbacktrace |
326 |
|
327 |
# This tests a problem of exponential growth, which seems to be less-reliably |
328 |
# fixed when running on older LLVM and/or some arches. Just skip it for now. |
329 |
sed -i.ignore -e '1i // ignore-test may still be exponential...' \ |
330 |
src/test/run-pass/issue-41696.rs |
331 |
|
332 |
%if %{with bundled_llvm} && 0%{?epel} |
333 |
mkdir -p cmake-bin |
334 |
ln -s /usr/bin/cmake3 cmake-bin/cmake |
335 |
%global cmake_path $PWD/cmake-bin |
336 |
%endif |
337 |
|
338 |
%if %{without bundled_llvm} && %{with llvm_static} |
339 |
# Static linking to distro LLVM needs to add -lffi |
340 |
# https://github.com/rust-lang/rust/issues/34486 |
341 |
sed -i.ffi -e '$a #[link(name = "ffi")] extern {}' \ |
342 |
src/librustc_llvm/lib.rs |
343 |
%endif |
344 |
|
345 |
%global _default_patch_fuzz 1 |
346 |
%patch1 -p1 -b .option-checking |
347 |
|
348 |
%ifarch %ix86 |
349 |
pushd src/tools/rust-installer |
350 |
%patch2 -p1 -R -b .revert-parallel-tarball |
351 |
popd |
352 |
%endif |
353 |
|
354 |
# The configure macro will modify some autoconf-related files, which upsets |
355 |
# cargo when it tries to verify checksums in those files. If we just truncate |
356 |
# that file list, cargo won't have anything to complain about. |
357 |
find src/vendor -name .cargo-checksum.json \ |
358 |
-exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+' |
359 |
|
360 |
|
361 |
%build |
362 |
|
363 |
%{?cmake_path:export PATH=%{cmake_path}:$PATH} |
364 |
%{?library_path:export LIBRARY_PATH="%{library_path}"} |
365 |
%{?rustflags:export RUSTFLAGS="%{rustflags}"} |
366 |
|
367 |
# We're going to override --libdir when configuring to get rustlib into a |
368 |
# common path, but we'll fix the shared libraries during install. |
369 |
%global common_libdir %{_prefix}/lib |
370 |
%global rustlibdir %{common_libdir}/rustlib |
371 |
|
372 |
%ifarch %{arm} |
373 |
# full debuginfo is exhausting memory; just do libstd for now |
374 |
# https://github.com/rust-lang/rust/issues/45854 |
375 |
%define enable_debuginfo --enable-debuginfo --enable-debuginfo-only-std --disable-debuginfo-lines |
376 |
%else |
377 |
%define enable_debuginfo --enable-debuginfo --disable-debuginfo-only-std --disable-debuginfo-lines |
378 |
%endif |
379 |
|
380 |
%configure --disable-option-checking \ |
381 |
--libdir=%{common_libdir} \ |
382 |
--build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \ |
383 |
--enable-local-rust --local-rust-root=%{local_rust_root} \ |
384 |
%{!?with_bundled_llvm: --llvm-root=%{llvm_root} --disable-codegen-tests \ |
385 |
%{!?with_llvm_static: --enable-llvm-link-shared } } \ |
386 |
--disable-jemalloc \ |
387 |
--disable-rpath \ |
388 |
%{enable_debuginfo} \ |
389 |
--enable-vendor \ |
390 |
--release-channel=%{channel} \ |
391 |
--enable-full-bootstrap |
392 |
|
393 |
./x.py build |
394 |
./x.py doc |
395 |
|
396 |
|
397 |
%install |
398 |
%{?cmake_path:export PATH=%{cmake_path}:$PATH} |
399 |
%{?library_path:export LIBRARY_PATH="%{library_path}"} |
400 |
%{?rustflags:export RUSTFLAGS="%{rustflags}"} |
401 |
|
402 |
DESTDIR=%{buildroot} ./x.py install |
403 |
DESTDIR=%{buildroot} ./x.py install src |
404 |
|
405 |
|
406 |
# Make sure the shared libraries are in the proper libdir |
407 |
%if "%{_libdir}" != "%{common_libdir}" |
408 |
mkdir -p %{buildroot}%{_libdir} |
409 |
find %{buildroot}%{common_libdir} -maxdepth 1 -type f -name '*.so' \ |
410 |
-exec mv -v -t %{buildroot}%{_libdir} '{}' '+' |
411 |
%endif |
412 |
|
413 |
# The shared libraries should be executable for debuginfo extraction. |
414 |
find %{buildroot}%{_libdir} -maxdepth 1 -type f -name '*.so' \ |
415 |
-exec chmod -v +x '{}' '+' |
416 |
|
417 |
# The libdir libraries are identical to those under rustlib/. It's easier on |
418 |
# library loading if we keep them in libdir, but we do need them in rustlib/ |
419 |
# to support dynamic linking for compiler plugins, so we'll symlink. |
420 |
(cd "%{buildroot}%{rustlibdir}/%{rust_triple}/lib" && |
421 |
find ../../../../%{_lib} -maxdepth 1 -name '*.so' \ |
422 |
-exec ln -v -f -s -t . '{}' '+') |
423 |
|
424 |
# Remove installer artifacts (manifests, uninstall scripts, etc.) |
425 |
find %{buildroot}%{rustlibdir} -maxdepth 1 -type f -exec rm -v '{}' '+' |
426 |
|
427 |
# FIXME: __os_install_post will strip the rlibs |
428 |
# -- should we find a way to preserve debuginfo? |
429 |
|
430 |
# Remove unwanted documentation files (we already package them) |
431 |
rm -f %{buildroot}%{_docdir}/%{name}/README.md |
432 |
rm -f %{buildroot}%{_docdir}/%{name}/COPYRIGHT |
433 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-APACHE |
434 |
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-MIT |
435 |
|
436 |
# Sanitize the HTML documentation |
437 |
find %{buildroot}%{_docdir}/%{name}/html -empty -delete |
438 |
find %{buildroot}%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+' |
439 |
|
440 |
%if %without lldb |
441 |
rm -f %{buildroot}%{_bindir}/rust-lldb |
442 |
rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py* |
443 |
%endif |
444 |
|
445 |
|
446 |
%check |
447 |
%{?cmake_path:export PATH=%{cmake_path}:$PATH} |
448 |
%{?library_path:export LIBRARY_PATH="%{library_path}"} |
449 |
%{?rustflags:export RUSTFLAGS="%{rustflags}"} |
450 |
|
451 |
# The results are not stable on koji, so mask errors and just log it. |
452 |
./x.py test --no-fail-fast || : |
453 |
|
454 |
|
455 |
%post -p /sbin/ldconfig |
456 |
%postun -p /sbin/ldconfig |
457 |
|
458 |
|
459 |
%files |
460 |
%license COPYRIGHT LICENSE-APACHE LICENSE-MIT |
461 |
%license src/libbacktrace/LICENSE-libbacktrace |
462 |
%license src/rt/hoedown/LICENSE-hoedown |
463 |
%doc README.md |
464 |
%{_bindir}/rustc |
465 |
%{_bindir}/rustdoc |
466 |
%{_libdir}/*.so |
467 |
%{_mandir}/man1/rustc.1* |
468 |
%{_mandir}/man1/rustdoc.1* |
469 |
%dir %{rustlibdir} |
470 |
%dir %{rustlibdir}/%{rust_triple} |
471 |
%dir %{rustlibdir}/%{rust_triple}/lib |
472 |
%{rustlibdir}/%{rust_triple}/lib/*.so |
473 |
|
474 |
|
475 |
%files std-static |
476 |
%dir %{rustlibdir} |
477 |
%dir %{rustlibdir}/%{rust_triple} |
478 |
%dir %{rustlibdir}/%{rust_triple}/lib |
479 |
%{rustlibdir}/%{rust_triple}/lib/*.rlib |
480 |
|
481 |
|
482 |
%files debugger-common |
483 |
%dir %{rustlibdir} |
484 |
%dir %{rustlibdir}/etc |
485 |
%{rustlibdir}/etc/debugger_*.py* |
486 |
|
487 |
|
488 |
%files gdb |
489 |
%{_bindir}/rust-gdb |
490 |
%{rustlibdir}/etc/gdb_*.py* |
491 |
|
492 |
|
493 |
%if %with lldb |
494 |
%files lldb |
495 |
%{_bindir}/rust-lldb |
496 |
%{rustlibdir}/etc/lldb_*.py* |
497 |
%endif |
498 |
|
499 |
|
500 |
%files doc |
501 |
%docdir %{_docdir}/%{name} |
502 |
%dir %{_docdir}/%{name} |
503 |
%dir %{_docdir}/%{name}/html |
504 |
%{_docdir}/%{name}/html/*/ |
505 |
%{_docdir}/%{name}/html/*.html |
506 |
%{_docdir}/%{name}/html/*.css |
507 |
%{_docdir}/%{name}/html/*.js |
508 |
%{_docdir}/%{name}/html/*.woff |
509 |
%license %{_docdir}/%{name}/html/*.txt |
510 |
|
511 |
|
512 |
%files src |
513 |
%dir %{rustlibdir} |
514 |
%{rustlibdir}/src |