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