]> git.pld-linux.org Git - packages/rust.git/blob - rust.spec
backport fixes to disable miri and analyzer; rel 2
[packages/rust.git] / rust.spec
1 # TODO
2 # - consider a rust-std package containing .../rustlib/$target
3 #   This might allow multilib cross-compilation to work naturally.
4 # - package additional tools
5 #
6 # Conditional build:
7 %bcond_with     bootstrap       # bootstrap using precompiled binaries
8 %bcond_with     full_debuginfo  # full debuginfo vs only std debuginfo (full takes gigabytes of memory to build)
9 %bcond_without  system_llvm     # system LLVM
10 %bcond_with     tests           # build without tests
11
12 # The channel can be stable, beta, or nightly
13 %define         channel         stable
14
15 %if "%{channel}" == "stable"
16 %define         rustc_package   rustc-%{version}-src
17 %else
18 %define         rustc_package   rustc-%{channel}-src
19 %endif
20
21 # To bootstrap from scratch, set the channel and date from src/stage0.txt
22 # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
23 # or nightly wants some beta-YYYY-MM-DD
24 %define         bootstrap_rust  1.52.0
25 %define         bootstrap_cargo 1.52.0
26 %define         bootstrap_date  2021-05-06
27
28 %ifarch x32
29 %define         with_cross      1
30 %endif
31
32 %if %{without full_debuginfo}
33 %define         _enable_debug_packages  0
34 %endif
35
36 Summary:        The Rust Programming Language
37 Summary(pl.UTF-8):      Język programowania Rust
38 Name:           rust
39 Version:        1.53.0
40 Release:        2
41 # Licenses: (rust itself) and (bundled libraries)
42 License:        (Apache v2.0 or MIT) and (BSD and ISC and MIT)
43 Group:          Development/Languages
44 Source0:        https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
45 # Source0-md5:  2c552dc35afd41ac7294637a7e85f1a3
46 Source1:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
47 # Source1-md5:  5451acacf06d3eed947fdfa7eb96d0e8
48 Source2:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
49 # Source2-md5:  136df423e63932ed02d18e9ba7923537
50 Source3:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
51 # Source3-md5:  2868d64a0ec681f3fe2bb59e20569d26
52 Source4:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
53 # Source4-md5:  e36ad0e20aef949b4335cf2599a136bb
54 Source5:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-armv7-unknown-linux-gnueabihf.tar.xz
55 # Source5-md5:  77d28773b9fa07979a075e5232b23ac7
56 Patch0:         disable_miri.patch
57 URL:            https://www.rust-lang.org/
58 # for src/compiler-rt
59 BuildRequires:  cmake >= 3.4.3
60 BuildRequires:  curl
61 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
62 BuildRequires:  procps
63 BuildRequires:  python >= 1:2.7
64 BuildRequires:  rpmbuild(macros) >= 1.752
65 %if %{without cross}
66 BuildRequires:  curl-devel
67 BuildRequires:  libgit2-devel >= 1.1.0
68 BuildRequires:  libstdc++-devel
69 %{?with_system_llvm:BuildRequires:      llvm-devel >= 10.0}
70 BuildRequires:  openssl-devel >= 1.0.1
71 BuildRequires:  tar >= 1:1.22
72 BuildRequires:  xz
73 BuildRequires:  zlib-devel
74 %endif
75 %if %{without bootstrap}
76 BuildRequires:  %{name} >= %{bootstrap_rust}
77 BuildRequires:  cargo >= %{bootstrap_cargo}
78 BuildConflicts: %{name} > %{version}
79 %endif
80 %ifarch x32
81 BuildRequires:  glibc-devel(x86-64)
82 BuildRequires:  glibc-devel(x86-x32)
83 %if "%{_host_cpu}" == "x86_64"
84 # building on x86_64 host with --target x32-pld-linux
85 BuildRequires:  curl-devel
86 BuildRequires:  gcc-multilib-x32
87 BuildRequires:  libgit2-devel >= 1.1.0
88 BuildRequires:  libstdc++-devel
89 %{?with_system_llvm:BuildRequires:      llvm-devel >= 10.0}
90 BuildRequires:  openssl-devel >= 1.0.1
91 BuildRequires:  zlib-devel
92 %else
93 # building x86_64-hosted crosscompiler on x32 host
94 BuildRequires:  curl-devel(x86-64)
95 BuildRequires:  curl-devel(x86-x32)
96 BuildRequires:  gcc-multilib-64
97 BuildRequires:  libgit2-devel(x86-64) >= 1.1.0
98 BuildRequires:  libgit2-devel(x86-x32) >= 1.1.0
99 BuildRequires:  libstdc++-multilib-64-devel
100 %if %{with system_llvm}
101 BuildRequires:  llvm-devel(x86-64) >= 10.0
102 BuildRequires:  llvm-devel(x86-x32) >= 10.0
103 %endif
104 BuildRequires:  openssl-devel(x86-64)
105 BuildRequires:  openssl-devel(x86-x32)
106 BuildRequires:  zlib-devel(x86-64)
107 BuildRequires:  zlib-devel(x86-x32)
108 %endif
109 %endif
110 # The C compiler is needed at runtime just for linking.  Someday rustc might
111 # invoke the linker directly, and then we'll only need binutils.
112 # https://github.com/rust-lang/rust/issues/11937
113 Requires:       gcc
114 Requires:       %{name}-std%{?_isa} = %{version}-%{release}
115 %ifarch x32
116 Requires:       %{name}-std(x86-64) = %{version}-%{release}
117 %endif
118 Obsoletes:      rust-analyzer < 1.53.0
119 # Only x86_64 and i686 are Tier 1 platforms at this time.
120 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
121 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
122 ExclusiveArch:  %{x8664} %{ix86} x32 aarch64 armv6hl armv7hl armv7hnl
123 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
124
125 %ifarch x32
126 %define         rust_triple             x86_64-unknown-linux-gnux32
127 %define         rust_host_triple        x86_64-unknown-linux-gnu
128 %define         rust_bootstrap_triple   x86_64-unknown-linux-gnu
129 # libs in _libdir are x86_64 64bit
130 %define         _lib                    lib64
131 %define         _libdir                 %{_prefix}/lib64
132 %else
133 %ifarch armv6hl
134 %define         rust_triple             arm-unknown-linux-gnueabihf
135 %define         rust_host_triple        %{rust_triple}
136 %define         rust_bootstrap_triple   %{rust_triple}
137 %else
138 %ifarch armv7hl armv7hnl
139 %define         rust_triple             armv7-unknown-linux-gnueabihf
140 %define         rust_host_triple        %{rust_triple}
141 %define         rust_bootstrap_triple   %{rust_triple}
142 %else
143 %define         rust_triple             %{_target_cpu}-unknown-linux-gnu
144 %define         rust_host_triple        %{rust_triple}
145 %define         rust_bootstrap_triple   %{rust_triple}
146 %endif
147 %endif
148 %endif
149
150 %if %{without bootstrap}
151 %define         local_rust_root %{_prefix}
152 %else
153 %define         bootstrap_root  rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
154 %define         local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
155 %endif
156
157 # We're going to override --libdir when configuring to get rustlib into a
158 # common path, but we'll fix the shared libraries during install.
159 # Without this ugly hack, rust would not be able to build itself
160 # for non-bootstrap build, lib64 is just too complicated for it.
161 %define         common_libdir   %{_prefix}/lib
162 %define         rustlibdir      %{common_libdir}/rustlib
163
164 # once_call/once_callable non-function libstdc++ symbols
165 %define         skip_post_check_so      'librustc.*llvm.*\.so.*'
166
167 # ALL Rust libraries are private, because they don't keep an ABI.
168 %define         _noautoreqfiles         lib.*-[[:xdigit:]]{8}[.]so.*
169 %define         _noautoprovfiles        lib.*-[[:xdigit:]]{8}[.]so.*
170
171 %define         x_py { \
172         x_py() { \
173                 local cmd="$1"; \
174                 shift; \
175                 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
176         }; x_py }
177
178
179 %description
180 Rust is a systems programming language that runs blazingly fast,
181 prevents segfaults, and guarantees thread safety.
182
183 This package includes the Rust compiler, standard library, and
184 documentation generator.
185
186 %description -l pl.UTF-8
187 Rust to systemowy język programowania działający bardzo szybko,
188 zapobiegający naruszeniom ochrony pamięci i gwarantujący
189 bezpieczną wielowątkowość.
190
191 %package analysis
192 Summary:        Metadata about the standard library
193 Summary(pl.UTF-8):      Metadane o standardowej bibliotece
194 Group:          Development/Tools
195 Requires:       %{name} = %{version}-%{release}
196
197 %description analysis
198 Metadata about the standard library.
199
200 %description analysis -l pl.UTF-8
201 Metadane o standardowej bibliotece.
202
203 %package std
204 Summary:        Standard library for Rust
205 Summary(pl.UTF-8):      Standardowa biblioteka Rusta
206 Group:          Development/Tools
207 Requires:       %{name} = %{version}-%{release}
208
209 %description std
210 Standard library for Rust.
211
212 %description std -l pl.UTF-8
213 Standardowa biblioteka Rusta.
214
215 %package debugger-common
216 Summary:        Common debugger pretty printers for Rust
217 Summary(pl.UTF-8):      Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
218 Group:          Development/Debuggers
219 BuildArch:      noarch
220
221 %description debugger-common
222 This package includes the common functionality for rust-gdb and
223 rust-lldb.
224
225 %description debugger-common -l pl.UTF-8
226 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
227
228 %package gdb
229 Summary:        GDB pretty printers for Rust
230 Summary(pl.UTF-8):      Ładne wypisywanie struktur Rusta w GDB
231 Group:          Development/Debuggers
232 Requires:       %{name}-debugger-common = %{version}-%{release}
233 Requires:       gdb
234 BuildArch:      noarch
235
236 %description gdb
237 This package includes the rust-gdb script, which allows easier
238 debugging of Rust programs.
239
240 %description gdb -l pl.UTF-8
241 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
242 odpluskwianie programów w języku Rust.
243
244 %package lldb
245 Summary:        LLDB pretty printers for Rust
246 Summary(pl.UTF-8):      Ładne wypisywanie struktur Rusta w LLDB
247 Group:          Development/Debuggers
248 Requires:       %{name}-debugger-common = %{version}-%{release}
249 Requires:       lldb
250 BuildArch:      noarch
251
252 %description lldb
253 This package includes the rust-lldb script, which allows easier
254 debugging of Rust programs.
255
256 %description lldb -l pl.UTF-8
257 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
258 odpluskwianie programów w języku Rust.
259
260 %package rls
261 Summary:        Rust Language Server for IDE integration
262 Summary(pl.UTF-8):      Rust Language Server do integracji z IDE
263 Group:          Development/Tools
264 Requires:       %{name} = %{version}-%{release}
265 Requires:       %{name}-analysis = %{version}-%{release}
266
267 %description rls
268 Rust Language Server for IDE integration.
269
270 %description rls -l pl.UTF-8
271 Rust Language Server do integracji z IDE.
272
273 %package doc
274 Summary:        Documentation for Rust
275 Summary(pl.UTF-8):      Dokumentacja do Rusta
276 Group:          Documentation
277 BuildArch:      noarch
278
279 %description doc
280 This package includes HTML documentation for the Rust programming
281 language and its standard library.
282
283 %description doc -l pl.UTF-8
284 Ten pakiet zawiera dokumentację w formacie HTML do języka
285 programowania Rust i jego biblioteki standardowej.
286
287 %package -n cargo
288 Summary:        Rust's package manager and build tool
289 Summary(pl.UTF-8):      Zarządca pakietów i narzędzie do budowania
290 Group:          Development/Tools
291 Requires:       %{name}%{?_isa}
292
293 %description -n cargo
294 Cargo is a tool that allows Rust projects to declare their various
295 dependencies and ensure that you'll always get a repeatable build.
296
297 %description -n cargo -l pl.UTF-8
298 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
299 zależności i zapewniające powtarzalność procesu budowania.
300
301 %package -n bash-completion-cargo
302 Summary:        Bash completion for cargo command
303 Summary(pl.UTF-8):      Bashowe dopełnianie parametrów polecenia cargo
304 Group:          Applications/Shells
305 Requires:       %{name} = %{version}-%{release}
306 Requires:       bash-completion
307
308 %description -n bash-completion-cargo
309 Bash completion for cargo command.
310
311 %description -n bash-completion-cargo -l pl.UTF-8
312 Bashowe dopełnianie parametrów polecenia cargo.
313
314 %package -n zsh-completion-cargo
315 Summary:        Zsh completion for cargo command
316 Summary(pl.UTF-8):      Dopełnianie parametrów polecenia cargo w powłoce Zsh
317 Group:          Applications/Shells
318 Requires:       %{name} = %{version}-%{release}
319 Requires:       zsh
320
321 %description -n zsh-completion-cargo
322 Zsh completion for cargo command.
323
324 %description -n zsh-completion-cargo -l pl.UTF-8
325 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
326
327 %prep
328 %setup -q -n %{rustc_package}
329 %patch0 -p1
330
331 %if %{with bootstrap}
332 %ifarch %{x8664} x32
333 tar xf %{SOURCE1}
334 %endif
335 %ifarch %{ix86}
336 tar xf %{SOURCE2}
337 %endif
338 %ifarch aarch64
339 tar xf %{SOURCE3}
340 %endif
341 %ifarch armv6hl
342 tar xf %{SOURCE4}
343 %endif
344 %ifarch armv7hl armv7hnl
345 tar xf %{SOURCE5}
346 %endif
347 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
348 %{bootstrap_root}-root/install.sh \
349         --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
350         --prefix=%{local_rust_root} \
351         --disable-ldconfig
352 test -f %{local_rust_root}/bin/cargo
353 test -f %{local_rust_root}/bin/rustc
354 %endif
355
356 # unbundle
357 # We're disabling jemalloc, but rust-src still wants it.
358 #%{__rm} -r src/jemalloc
359 %if %{with system_llvm}
360 %{__rm} -r src/llvm-project
361 mkdir -p src/llvm-project/libunwind
362 %endif
363
364 # extract bundled licenses for packaging
365 sed -e '/*\//q' library/backtrace/crates/backtrace-sys/src/libbacktrace/backtrace.h \
366         >library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
367
368 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
369 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
370         src/etc/rust-gdb
371
372 # The configure macro will modify some autoconf-related files, which upsets
373 # cargo when it tries to verify checksums in those files.  If we just truncate
374 # that file list, cargo won't have anything to complain about.
375 find vendor -name .cargo-checksum.json \
376         -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
377
378 %build
379 %configure \
380         --build=%{rust_bootstrap_triple} \
381         --host=%{rust_host_triple} \
382         --target=%{rust_triple} \
383         --libdir=%{common_libdir} \
384         --disable-codegen-tests \
385         --disable-debuginfo-lines \
386 %if %{with full_debuginfo}
387         --disable-debuginfo-only-std \
388         --enable-debuginfo \
389 %else
390         --enable-debuginfo-only-std \
391         --disable-debuginfo \
392 %endif
393         --disable-jemalloc \
394         --disable-option-checking \
395         --disable-rpath \
396         --enable-extended \
397         --enable-llvm-link-shared \
398         --enable-vendor \
399         --local-rust-root=%{local_rust_root} \
400         --llvm-root=%{_prefix} \
401         --release-channel=%{channel}
402
403 export RUST_BACKTRACE=full
404 %x_py dist --verbose
405
406 %{?with_tests:%x_py test}
407
408 %install
409 rm -rf $RPM_BUILD_ROOT
410
411 export DESTDIR=$RPM_BUILD_ROOT
412 %x_py install
413
414 # Make sure the shared libraries are in the proper libdir
415 %if "%{_libdir}" != "%{common_libdir}"
416 mkdir -p %{buildroot}%{_libdir}
417 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
418         -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
419 %endif
420
421 # The shared libraries should be executable for debuginfo extraction.
422 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
423
424 # The libdir libraries are identical to those under rustlib/.  It's easier on
425 # library loading if we keep them in libdir, but we do need them in rustlib/
426 # to support dynamic linking for compiler plugins, so we'll symlink.
427 for l in libstd libtest ; do
428         liblib=$RPM_BUILD_ROOT%{_libdir}/${l}-*.so
429         libstd=$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib/${l}-*.so
430         if [ "$(basename ${liblib})" = "$(basename ${libstd})" ]; then
431                 ln -vfsr ${libstd} $RPM_BUILD_ROOT%{_libdir}/
432         fi
433 done
434
435 # Remove installer artifacts (manifests, uninstall scripts, etc.)
436 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
437
438 # FIXME: __os_install_post will strip the rlibs
439 # -- should we find a way to preserve debuginfo?
440
441 # Remove unwanted documentation files (we already package them)
442 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
443 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
444 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
445 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
446
447 # Sanitize the HTML documentation
448 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
449 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
450
451 # Move rust-gdb's python scripts so they're noarch
452 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
453 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
454
455 # We don't need stdlib source
456 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
457
458 # Create the path for crate-devel packages
459 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
460
461 %clean
462 rm -rf $RPM_BUILD_ROOT
463
464 %post   -p /sbin/ldconfig
465 %postun -p /sbin/ldconfig
466
467 %files
468 %defattr(644,root,root,755)
469 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
470 %attr(755,root,root) %{_bindir}/rustc
471 %attr(755,root,root) %{_bindir}/rustdoc
472 %attr(755,root,root) %{_bindir}/rustfmt
473 %attr(755,root,root) %{_libdir}/librustc_driver-*.so
474 %attr(755,root,root) %{_libdir}/libstd-*.so
475 %attr(755,root,root) %{_libdir}/libtest-*.so
476 %{_mandir}/man1/rustc.1*
477 %{_mandir}/man1/rustdoc.1*
478 %dir %{rustlibdir}
479
480 %files analysis
481 %defattr(644,root,root,755)
482 %{rustlibdir}/%{rust_triple}/analysis
483
484 %files std
485 %defattr(644,root,root,755)
486 %dir %{rustlibdir}/%{rust_triple}
487 %dir %{rustlibdir}/%{rust_triple}/lib
488 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
489 %{rustlibdir}/%{rust_triple}/lib/*.rlib
490
491 %files debugger-common
492 %defattr(644,root,root,755)
493 %dir %{_datadir}/%{name}
494 %dir %{_datadir}/%{name}/etc
495 %{_datadir}/%{name}/etc/lldb_commands
496 %{_datadir}/%{name}/etc/rust_types.py
497
498 %files lldb
499 %defattr(644,root,root,755)
500 %attr(755,root,root) %{_bindir}/rust-lldb
501 %{_datadir}/%{name}/etc/lldb_*.py*
502
503 %files gdb
504 %defattr(644,root,root,755)
505 %attr(755,root,root) %{_bindir}/rust-gdb
506 %attr(755,root,root) %{_bindir}/rust-gdbgui
507 %{_datadir}/%{name}/etc/gdb_*.py*
508
509 %files rls
510 %defattr(644,root,root,755)
511 %attr(755,root,root) %{_bindir}/rls
512
513 %files doc
514 %defattr(644,root,root,755)
515 %dir %{_docdir}/%{name}
516 %doc %{_docdir}/%{name}/html
517
518 %files -n cargo
519 %defattr(644,root,root,755)
520 %attr(755,root,root) %{_bindir}/cargo
521 %attr(755,root,root) %{_bindir}/cargo-clippy
522 %attr(755,root,root) %{_bindir}/cargo-fmt
523 %attr(755,root,root) %{_bindir}/clippy-driver
524 %attr(755,root,root) %{_libexecdir}/cargo-credential-1password
525 %{_mandir}/man1/cargo*.1*
526 %dir %{_datadir}/cargo
527 %dir %{_datadir}/cargo/registry
528
529 %files -n bash-completion-cargo
530 %defattr(644,root,root,755)
531 %{_sysconfdir}/bash_completion.d/cargo
532
533 %files -n zsh-completion-cargo
534 %defattr(644,root,root,755)
535 %{zsh_compdir}/_cargo
This page took 0.058616 seconds and 4 git commands to generate.