]> git.pld-linux.org Git - packages/rust.git/blob - rust.spec
- update libgit2 BRs
[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.55.0
26 %define         bootstrap_cargo 1.55.0
27 %define         bootstrap_date  2021-09-09
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.56.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:  3ad94ba9f05779800a5da6c02e00c444
47 Source1:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
48 # Source1-md5:  59b0a04436f96250a307086b6fc2ce34
49 Source2:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
50 # Source2-md5:  693c87cf2fc1a41169f55fdbf8426a2e
51 Source3:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
52 # Source3-md5:  475f762804d4ad8695029a70f8b93a6d
53 Source4:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
54 # Source4-md5:  56a568e97e7a5c3cb80569ab84f4657b
55 Source5:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-armv7-unknown-linux-gnueabihf.tar.xz
56 # Source5-md5:  991a439bcdcbcf1b2bbe55ce9e90404f
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.3.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.3.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.3.0
101 BuildRequires:  libgit2-devel(x86-x32) >= 1.3.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 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
367 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
368         src/etc/rust-gdb
369
370 # cargo has hardcoded libexec path - honour rpm _libexecdir
371 %if "%{_libexecdir}" != "%{_prefix}/libexec"
372 suffix="%(echo "%{_libexecdir}" | %{__sed} -e 's,^%{_prefix}/,,')"
373 %{__sed} -i -e 's,"libexec","'${suffix}'",' \
374         src/bootstrap/dist.rs \
375         src/tools/cargo/src/cargo/ops/registry/auth.rs
376 %{__sed} -i -e 's,libexec/,'${suffix}'/,' src/tools/cargo/tests/testsuite/credential_process.rs
377 %endif
378
379 # The configure macro will modify some autoconf-related files, which upsets
380 # cargo when it tries to verify checksums in those files.  If we just truncate
381 # that file list, cargo won't have anything to complain about.
382 find vendor -name .cargo-checksum.json \
383         -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
384
385 %build
386 %configure \
387         --build=%{rust_bootstrap_triple} \
388         --host=%{rust_host_triple} \
389         --target=%{rust_triple} \
390         --libdir=%{common_libdir} \
391         --disable-codegen-tests \
392         --disable-debuginfo-lines \
393 %if %{with full_debuginfo}
394         --disable-debuginfo-only-std \
395         --enable-debuginfo \
396 %else
397         --enable-debuginfo-only-std \
398         --disable-debuginfo \
399 %endif
400         --disable-jemalloc \
401         --disable-option-checking \
402         --disable-rpath \
403         --enable-extended \
404         --enable-llvm-link-shared \
405         --enable-vendor \
406         --local-rust-root=%{local_rust_root} \
407         --llvm-root=%{_prefix} \
408         --release-channel=%{channel}
409
410 export RUST_BACKTRACE=full
411 %x_py dist --verbose
412
413 %{?with_tests:%x_py test}
414
415 %install
416 rm -rf $RPM_BUILD_ROOT
417
418 export DESTDIR=$RPM_BUILD_ROOT
419 %x_py install
420
421 # Make sure the shared libraries are in the proper libdir
422 %if "%{_libdir}" != "%{common_libdir}"
423 mkdir -p %{buildroot}%{_libdir}
424 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
425         -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
426 %endif
427
428 # The shared libraries should be executable for debuginfo extraction.
429 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -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 for l in libstd libtest ; do
435         liblib=$RPM_BUILD_ROOT%{_libdir}/${l}-*.so
436         libstd=$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib/${l}-*.so
437         if [ "$(basename ${liblib})" = "$(basename ${libstd})" ]; then
438                 ln -vfsr ${libstd} $RPM_BUILD_ROOT%{_libdir}/
439         fi
440 done
441
442 # Remove installer artifacts (manifests, uninstall scripts, etc.)
443 find $RPM_BUILD_ROOT%{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} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
450 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
451 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
452 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
453
454 # Sanitize the HTML documentation
455 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
456 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
457
458 # Move rust-gdb's python scripts so they're noarch
459 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
460 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
461
462 # We don't need stdlib source
463 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
464
465 # Create the path for crate-devel packages
466 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
467
468 %clean
469 rm -rf $RPM_BUILD_ROOT
470
471 %post   -p /sbin/ldconfig
472 %postun -p /sbin/ldconfig
473
474 %files
475 %defattr(644,root,root,755)
476 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md
477 %attr(755,root,root) %{_bindir}/rustc
478 %attr(755,root,root) %{_bindir}/rustdoc
479 %attr(755,root,root) %{_bindir}/rustfmt
480 %attr(755,root,root) %{_libdir}/librustc_driver-*.so
481 %attr(755,root,root) %{_libdir}/libstd-*.so
482 %attr(755,root,root) %{_libdir}/libtest-*.so
483 %{_mandir}/man1/rustc.1*
484 %{_mandir}/man1/rustdoc.1*
485 %dir %{rustlibdir}
486
487 %files analysis
488 %defattr(644,root,root,755)
489 %{rustlibdir}/%{rust_triple}/analysis
490
491 %files std
492 %defattr(644,root,root,755)
493 %dir %{rustlibdir}/%{rust_triple}
494 %dir %{rustlibdir}/%{rust_triple}/lib
495 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
496 %{rustlibdir}/%{rust_triple}/lib/*.rlib
497
498 %files debugger-common
499 %defattr(644,root,root,755)
500 %dir %{_datadir}/%{name}
501 %dir %{_datadir}/%{name}/etc
502 %{_datadir}/%{name}/etc/lldb_commands
503 %{_datadir}/%{name}/etc/rust_types.py
504
505 %files lldb
506 %defattr(644,root,root,755)
507 %attr(755,root,root) %{_bindir}/rust-lldb
508 %{_datadir}/%{name}/etc/lldb_*.py*
509
510 %files gdb
511 %defattr(644,root,root,755)
512 %attr(755,root,root) %{_bindir}/rust-gdb
513 %attr(755,root,root) %{_bindir}/rust-gdbgui
514 %{_datadir}/%{name}/etc/gdb_*.py*
515
516 %files rls
517 %defattr(644,root,root,755)
518 %attr(755,root,root) %{_bindir}/rls
519
520 %files doc
521 %defattr(644,root,root,755)
522 %dir %{_docdir}/%{name}
523 %doc %{_docdir}/%{name}/html
524
525 %files -n cargo
526 %defattr(644,root,root,755)
527 %attr(755,root,root) %{_bindir}/cargo
528 %attr(755,root,root) %{_bindir}/cargo-clippy
529 %attr(755,root,root) %{_bindir}/cargo-fmt
530 %attr(755,root,root) %{_bindir}/clippy-driver
531 %attr(755,root,root) %{_libexecdir}/cargo-credential-1password
532 %{_mandir}/man1/cargo*.1*
533 %dir %{_datadir}/cargo
534 %dir %{_datadir}/cargo/registry
535
536 %files -n bash-completion-cargo
537 %defattr(644,root,root,755)
538 %{_sysconfdir}/bash_completion.d/cargo
539
540 %files -n zsh-completion-cargo
541 %defattr(644,root,root,755)
542 %{zsh_compdir}/_cargo
This page took 0.114826 seconds and 4 git commands to generate.