]> git.pld-linux.org Git - packages/rust.git/blame - rust.spec
respect configured number of parallel jobs
[packages/rust.git] / rust.spec
CommitLineData
e361528e
ER
1# TODO
2# - consider a rust-std package containing .../rustlib/$target
3# This might allow multilib cross-compilation to work naturally.
8a758d34 4# - package additional tools
e361528e
ER
5#
6# Conditional build:
e8f16183 7%bcond_with bootstrap # bootstrap using precompiled binaries
398b58dd 8%bcond_with full_debuginfo # full debuginfo vs only std debuginfo (full takes gigabytes of memory to build)
5b9d67b0 9%bcond_without system_llvm # system LLVM
badbe44d
JB
10%bcond_without rustc # rustc building
11%bcond_without cargo # cargo building
cace5bf9 12%bcond_with tests # build without tests
e361528e 13
8a073211
JR
14# The channel can be stable, beta, or nightly
15%define channel stable
16
e361528e 17%if "%{channel}" == "stable"
8a073211 18%define rustc_package rustc-%{version}-src
e361528e 19%else
8a073211 20%define rustc_package rustc-%{channel}-src
e361528e
ER
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
e901a823
JP
26%define bootstrap_rust 1.41.1
27%define bootstrap_cargo 1.41.0
28%define bootstrap_date 2020-02-27
e361528e 29
badbe44d
JB
30%ifarch x32
31%undefine with_cargo
32%undefine with_rustc
33%endif
e361528e 34Summary: The Rust Programming Language
e8f16183 35Summary(pl.UTF-8): Język programowania Rust
e361528e 36Name: rust
e901a823 37Version: 1.42.0
31742117 38Release: 3
d1b96fd8 39# Licenses: (rust itself) and (bundled libraries)
e8f16183 40License: (Apache v2.0 or MIT) and (BSD and ISC and MIT)
e361528e 41Group: Development/Languages
be28e1f1 42Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
e901a823 43# Source0-md5: 03a6111956f8d3bfdfc21aedce7f06bc
be28e1f1 44Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
e901a823 45# Source1-md5: 3336c39311a33005d51298c60b99f2c1
be28e1f1 46Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
e901a823 47# Source2-md5: be3f4d5143483c754a3c272eb213cd07
be28e1f1 48Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-std-%{bootstrap_rust}-x86_64-unknown-linux-gnux32.tar.xz
e901a823 49# Source3-md5: 38da0bf057e0801669f18f74555830bf
e361528e 50URL: https://www.rust-lang.org/
e8f16183
JB
51# for src/compiler-rt
52BuildRequires: cmake >= 3.4.3
e361528e 53BuildRequires: curl
d1b96fd8 54BuildRequires: libstdc++-devel
7da6653d
JB
55%{?with_system_llvm:BuildRequires: llvm-devel >= 7.0}
56BuildRequires: openssl-devel >= 1.0.1
e8f16183 57BuildRequires: python >= 1:2.7
e361528e
ER
58BuildRequires: zlib-devel
59%if %{without bootstrap}
d6d4cb2b 60BuildRequires: %{name} >= %{bootstrap_rust}
d1b96fd8 61BuildRequires: cargo >= %{bootstrap_cargo}
ff5a5e0b 62BuildConflicts: %{name} > %{version}
e361528e
ER
63%endif
64# make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
65BuildRequires: procps
e361528e
ER
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
69Requires: gcc
e361528e 70# Only x86_64 and i686 are Tier 1 platforms at this time.
badbe44d 71# x32 is Tier 2, only rust-std is available (no rustc or cargo).
e361528e 72# https://doc.rust-lang.org/stable/book/getting-started.html#tier-1
badbe44d 73ExclusiveArch: %{x8664} %{ix86} x32
6ed79af8 74BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
e361528e 75
e064fbd0 76%ifarch x32
badbe44d
JB
77%define rust_triple x86_64-unknown-linux-gnux32
78%define rust_bootstrap_triple x86_64-unknown-linux-gnu
e064fbd0 79%else
badbe44d
JB
80%define rust_triple %{_target_cpu}-unknown-linux-gnu
81%define rust_bootstrap_triple %{_target_cpu}-unknown-linux-gnu
e064fbd0 82%endif
e361528e
ER
83
84%if %{without bootstrap}
8a073211 85%define local_rust_root %{_prefix}
e361528e 86%else
badbe44d 87%define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
8a073211 88%define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
e361528e
ER
89%endif
90
18a1004b
JR
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.
5b9d67b0 93# Without this ugly hack, rust would not be able to build itself
18a1004b
JR
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
19f98749 98# once_call/once_callable non-function libstdc++ symbols
8f4c23f4 99%define skip_post_check_so 'librustc.*llvm.*\.so.*'
19f98749 100
e361528e 101# ALL Rust libraries are private, because they don't keep an ABI.
8a073211
JR
102%define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
103%define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
e361528e 104
37765656
JP
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
e361528e
ER
113%description
114Rust is a systems programming language that runs blazingly fast,
115prevents segfaults, and guarantees thread safety.
116
117This package includes the Rust compiler, standard library, and
118documentation generator.
119
e8f16183
JB
120%description -l pl.UTF-8
121Rust to systemowy język programowania działający bardzo szybko,
122zapobiegający naruszeniom ochrony pamięci i gwarantujący
123bezpieczną wielowątkowość.
124
d1b96fd8
JR
125%package debugger-common
126Summary: Common debugger pretty printers for Rust
e8f16183 127Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
d1b96fd8
JR
128Group: Development/Debuggers
129BuildArch: noarch
130
131%description debugger-common
e8f16183
JB
132This package includes the common functionality for rust-gdb and
133rust-lldb.
134
135%description debugger-common -l pl.UTF-8
136Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
d1b96fd8 137
e361528e
ER
138%package gdb
139Summary: GDB pretty printers for Rust
e8f16183 140Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
d1b96fd8
JR
141Group: Development/Debuggers
142Requires: %{name}-debugger-common = %{version}-%{release}
e361528e 143Requires: gdb
e361528e 144BuildArch: noarch
e361528e
ER
145
146%description gdb
147This package includes the rust-gdb script, which allows easier
148debugging of Rust programs.
149
e8f16183
JB
150%description gdb -l pl.UTF-8
151Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
152odpluskwianie programów w języku Rust.
153
d1b96fd8
JR
154%package lldb
155Summary: LLDB pretty printers for Rust
e8f16183 156Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
d1b96fd8
JR
157Group: Development/Debuggers
158Requires: %{name}-debugger-common = %{version}-%{release}
159Requires: lldb
d1b96fd8
JR
160BuildArch: noarch
161
162%description lldb
163This package includes the rust-lldb script, which allows easier
164debugging of Rust programs.
165
e8f16183
JB
166%description lldb -l pl.UTF-8
167Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
168odpluskwianie programów w języku Rust.
169
e361528e
ER
170%package doc
171Summary: Documentation for Rust
e8f16183 172Summary(pl.UTF-8): Dokumentacja do Rusta
d1b96fd8
JR
173Group: Documentation
174BuildArch: noarch
e361528e
ER
175
176%description doc
177This package includes HTML documentation for the Rust programming
178language and its standard library.
179
e8f16183
JB
180%description doc -l pl.UTF-8
181Ten pakiet zawiera dokumentację w formacie HTML do języka
182programowania Rust i jego biblioteki standardowej.
183
8a758d34
JP
184%package -n cargo
185Summary: Rust's package manager and build tool
186Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
187Group: Development/Tools
188Requires: %{name}
189
190%description -n cargo
191Cargo is a tool that allows Rust projects to declare their various
192dependencies and ensure that you'll always get a repeatable build.
193
194%description -n cargo -l pl.UTF-8
195Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
196zależności i zapewniające powtarzalność procesu budowania.
197
6ed79af8
JB
198%package -n bash-completion-cargo
199Summary: Bash completion for cargo command
200Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
201Group: Applications/Shells
202Requires: %{name} = %{version}-%{release}
203Requires: bash-completion
204
205%description -n bash-completion-cargo
206Bash completion for cargo command.
207
208%description -n bash-completion-cargo -l pl.UTF-8
209Bashowe dopełnianie parametrów polecenia cargo.
210
8a758d34
JP
211%package -n zsh-completion-cargo
212Summary: Zsh completion for cargo command
213Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
214Group: Applications/Shells
215Requires: %{name} = %{version}-%{release}
6ed79af8 216Requires: zsh
8a758d34
JP
217
218%description -n zsh-completion-cargo
219Zsh completion for cargo command.
220
221%description -n zsh-completion-cargo -l pl.UTF-8
222Dopełnianie parametrów polecenia cargo w powłoce Zsh.
223
e361528e
ER
224%prep
225%setup -q -n %{rustc_package}
b5eceb5e 226
e361528e 227%if %{with bootstrap}
72bb5844 228%ifarch %{x8664}
e361528e
ER
229tar xf %{SOURCE1}
230%endif
231%ifarch %{ix86}
232tar xf %{SOURCE2}
233%endif
72bb5844
JR
234%ifarch x32
235tar xf %{SOURCE1}
236cd %{bootstrap_root}
237tar xf %{SOURCE3}
238%{__mv} rust-std-%{bootstrap_rust}-%{rust_triple} rust-std-%{rust_triple}
239cd ..
240%endif
d6d4cb2b
JR
241%{__mv} %{bootstrap_root} %{bootstrap_root}-root
242%{bootstrap_root}-root/install.sh \
badbe44d 243 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
d6d4cb2b
JR
244 --prefix=%{local_rust_root} \
245 --disable-ldconfig
246test -f %{local_rust_root}/bin/cargo
e361528e 247test -f %{local_rust_root}/bin/rustc
72bb5844
JR
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
e361528e
ER
254%endif
255
256# unbundle
d4b51567 257# We're disabling jemalloc, but rust-src still wants it.
5b9d67b0 258#%{__rm} -r src/jemalloc
fe49e3fc 259%{?with_system_llvm:%{__rm} -r src/llvm-project}
e361528e
ER
260
261# extract bundled licenses for packaging
fe49e3fc
JP
262sed -e '/*\//q' vendor/backtrace-sys/src/libbacktrace/backtrace.h \
263 >vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
e361528e
ER
264
265# rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
266sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
267 src/etc/rust-gdb
268
5ee06aa0
JR
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.
fe49e3fc 272find vendor -name .cargo-checksum.json \
5ee06aa0 273 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
e361528e 274
e361528e
ER
275%build
276%configure \
e8f16183
JB
277 --build=%{rust_triple} \
278 --host=%{rust_triple} \
279 --target=%{rust_triple} \
18a1004b 280 --libdir=%{common_libdir} \
e8f16183 281 --disable-codegen-tests \
5ee06aa0 282 --disable-debuginfo-lines \
5b9d67b0 283%if %{with full_debuginfo}
5ee06aa0 284 --disable-debuginfo-only-std \
e361528e 285 --enable-debuginfo \
5b9d67b0
JB
286%else
287 --enable-debuginfo-only-std \
288 --disable-debuginfo \
289%endif
6ed79af8
JB
290 --disable-jemalloc \
291 --disable-option-checking \
292 --disable-rpath \
8a758d34 293 --enable-extended \
e8f16183 294 --enable-llvm-link-shared \
d6d4cb2b 295 --enable-vendor \
6ed79af8 296 --local-rust-root=%{local_rust_root} \
e8f16183 297 --llvm-root=%{_prefix} \
e361528e
ER
298 --release-channel=%{channel}
299
37765656
JP
300export RUST_BACKTRACE=full
301%x_py dist --verbose
e361528e 302
37765656 303%{?with_tests:%x_py test}
8a073211 304
e361528e
ER
305%install
306rm -rf $RPM_BUILD_ROOT
e361528e 307
37765656
JP
308export DESTDIR=$RPM_BUILD_ROOT
309%x_py install
310%x_py install src
e361528e 311
18a1004b
JR
312# Make sure the shared libraries are in the proper libdir
313%if "%{_libdir}" != "%{common_libdir}"
314mkdir -p %{buildroot}%{_libdir}
315find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
316 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
317%endif
318
d1b96fd8 319# The shared libraries should be executable for debuginfo extraction.
e361528e
ER
320find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
321
d1b96fd8
JR
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.
18a1004b 325(cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
d1b96fd8
JR
326 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
327 -exec ln -v -f -s -t . '{}' '+')
328
329# Remove installer artifacts (manifests, uninstall scripts, etc.)
18a1004b 330find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
e361528e
ER
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)
e8f16183
JB
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
e361528e
ER
340
341# Sanitize the HTML documentation
342find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
343find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
344
345# Move rust-gdb's python scripts so they're noarch
346install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
e8f16183 347%{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
e361528e 348
4f353dba
JR
349# We don't need stdlib source
350%{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
351
1dd26160
JP
352# Create the path for crate-devel packages
353install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
354
e361528e
ER
355%clean
356rm -rf $RPM_BUILD_ROOT
357
358%post -p /sbin/ldconfig
359%postun -p /sbin/ldconfig
360
361%files
362%defattr(644,root,root,755)
fe49e3fc
JP
363%doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
364%attr(755,root,root) %{_bindir}/miri
6ed79af8 365%attr(755,root,root) %{_bindir}/rls
e361528e
ER
366%attr(755,root,root) %{_bindir}/rustc
367%attr(755,root,root) %{_bindir}/rustdoc
6ed79af8 368%attr(755,root,root) %{_bindir}/rustfmt
e8f16183 369%attr(755,root,root) %{_libdir}/librustc*-*.so
e8f16183 370%attr(755,root,root) %{_libdir}/libstd-*.so
e8f16183 371%attr(755,root,root) %{_libdir}/libtest-*.so
e361528e
ER
372%{_mandir}/man1/rustc.1*
373%{_mandir}/man1/rustdoc.1*
18a1004b
JR
374%dir %{rustlibdir}
375%dir %{rustlibdir}/%{rust_triple}
6ed79af8 376%{rustlibdir}/%{rust_triple}/analysis
18a1004b
JR
377%dir %{rustlibdir}/%{rust_triple}/lib
378%attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
379%{rustlibdir}/%{rust_triple}/lib/*.rlib
e361528e 380
d1b96fd8
JR
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
e361528e
ER
392%files gdb
393%defattr(644,root,root,755)
394%attr(755,root,root) %{_bindir}/rust-gdb
fe49e3fc 395%attr(755,root,root) %{_bindir}/rust-gdbgui
d1b96fd8 396%{_datadir}/%{name}/etc/gdb_*.py*
e361528e
ER
397
398%files doc
399%defattr(644,root,root,755)
400%dir %{_docdir}/%{name}
d1b96fd8 401%doc %{_docdir}/%{name}/html
8a758d34
JP
402
403%files -n cargo
404%defattr(644,root,root,755)
405%attr(755,root,root) %{_bindir}/cargo
6ed79af8
JB
406%attr(755,root,root) %{_bindir}/cargo-clippy
407%attr(755,root,root) %{_bindir}/cargo-fmt
fe49e3fc 408%attr(755,root,root) %{_bindir}/cargo-miri
6ed79af8 409%attr(755,root,root) %{_bindir}/clippy-driver
8a758d34
JP
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.165469 seconds and 4 git commands to generate.