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