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