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