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