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