]> git.pld-linux.org Git - packages/rust.git/blame - rust.spec
up to 1.48.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
9e7854c5
JP
24%define bootstrap_rust 1.47.0
25%define bootstrap_cargo 1.47.0
26%define bootstrap_date 2020-10-08
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
9e7854c5 34Version: 1.48.0
20b64456 35Release: 0.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
9e7854c5 40# Source0-md5: 1d8996bba1abbd5b3b149ccc89589664
be28e1f1 41Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
9e7854c5 42# Source1-md5: 9365de1153dae7bf1f99224382f8d77c
be28e1f1 43Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
9e7854c5 44# Source2-md5: 9c351771a541e38416dd99ca85309059
9eb0511e 45Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
9e7854c5 46# Source3-md5: 1bb96238b441204e2b47561857ca9916
5aae056c 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
3c25e53d
JR
85# how to specify? - rpm.org adds arch provides on packages (__isa), uncomment once we switch
86#BuildRequires: curl-devel(x86-64)
87#BuildRequires: libgit2-devel(x86-64)
88#BuildRequires: llvm-devel(x86-64)>= 7.0
89#BuildRequires: openssl-devel(x86-64)
90#BuildRequires: zlib-devel(x86-64)
2eb30149
JB
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
a7fda0f8
JP
154%package analyzer
155Summary: Implementation of Language Server Protocol for Rust
156Summary(pl.UTF-8): Implementacja Language Server Protocol dla Rusta
157Group: Development/Tools
158Requires: %{name} = %{version}-%{release}
159
160%description analyzer
161Implementation of Language Server Protocol for Rust.
162
163%description analyzer -l pl.UTF-8
164Implementacja Language Server Protocol dla Rusta.
165
d1b96fd8
JR
166%package debugger-common
167Summary: Common debugger pretty printers for Rust
e8f16183 168Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
d1b96fd8 169Group: Development/Debuggers
2eb30149 170%{?noarchpackage}
d1b96fd8
JR
171
172%description debugger-common
e8f16183
JB
173This package includes the common functionality for rust-gdb and
174rust-lldb.
175
176%description debugger-common -l pl.UTF-8
177Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
d1b96fd8 178
e361528e
ER
179%package gdb
180Summary: GDB pretty printers for Rust
e8f16183 181Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
d1b96fd8
JR
182Group: Development/Debuggers
183Requires: %{name}-debugger-common = %{version}-%{release}
e361528e 184Requires: gdb
2eb30149 185%{?noarchpackage}
e361528e
ER
186
187%description gdb
188This package includes the rust-gdb script, which allows easier
189debugging of Rust programs.
190
e8f16183
JB
191%description gdb -l pl.UTF-8
192Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
193odpluskwianie programów w języku Rust.
194
d1b96fd8
JR
195%package lldb
196Summary: LLDB pretty printers for Rust
e8f16183 197Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
d1b96fd8
JR
198Group: Development/Debuggers
199Requires: %{name}-debugger-common = %{version}-%{release}
200Requires: lldb
2eb30149 201%{?noarchpackage}
d1b96fd8
JR
202
203%description lldb
204This package includes the rust-lldb script, which allows easier
205debugging of Rust programs.
206
e8f16183
JB
207%description lldb -l pl.UTF-8
208Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
209odpluskwianie programów w języku Rust.
210
a7fda0f8
JP
211%package rls
212Summary: Rust Language Server for IDE integration
213Summary(pl.UTF-8): Rust Language Server do integracji z IDE
214Group: Development/Tools
215Requires: %{name} = %{version}-%{release}
216
217%description rls
218Rust Language Server for IDE integration.
219
220%description rls -l pl.UTF-8
221Rust Language Server do integracji z IDE.
222
e361528e
ER
223%package doc
224Summary: Documentation for Rust
e8f16183 225Summary(pl.UTF-8): Dokumentacja do Rusta
d1b96fd8 226Group: Documentation
2eb30149 227%{?noarchpackage}
e361528e
ER
228
229%description doc
230This package includes HTML documentation for the Rust programming
231language and its standard library.
232
e8f16183
JB
233%description doc -l pl.UTF-8
234Ten pakiet zawiera dokumentację w formacie HTML do języka
235programowania Rust i jego biblioteki standardowej.
236
8a758d34
JP
237%package -n cargo
238Summary: Rust's package manager and build tool
239Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
240Group: Development/Tools
241Requires: %{name}
242
243%description -n cargo
244Cargo is a tool that allows Rust projects to declare their various
245dependencies and ensure that you'll always get a repeatable build.
246
247%description -n cargo -l pl.UTF-8
248Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
249zależności i zapewniające powtarzalność procesu budowania.
250
6ed79af8
JB
251%package -n bash-completion-cargo
252Summary: Bash completion for cargo command
253Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
254Group: Applications/Shells
255Requires: %{name} = %{version}-%{release}
256Requires: bash-completion
257
258%description -n bash-completion-cargo
259Bash completion for cargo command.
260
261%description -n bash-completion-cargo -l pl.UTF-8
262Bashowe dopełnianie parametrów polecenia cargo.
263
8a758d34
JP
264%package -n zsh-completion-cargo
265Summary: Zsh completion for cargo command
266Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
267Group: Applications/Shells
268Requires: %{name} = %{version}-%{release}
6ed79af8 269Requires: zsh
8a758d34
JP
270
271%description -n zsh-completion-cargo
272Zsh completion for cargo command.
273
274%description -n zsh-completion-cargo -l pl.UTF-8
275Dopełnianie parametrów polecenia cargo w powłoce Zsh.
276
e361528e
ER
277%prep
278%setup -q -n %{rustc_package}
2eb30149 279# irrelevant when not building rustc for x32
d794f84f 280%patch0 -p1
b5eceb5e 281
e361528e 282%if %{with bootstrap}
a1735efb 283%ifarch %{x8664} x32
e361528e
ER
284tar xf %{SOURCE1}
285%endif
286%ifarch %{ix86}
287tar xf %{SOURCE2}
288%endif
c160f211 289%ifarch aarch64
9eb0511e 290tar xf %{SOURCE3}
c160f211 291%endif
d6d4cb2b
JR
292%{__mv} %{bootstrap_root} %{bootstrap_root}-root
293%{bootstrap_root}-root/install.sh \
badbe44d 294 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
d6d4cb2b
JR
295 --prefix=%{local_rust_root} \
296 --disable-ldconfig
297test -f %{local_rust_root}/bin/cargo
e361528e
ER
298test -f %{local_rust_root}/bin/rustc
299%endif
300
301# unbundle
d4b51567 302# We're disabling jemalloc, but rust-src still wants it.
5b9d67b0 303#%{__rm} -r src/jemalloc
9e7854c5
JP
304%if %{with system_llvm}
305%{__rm} -r src/llvm-project
306mkdir -p src/llvm-project/libunwind
307%endif
e361528e
ER
308
309# extract bundled licenses for packaging
5aae056c
JP
310sed -e '/*\//q' library/backtrace/crates/backtrace-sys/src/libbacktrace/backtrace.h \
311 >library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
e361528e
ER
312
313# rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
314sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
315 src/etc/rust-gdb
316
5ee06aa0
JR
317# The configure macro will modify some autoconf-related files, which upsets
318# cargo when it tries to verify checksums in those files. If we just truncate
319# that file list, cargo won't have anything to complain about.
fe49e3fc 320find vendor -name .cargo-checksum.json \
5ee06aa0 321 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
e361528e 322
e361528e
ER
323%build
324%configure \
2eb30149
JB
325 --build=%{rust_bootstrap_triple} \
326 --host=%{rust_host_triple} \
e8f16183 327 --target=%{rust_triple} \
18a1004b 328 --libdir=%{common_libdir} \
e8f16183 329 --disable-codegen-tests \
5ee06aa0 330 --disable-debuginfo-lines \
5b9d67b0 331%if %{with full_debuginfo}
5ee06aa0 332 --disable-debuginfo-only-std \
e361528e 333 --enable-debuginfo \
5b9d67b0
JB
334%else
335 --enable-debuginfo-only-std \
336 --disable-debuginfo \
337%endif
6ed79af8
JB
338 --disable-jemalloc \
339 --disable-option-checking \
340 --disable-rpath \
8a758d34 341 --enable-extended \
e8f16183 342 --enable-llvm-link-shared \
d6d4cb2b 343 --enable-vendor \
6ed79af8 344 --local-rust-root=%{local_rust_root} \
e8f16183 345 --llvm-root=%{_prefix} \
e361528e
ER
346 --release-channel=%{channel}
347
37765656
JP
348export RUST_BACKTRACE=full
349%x_py dist --verbose
e361528e 350
37765656 351%{?with_tests:%x_py test}
8a073211 352
e361528e
ER
353%install
354rm -rf $RPM_BUILD_ROOT
e361528e 355
37765656
JP
356export DESTDIR=$RPM_BUILD_ROOT
357%x_py install
358%x_py install src
e361528e 359
18a1004b
JR
360# Make sure the shared libraries are in the proper libdir
361%if "%{_libdir}" != "%{common_libdir}"
362mkdir -p %{buildroot}%{_libdir}
363find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
364 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
365%endif
366
d1b96fd8 367# The shared libraries should be executable for debuginfo extraction.
e361528e
ER
368find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
369
d1b96fd8
JR
370# The libdir libraries are identical to those under rustlib/. It's easier on
371# library loading if we keep them in libdir, but we do need them in rustlib/
372# to support dynamic linking for compiler plugins, so we'll symlink.
18a1004b 373(cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
d1b96fd8
JR
374 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
375 -exec ln -v -f -s -t . '{}' '+')
376
377# Remove installer artifacts (manifests, uninstall scripts, etc.)
18a1004b 378find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
e361528e
ER
379
380# FIXME: __os_install_post will strip the rlibs
381# -- should we find a way to preserve debuginfo?
382
383# Remove unwanted documentation files (we already package them)
e8f16183
JB
384%{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
385%{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
386%{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
387%{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
e361528e
ER
388
389# Sanitize the HTML documentation
390find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
391find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
392
393# Move rust-gdb's python scripts so they're noarch
394install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
e8f16183 395%{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
e361528e 396
4f353dba
JR
397# We don't need stdlib source
398%{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
399
1dd26160
JP
400# Create the path for crate-devel packages
401install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
402
e361528e
ER
403%clean
404rm -rf $RPM_BUILD_ROOT
405
406%post -p /sbin/ldconfig
407%postun -p /sbin/ldconfig
408
409%files
410%defattr(644,root,root,755)
5aae056c 411%doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
e361528e
ER
412%attr(755,root,root) %{_bindir}/rustc
413%attr(755,root,root) %{_bindir}/rustdoc
6ed79af8 414%attr(755,root,root) %{_bindir}/rustfmt
5aae056c 415%attr(755,root,root) %{_libdir}/libchalk_derive-*.so
e8f16183 416%attr(755,root,root) %{_libdir}/librustc*-*.so
e8f16183 417%attr(755,root,root) %{_libdir}/libstd-*.so
e8f16183 418%attr(755,root,root) %{_libdir}/libtest-*.so
5aae056c 419%attr(755,root,root) %{_libdir}/libtracing_attributes-*.so
e361528e
ER
420%{_mandir}/man1/rustc.1*
421%{_mandir}/man1/rustdoc.1*
18a1004b
JR
422%dir %{rustlibdir}
423%dir %{rustlibdir}/%{rust_triple}
6ed79af8 424%{rustlibdir}/%{rust_triple}/analysis
18a1004b
JR
425%dir %{rustlibdir}/%{rust_triple}/lib
426%attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
427%{rustlibdir}/%{rust_triple}/lib/*.rlib
e361528e 428
2eb30149
JB
429# for cross-compiler (e.g. x86_64-hosted x32 rust)
430%if "%{rust_host_triple}" != "%{rust_triple}"
431%dir %{rustlibdir}/%{rust_host_triple}
432%{rustlibdir}/%{rust_host_triple}/analysis
433%dir %{rustlibdir}/%{rust_host_triple}/lib
434%attr(755,root,root) %{rustlibdir}/%{rust_host_triple}/lib/*.so
435%{rustlibdir}/%{rust_host_triple}/lib/*.rlib
436%endif
437
a7fda0f8
JP
438%files analyzer
439%defattr(644,root,root,755)
440%attr(755,root,root) %{_bindir}/rust-analyzer
441
d1b96fd8
JR
442%files debugger-common
443%defattr(644,root,root,755)
444%dir %{_datadir}/%{name}
445%dir %{_datadir}/%{name}/etc
5aae056c
JP
446%{_datadir}/%{name}/etc/lldb_commands
447%{_datadir}/%{name}/etc/rust_types.py
d1b96fd8
JR
448
449%files lldb
450%defattr(644,root,root,755)
451%attr(755,root,root) %{_bindir}/rust-lldb
452%{_datadir}/%{name}/etc/lldb_*.py*
453
e361528e
ER
454%files gdb
455%defattr(644,root,root,755)
456%attr(755,root,root) %{_bindir}/rust-gdb
fe49e3fc 457%attr(755,root,root) %{_bindir}/rust-gdbgui
d1b96fd8 458%{_datadir}/%{name}/etc/gdb_*.py*
e361528e 459
a7fda0f8
JP
460%files rls
461%defattr(644,root,root,755)
462%attr(755,root,root) %{_bindir}/rls
463
e361528e
ER
464%files doc
465%defattr(644,root,root,755)
466%dir %{_docdir}/%{name}
d1b96fd8 467%doc %{_docdir}/%{name}/html
8a758d34
JP
468
469%files -n cargo
470%defattr(644,root,root,755)
471%attr(755,root,root) %{_bindir}/cargo
6ed79af8
JB
472%attr(755,root,root) %{_bindir}/cargo-clippy
473%attr(755,root,root) %{_bindir}/cargo-fmt
474%attr(755,root,root) %{_bindir}/clippy-driver
8a758d34
JP
475%{_mandir}/man1/cargo*.1*
476%dir %{_datadir}/cargo
477%dir %{_datadir}/cargo/registry
478
479%files -n bash-completion-cargo
480%defattr(644,root,root,755)
481%{_sysconfdir}/bash_completion.d/cargo
482
483%files -n zsh-completion-cargo
484%defattr(644,root,root,755)
485%{zsh_compdir}/_cargo
This page took 0.115564 seconds and 4 git commands to generate.