2 # - consider a rust-std package containing .../rustlib/$target
3 # This might allow multilib cross-compilation to work naturally.
4 # - package additional tools
7 %bcond_with bootstrap # bootstrap using precompiled binaries
8 %bcond_with full_debuginfo # full debuginfo vs only std debuginfo (full takes gigabytes of memory to build)
9 %bcond_without system_llvm # system LLVM
10 %bcond_with tests # build without tests
12 # The channel can be stable, beta, or nightly
13 %define channel stable
15 %if "%{channel}" == "stable"
16 %define rustc_package rustc-%{version}-src
18 %define rustc_package rustc-%{channel}-src
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
24 %define bootstrap_rust 1.53.0
25 %define bootstrap_cargo 1.53.0
26 %define bootstrap_date 2021-06-17
32 %if %{without full_debuginfo}
33 %define _enable_debug_packages 0
36 Summary: The Rust Programming Language
37 Summary(pl.UTF-8): Język programowania Rust
41 # Licenses: (rust itself) and (bundled libraries)
42 License: (Apache v2.0 or MIT) and (BSD and ISC and MIT)
43 Group: Development/Languages
44 Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
45 # Source0-md5: f1fc7b0f0c7aff2b8d61e58b510a6f66
46 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
47 # Source1-md5: 3f2ea3d908dac317d6006a117463f18e
48 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
49 # Source2-md5: 2ea9461d6c06c38ad85cc6037d70b9d7
50 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
51 # Source3-md5: 0772ec454b29685a4d79ead06c5cdd23
52 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
53 # Source4-md5: 7ecbfb7344a3dbafcaddffb898afbfa9
54 Source5: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-armv7-unknown-linux-gnueabihf.tar.xz
55 # Source5-md5: 3650d93b062c6605e3aa96ce4d63335c
56 URL: https://www.rust-lang.org/
58 BuildRequires: cmake >= 3.4.3
60 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
62 BuildRequires: python >= 1:2.7
63 BuildRequires: rpmbuild(macros) >= 1.752
65 BuildRequires: curl-devel
66 BuildRequires: libgit2-devel >= 1.1.0
67 BuildRequires: libstdc++-devel
68 %{?with_system_llvm:BuildRequires: llvm-devel >= 10.0}
69 BuildRequires: openssl-devel >= 1.0.1
70 BuildRequires: tar >= 1:1.22
72 BuildRequires: zlib-devel
74 %if %{without bootstrap}
75 BuildRequires: %{name} >= %{bootstrap_rust}
76 BuildRequires: cargo >= %{bootstrap_cargo}
77 BuildConflicts: %{name} > %{version}
80 BuildRequires: glibc-devel(x86-64)
81 BuildRequires: glibc-devel(x86-x32)
82 %if "%{_host_cpu}" == "x86_64"
83 # building on x86_64 host with --target x32-pld-linux
84 BuildRequires: curl-devel
85 BuildRequires: gcc-multilib-x32
86 BuildRequires: libgit2-devel >= 1.1.0
87 BuildRequires: libstdc++-devel
88 %{?with_system_llvm:BuildRequires: llvm-devel >= 10.0}
89 BuildRequires: openssl-devel >= 1.0.1
90 BuildRequires: zlib-devel
92 # building x86_64-hosted crosscompiler on x32 host
93 BuildRequires: curl-devel(x86-64)
94 BuildRequires: curl-devel(x86-x32)
95 BuildRequires: gcc-multilib-64
96 BuildRequires: libgit2-devel(x86-64) >= 1.1.0
97 BuildRequires: libgit2-devel(x86-x32) >= 1.1.0
98 BuildRequires: libstdc++-multilib-64-devel
99 %if %{with system_llvm}
100 BuildRequires: llvm-devel(x86-64) >= 10.0
101 BuildRequires: llvm-devel(x86-x32) >= 10.0
103 BuildRequires: openssl-devel(x86-64)
104 BuildRequires: openssl-devel(x86-x32)
105 BuildRequires: zlib-devel(x86-64)
106 BuildRequires: zlib-devel(x86-x32)
109 # The C compiler is needed at runtime just for linking. Someday rustc might
110 # invoke the linker directly, and then we'll only need binutils.
111 # https://github.com/rust-lang/rust/issues/11937
113 Requires: %{name}-std%{?_isa} = %{version}-%{release}
115 Requires: %{name}-std(x86-64) = %{version}-%{release}
117 Obsoletes: rust-analyzer < 1.53.0
118 # Only x86_64 and i686 are Tier 1 platforms at this time.
119 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
120 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
121 ExclusiveArch: %{x8664} %{ix86} x32 aarch64 armv6hl armv7hl armv7hnl
122 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
125 %define rust_triple x86_64-unknown-linux-gnux32
126 %define rust_host_triple x86_64-unknown-linux-gnu
127 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
128 # libs in _libdir are x86_64 64bit
130 %define _libdir %{_prefix}/lib64
133 %define rust_triple arm-unknown-linux-gnueabihf
134 %define rust_host_triple %{rust_triple}
135 %define rust_bootstrap_triple %{rust_triple}
137 %ifarch armv7hl armv7hnl
138 %define rust_triple armv7-unknown-linux-gnueabihf
139 %define rust_host_triple %{rust_triple}
140 %define rust_bootstrap_triple %{rust_triple}
142 %define rust_triple %{_target_cpu}-unknown-linux-gnu
143 %define rust_host_triple %{rust_triple}
144 %define rust_bootstrap_triple %{rust_triple}
149 %if %{without bootstrap}
150 %define local_rust_root %{_prefix}
152 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
153 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
156 # We're going to override --libdir when configuring to get rustlib into a
157 # common path, but we'll fix the shared libraries during install.
158 # Without this ugly hack, rust would not be able to build itself
159 # for non-bootstrap build, lib64 is just too complicated for it.
160 %define common_libdir %{_prefix}/lib
161 %define rustlibdir %{common_libdir}/rustlib
163 # once_call/once_callable non-function libstdc++ symbols
164 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
166 # ALL Rust libraries are private, because they don't keep an ABI.
167 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
168 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
174 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
179 Rust is a systems programming language that runs blazingly fast,
180 prevents segfaults, and guarantees thread safety.
182 This package includes the Rust compiler, standard library, and
183 documentation generator.
185 %description -l pl.UTF-8
186 Rust to systemowy język programowania działający bardzo szybko,
187 zapobiegający naruszeniom ochrony pamięci i gwarantujący
188 bezpieczną wielowątkowość.
191 Summary: Metadata about the standard library
192 Summary(pl.UTF-8): Metadane o standardowej bibliotece
193 Group: Development/Tools
194 Requires: %{name} = %{version}-%{release}
196 %description analysis
197 Metadata about the standard library.
199 %description analysis -l pl.UTF-8
200 Metadane o standardowej bibliotece.
203 Summary: Standard library for Rust
204 Summary(pl.UTF-8): Standardowa biblioteka Rusta
205 Group: Development/Tools
206 Requires: %{name} = %{version}-%{release}
209 Standard library for Rust.
211 %description std -l pl.UTF-8
212 Standardowa biblioteka Rusta.
214 %package debugger-common
215 Summary: Common debugger pretty printers for Rust
216 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
217 Group: Development/Debuggers
220 %description debugger-common
221 This package includes the common functionality for rust-gdb and
224 %description debugger-common -l pl.UTF-8
225 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
228 Summary: GDB pretty printers for Rust
229 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
230 Group: Development/Debuggers
231 Requires: %{name}-debugger-common = %{version}-%{release}
236 This package includes the rust-gdb script, which allows easier
237 debugging of Rust programs.
239 %description gdb -l pl.UTF-8
240 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
241 odpluskwianie programów w języku Rust.
244 Summary: LLDB pretty printers for Rust
245 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
246 Group: Development/Debuggers
247 Requires: %{name}-debugger-common = %{version}-%{release}
252 This package includes the rust-lldb script, which allows easier
253 debugging of Rust programs.
255 %description lldb -l pl.UTF-8
256 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
257 odpluskwianie programów w języku Rust.
260 Summary: Rust Language Server for IDE integration
261 Summary(pl.UTF-8): Rust Language Server do integracji z IDE
262 Group: Development/Tools
263 Requires: %{name} = %{version}-%{release}
264 Requires: %{name}-analysis = %{version}-%{release}
267 Rust Language Server for IDE integration.
269 %description rls -l pl.UTF-8
270 Rust Language Server do integracji z IDE.
273 Summary: Documentation for Rust
274 Summary(pl.UTF-8): Dokumentacja do Rusta
279 This package includes HTML documentation for the Rust programming
280 language and its standard library.
282 %description doc -l pl.UTF-8
283 Ten pakiet zawiera dokumentację w formacie HTML do języka
284 programowania Rust i jego biblioteki standardowej.
287 Summary: Rust's package manager and build tool
288 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
289 Group: Development/Tools
290 Requires: %{name}%{?_isa}
292 %description -n cargo
293 Cargo is a tool that allows Rust projects to declare their various
294 dependencies and ensure that you'll always get a repeatable build.
296 %description -n cargo -l pl.UTF-8
297 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
298 zależności i zapewniające powtarzalność procesu budowania.
300 %package -n bash-completion-cargo
301 Summary: Bash completion for cargo command
302 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
303 Group: Applications/Shells
304 Requires: %{name} = %{version}-%{release}
305 Requires: bash-completion
307 %description -n bash-completion-cargo
308 Bash completion for cargo command.
310 %description -n bash-completion-cargo -l pl.UTF-8
311 Bashowe dopełnianie parametrów polecenia cargo.
313 %package -n zsh-completion-cargo
314 Summary: Zsh completion for cargo command
315 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
316 Group: Applications/Shells
317 Requires: %{name} = %{version}-%{release}
320 %description -n zsh-completion-cargo
321 Zsh completion for cargo command.
323 %description -n zsh-completion-cargo -l pl.UTF-8
324 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
327 %setup -q -n %{rustc_package}
329 %if %{with bootstrap}
342 %ifarch armv7hl armv7hnl
345 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
346 %{bootstrap_root}-root/install.sh \
347 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
348 --prefix=%{local_rust_root} \
350 test -f %{local_rust_root}/bin/cargo
351 test -f %{local_rust_root}/bin/rustc
355 # We're disabling jemalloc, but rust-src still wants it.
356 #%{__rm} -r src/jemalloc
357 %if %{with system_llvm}
358 %{__rm} -r src/llvm-project
359 mkdir -p src/llvm-project/libunwind
362 # extract bundled licenses for packaging
363 sed -e '/*\//q' library/backtrace/crates/backtrace-sys/src/libbacktrace/backtrace.h \
364 >library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
366 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
367 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
370 # cargo has hardcoded libexec path - honour rpm _libexecdir
371 %if "%{_libexecdir}" != "%{_prefix}/libexec"
372 suffix="%(echo "%{_libexecdir}" | %{__sed} -e 's,^%{_prefix}/,,')"
373 %{__sed} -i -e 's,"libexec","'${suffix}'",' \
374 src/bootstrap/dist.rs \
375 src/tools/cargo/src/cargo/ops/registry/auth.rs
376 %{__sed} -i -e 's,libexec/,'${suffix}'/,' src/tools/cargo/tests/testsuite/credential_process.rs
379 # The configure macro will modify some autoconf-related files, which upsets
380 # cargo when it tries to verify checksums in those files. If we just truncate
381 # that file list, cargo won't have anything to complain about.
382 find vendor -name .cargo-checksum.json \
383 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
387 --build=%{rust_bootstrap_triple} \
388 --host=%{rust_host_triple} \
389 --target=%{rust_triple} \
390 --libdir=%{common_libdir} \
391 --disable-codegen-tests \
392 --disable-debuginfo-lines \
393 %if %{with full_debuginfo}
394 --disable-debuginfo-only-std \
397 --enable-debuginfo-only-std \
398 --disable-debuginfo \
401 --disable-option-checking \
404 --enable-llvm-link-shared \
406 --local-rust-root=%{local_rust_root} \
407 --llvm-root=%{_prefix} \
408 --release-channel=%{channel}
410 export RUST_BACKTRACE=full
413 %{?with_tests:%x_py test}
416 rm -rf $RPM_BUILD_ROOT
418 export DESTDIR=$RPM_BUILD_ROOT
421 # Make sure the shared libraries are in the proper libdir
422 %if "%{_libdir}" != "%{common_libdir}"
423 mkdir -p %{buildroot}%{_libdir}
424 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
425 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
428 # The shared libraries should be executable for debuginfo extraction.
429 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
431 # The libdir libraries are identical to those under rustlib/. It's easier on
432 # library loading if we keep them in libdir, but we do need them in rustlib/
433 # to support dynamic linking for compiler plugins, so we'll symlink.
434 for l in libstd libtest ; do
435 liblib=$RPM_BUILD_ROOT%{_libdir}/${l}-*.so
436 libstd=$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib/${l}-*.so
437 if [ "$(basename ${liblib})" = "$(basename ${libstd})" ]; then
438 ln -vfsr ${libstd} $RPM_BUILD_ROOT%{_libdir}/
442 # Remove installer artifacts (manifests, uninstall scripts, etc.)
443 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
445 # FIXME: __os_install_post will strip the rlibs
446 # -- should we find a way to preserve debuginfo?
448 # Remove unwanted documentation files (we already package them)
449 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
450 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
451 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
452 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
454 # Sanitize the HTML documentation
455 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
456 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
458 # Move rust-gdb's python scripts so they're noarch
459 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
460 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
462 # We don't need stdlib source
463 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
465 # Create the path for crate-devel packages
466 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
469 rm -rf $RPM_BUILD_ROOT
471 %post -p /sbin/ldconfig
472 %postun -p /sbin/ldconfig
475 %defattr(644,root,root,755)
476 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
477 %attr(755,root,root) %{_bindir}/rustc
478 %attr(755,root,root) %{_bindir}/rustdoc
479 %attr(755,root,root) %{_bindir}/rustfmt
480 %attr(755,root,root) %{_libdir}/librustc_driver-*.so
481 %attr(755,root,root) %{_libdir}/libstd-*.so
482 %attr(755,root,root) %{_libdir}/libtest-*.so
483 %{_mandir}/man1/rustc.1*
484 %{_mandir}/man1/rustdoc.1*
488 %defattr(644,root,root,755)
489 %{rustlibdir}/%{rust_triple}/analysis
492 %defattr(644,root,root,755)
493 %dir %{rustlibdir}/%{rust_triple}
494 %dir %{rustlibdir}/%{rust_triple}/lib
495 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
496 %{rustlibdir}/%{rust_triple}/lib/*.rlib
498 %files debugger-common
499 %defattr(644,root,root,755)
500 %dir %{_datadir}/%{name}
501 %dir %{_datadir}/%{name}/etc
502 %{_datadir}/%{name}/etc/lldb_commands
503 %{_datadir}/%{name}/etc/rust_types.py
506 %defattr(644,root,root,755)
507 %attr(755,root,root) %{_bindir}/rust-lldb
508 %{_datadir}/%{name}/etc/lldb_*.py*
511 %defattr(644,root,root,755)
512 %attr(755,root,root) %{_bindir}/rust-gdb
513 %attr(755,root,root) %{_bindir}/rust-gdbgui
514 %{_datadir}/%{name}/etc/gdb_*.py*
517 %defattr(644,root,root,755)
518 %attr(755,root,root) %{_bindir}/rls
521 %defattr(644,root,root,755)
522 %dir %{_docdir}/%{name}
523 %doc %{_docdir}/%{name}/html
526 %defattr(644,root,root,755)
527 %attr(755,root,root) %{_bindir}/cargo
528 %attr(755,root,root) %{_bindir}/cargo-clippy
529 %attr(755,root,root) %{_bindir}/cargo-fmt
530 %attr(755,root,root) %{_bindir}/clippy-driver
531 %attr(755,root,root) %{_libexecdir}/cargo-credential-1password
532 %{_mandir}/man1/cargo*.1*
533 %dir %{_datadir}/cargo
534 %dir %{_datadir}/cargo/registry
536 %files -n bash-completion-cargo
537 %defattr(644,root,root,755)
538 %{_sysconfdir}/bash_completion.d/cargo
540 %files -n zsh-completion-cargo
541 %defattr(644,root,root,755)
542 %{zsh_compdir}/_cargo