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