/[packages]/cauldron/rust/current/SPECS/rust.spec
ViewVC logotype

Contents of /cauldron/rust/current/SPECS/rust.spec

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.30