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