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