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