2 # - unpackaged %{rustlibdir}/%{rust_triple}/bin/rust-llvm-dwp
3 # - consider a rust-std package containing .../rustlib/$target
4 # This might allow multilib cross-compilation to work naturally.
5 # - package additional tools
8 %bcond_with bootstrap # bootstrap using precompiled binaries
9 %bcond_with full_debuginfo # full debuginfo vs only std debuginfo (full takes gigabytes of memory to build)
10 %bcond_without system_llvm # system LLVM
11 %bcond_with tests # build without tests
13 # The channel can be stable, beta, or nightly
14 %define channel stable
16 %if "%{channel}" == "stable"
17 %define rustc_package rustc-%{version}-src
19 %define rustc_package rustc-%{channel}-src
22 # To bootstrap from scratch, set the channel and date from src/stage0.json
23 # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
24 # or nightly wants some beta-YYYY-MM-DD
25 %define bootstrap_rust 1.56.1
26 %define bootstrap_cargo 1.56.1
27 %define bootstrap_date 2021-11-01
33 %if %{without full_debuginfo}
34 %define _enable_debug_packages 0
37 Summary: The Rust Programming Language
38 Summary(pl.UTF-8): Język programowania Rust
42 # Licenses: (rust itself) and (bundled libraries)
43 License: (Apache v2.0 or MIT) and (BSD and ISC and MIT)
44 Group: Development/Languages
45 Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
46 # Source0-md5: 0c7d63d9c456c4ec0f95bb6bb729c13e
47 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
48 # Source1-md5: 9c12561dff9debea38e4b93f881ae2bb
49 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
50 # Source2-md5: 947bd95b9c8a9943d43af1bbabf1a8e1
51 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
52 # Source3-md5: 64d78bc0747c975fe0451e4fd5b8ac4b
53 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
54 # Source4-md5: a13652efd627b5e5f8bd278f378acea4
55 Source5: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-armv7-unknown-linux-gnueabihf.tar.xz
56 # Source5-md5: 3fb69008b1b0141d464a4a48317709b3
57 URL: https://www.rust-lang.org/
59 BuildRequires: cmake >= 3.4.3
61 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
63 BuildRequires: python3
64 BuildRequires: python3-modules
65 BuildRequires: rpm-build >= 4.6
66 BuildRequires: rpmbuild(macros) >= 1.752
68 BuildRequires: curl-devel
69 BuildRequires: libgit2-devel >= 1.3.0
70 BuildRequires: libstdc++-devel
71 %if %{with system_llvm}
72 BuildRequires: llvm >= 10.0
73 BuildRequires: llvm-devel >= 10.0
75 BuildRequires: openssl-devel >= 1.0.1
76 BuildRequires: tar >= 1:1.22
78 BuildRequires: zlib-devel
80 %if %{without bootstrap}
81 BuildRequires: %{name} >= %{bootstrap_rust}
82 BuildRequires: cargo >= %{bootstrap_cargo}
83 BuildConflicts: %{name} > %{version}
86 BuildRequires: glibc-devel(x86-64)
87 BuildRequires: glibc-devel(x86-x32)
88 %if "%{_host_cpu}" == "x86_64"
89 # building on x86_64 host with --target x32-pld-linux
90 BuildRequires: curl-devel
91 BuildRequires: gcc-multilib-x32
92 BuildRequires: libgit2-devel >= 1.3.0
93 BuildRequires: libstdc++-devel
94 %{?with_system_llvm:BuildRequires: llvm-devel >= 10.0}
95 BuildRequires: openssl-devel >= 1.0.1
96 BuildRequires: zlib-devel
98 # building x86_64-hosted crosscompiler on x32 host
99 BuildRequires: curl-devel(x86-64)
100 BuildRequires: curl-devel(x86-x32)
101 BuildRequires: gcc-multilib-64
102 BuildRequires: libgit2-devel(x86-64) >= 1.3.0
103 BuildRequires: libgit2-devel(x86-x32) >= 1.3.0
104 BuildRequires: libstdc++-multilib-64-devel
105 %if %{with system_llvm}
106 BuildRequires: llvm-devel(x86-64) >= 10.0
107 BuildRequires: llvm-devel(x86-x32) >= 10.0
109 BuildRequires: openssl-devel(x86-64)
110 BuildRequires: openssl-devel(x86-x32)
111 BuildRequires: zlib-devel(x86-64)
112 BuildRequires: zlib-devel(x86-x32)
115 # The C compiler is needed at runtime just for linking. Someday rustc might
116 # invoke the linker directly, and then we'll only need binutils.
117 # https://github.com/rust-lang/rust/issues/11937
119 Requires: %{name}-std%{?_isa} = %{version}-%{release}
121 Requires: %{name}-std(x86-64) = %{version}-%{release}
123 Obsoletes: rust-analyzer < 1.53.0
124 # Only x86_64 and i686 are Tier 1 platforms at this time.
125 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
126 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
127 ExclusiveArch: %{x8664} %{ix86} x32 aarch64 armv6hl armv7hl armv7hnl
128 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
131 %define rust_triple x86_64-unknown-linux-gnux32
132 %define rust_host_triple x86_64-unknown-linux-gnu
133 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
134 # libs in _libdir are x86_64 64bit
136 %define _libdir %{_prefix}/lib64
139 %define rust_triple arm-unknown-linux-gnueabihf
140 %define rust_host_triple %{rust_triple}
141 %define rust_bootstrap_triple %{rust_triple}
143 %ifarch armv7hl armv7hnl
144 %define rust_triple armv7-unknown-linux-gnueabihf
145 %define rust_host_triple %{rust_triple}
146 %define rust_bootstrap_triple %{rust_triple}
148 %define rust_triple %{_target_cpu}-unknown-linux-gnu
149 %define rust_host_triple %{rust_triple}
150 %define rust_bootstrap_triple %{rust_triple}
155 %if %{without bootstrap}
156 %define local_rust_root %{_prefix}
158 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
159 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
162 # We're going to override --libdir when configuring to get rustlib into a
163 # common path, but we'll fix the shared libraries during install.
164 # Without this ugly hack, rust would not be able to build itself
165 # for non-bootstrap build, lib64 is just too complicated for it.
166 %define common_libdir %{_prefix}/lib
167 %define rustlibdir %{common_libdir}/rustlib
169 # once_call/once_callable non-function libstdc++ symbols
170 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
172 # ALL Rust libraries are private, because they don't keep an ABI.
173 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
174 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
180 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }%{__python3} ./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
185 Rust is a systems programming language that runs blazingly fast,
186 prevents segfaults, and guarantees thread safety.
188 This package includes the Rust compiler, standard library, and
189 documentation generator.
191 %description -l pl.UTF-8
192 Rust to systemowy język programowania działający bardzo szybko,
193 zapobiegający naruszeniom ochrony pamięci i gwarantujący
194 bezpieczną wielowątkowość.
197 Summary: Metadata about the standard library
198 Summary(pl.UTF-8): Metadane o standardowej bibliotece
199 Group: Development/Tools
200 Requires: %{name} = %{version}-%{release}
202 %description analysis
203 Metadata about the standard library.
205 %description analysis -l pl.UTF-8
206 Metadane o standardowej bibliotece.
209 Summary: Standard library for Rust
210 Summary(pl.UTF-8): Standardowa biblioteka Rusta
211 Group: Development/Tools
212 Requires: %{name} = %{version}-%{release}
215 Standard library for Rust.
217 %description std -l pl.UTF-8
218 Standardowa biblioteka Rusta.
220 %package debugger-common
221 Summary: Common debugger pretty printers for Rust
222 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
223 Group: Development/Debuggers
226 %description debugger-common
227 This package includes the common functionality for rust-gdb and
230 %description debugger-common -l pl.UTF-8
231 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
234 Summary: GDB pretty printers for Rust
235 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
236 Group: Development/Debuggers
237 Requires: %{name}-debugger-common = %{version}-%{release}
242 This package includes the rust-gdb script, which allows easier
243 debugging of Rust programs.
245 %description gdb -l pl.UTF-8
246 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
247 odpluskwianie programów w języku Rust.
250 Summary: LLDB pretty printers for Rust
251 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
252 Group: Development/Debuggers
253 Requires: %{name}-debugger-common = %{version}-%{release}
258 This package includes the rust-lldb script, which allows easier
259 debugging of Rust programs.
261 %description lldb -l pl.UTF-8
262 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
263 odpluskwianie programów w języku Rust.
266 Summary: Rust Language Server for IDE integration
267 Summary(pl.UTF-8): Rust Language Server do integracji z IDE
268 Group: Development/Tools
269 Requires: %{name} = %{version}-%{release}
270 Requires: %{name}-analysis = %{version}-%{release}
273 Rust Language Server for IDE integration.
275 %description rls -l pl.UTF-8
276 Rust Language Server do integracji z IDE.
279 Summary: Documentation for Rust
280 Summary(pl.UTF-8): Dokumentacja do Rusta
285 This package includes HTML documentation for the Rust programming
286 language and its standard library.
288 %description doc -l pl.UTF-8
289 Ten pakiet zawiera dokumentację w formacie HTML do języka
290 programowania Rust i jego biblioteki standardowej.
293 Summary: Rust's package manager and build tool
294 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
295 Group: Development/Tools
296 Requires: %{name}%{?_isa}
298 %description -n cargo
299 Cargo is a tool that allows Rust projects to declare their various
300 dependencies and ensure that you'll always get a repeatable build.
302 %description -n cargo -l pl.UTF-8
303 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
304 zależności i zapewniające powtarzalność procesu budowania.
306 %package -n bash-completion-cargo
307 Summary: Bash completion for cargo command
308 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
309 Group: Applications/Shells
310 Requires: %{name} = %{version}-%{release}
311 Requires: bash-completion
313 %description -n bash-completion-cargo
314 Bash completion for cargo command.
316 %description -n bash-completion-cargo -l pl.UTF-8
317 Bashowe dopełnianie parametrów polecenia cargo.
319 %package -n zsh-completion-cargo
320 Summary: Zsh completion for cargo command
321 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
322 Group: Applications/Shells
323 Requires: %{name} = %{version}-%{release}
326 %description -n zsh-completion-cargo
327 Zsh completion for cargo command.
329 %description -n zsh-completion-cargo -l pl.UTF-8
330 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
333 %setup -q -n %{rustc_package}
335 %if %{with bootstrap}
348 %ifarch armv7hl armv7hnl
351 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
352 %{bootstrap_root}-root/install.sh \
353 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
354 --prefix=%{local_rust_root} \
356 test -f %{local_rust_root}/bin/cargo
357 test -f %{local_rust_root}/bin/rustc
361 # We're disabling jemalloc, but rust-src still wants it.
362 #%{__rm} -r src/jemalloc
363 %if %{with system_llvm}
364 %{__rm} -r src/llvm-project
365 mkdir -p src/llvm-project/libunwind
368 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
369 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
372 # cargo has hardcoded libexec path - honour rpm _libexecdir
373 %if "%{_libexecdir}" != "%{_prefix}/libexec"
374 suffix="%(echo "%{_libexecdir}" | %{__sed} -e 's,^%{_prefix}/,,')"
375 %{__sed} -i -e 's,"libexec","'${suffix}'",' \
376 src/bootstrap/dist.rs \
377 src/tools/cargo/src/cargo/ops/registry/auth.rs
378 %{__sed} -i -e 's,libexec/,'${suffix}'/,' src/tools/cargo/tests/testsuite/credential_process.rs
381 # The configure macro will modify some autoconf-related files, which upsets
382 # cargo when it tries to verify checksums in those files. If we just truncate
383 # that file list, cargo won't have anything to complain about.
384 find vendor -name .cargo-checksum.json \
385 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
389 --build=%{rust_bootstrap_triple} \
390 --host=%{rust_host_triple} \
391 --target=%{rust_triple} \
392 --libdir=%{common_libdir} \
393 --disable-codegen-tests \
394 --disable-debuginfo-lines \
395 %if %{with full_debuginfo}
396 --disable-debuginfo-only-std \
399 --enable-debuginfo-only-std \
400 --disable-debuginfo \
403 --disable-option-checking \
406 --enable-llvm-link-shared \
408 --local-rust-root=%{local_rust_root} \
409 --llvm-root=%{_prefix} \
410 --release-channel=%{channel}
412 export RUST_BACKTRACE=full
415 %{?with_tests:%x_py test}
418 rm -rf $RPM_BUILD_ROOT
420 export DESTDIR=$RPM_BUILD_ROOT
423 # Make sure the shared libraries are in the proper libdir
424 %if "%{_libdir}" != "%{common_libdir}"
425 mkdir -p %{buildroot}%{_libdir}
426 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
427 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
430 # The shared libraries should be executable for debuginfo extraction.
431 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
433 # The libdir libraries are identical to those under rustlib/. It's easier on
434 # library loading if we keep them in libdir, but we do need them in rustlib/
435 # to support dynamic linking for compiler plugins, so we'll symlink.
436 for l in libstd libtest ; do
437 liblib=$RPM_BUILD_ROOT%{_libdir}/${l}-*.so
438 libstd=$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib/${l}-*.so
439 if [ "$(basename ${liblib})" = "$(basename ${libstd})" ]; then
440 ln -vfsr ${libstd} $RPM_BUILD_ROOT%{_libdir}/
444 # Remove installer artifacts (manifests, uninstall scripts, etc.)
445 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
447 # FIXME: __os_install_post will strip the rlibs
448 # -- should we find a way to preserve debuginfo?
450 # Remove unwanted documentation files (we already package them)
451 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
452 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
453 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
454 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
456 # Sanitize the HTML documentation
457 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
458 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
460 # Move rust-gdb's python scripts so they're noarch
461 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
462 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
464 # We don't need stdlib source
465 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
467 # Create the path for crate-devel packages
468 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
471 rm -rf $RPM_BUILD_ROOT
473 %post -p /sbin/ldconfig
474 %postun -p /sbin/ldconfig
477 %defattr(644,root,root,755)
478 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md
479 %attr(755,root,root) %{_bindir}/rustc
480 %attr(755,root,root) %{_bindir}/rustdoc
481 %attr(755,root,root) %{_bindir}/rustfmt
482 %attr(755,root,root) %{_libdir}/librustc_driver-*.so
483 %attr(755,root,root) %{_libdir}/libstd-*.so
484 %attr(755,root,root) %{_libdir}/libtest-*.so
485 %{_mandir}/man1/rustc.1*
486 %{_mandir}/man1/rustdoc.1*
490 %defattr(644,root,root,755)
491 %{rustlibdir}/%{rust_triple}/analysis
494 %defattr(644,root,root,755)
495 %dir %{rustlibdir}/%{rust_triple}
496 %dir %{rustlibdir}/%{rust_triple}/lib
497 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
498 %{rustlibdir}/%{rust_triple}/lib/*.rlib
500 %files debugger-common
501 %defattr(644,root,root,755)
502 %dir %{_datadir}/%{name}
503 %dir %{_datadir}/%{name}/etc
504 %{_datadir}/%{name}/etc/lldb_commands
505 %{_datadir}/%{name}/etc/rust_types.py
508 %defattr(644,root,root,755)
509 %attr(755,root,root) %{_bindir}/rust-lldb
510 %{_datadir}/%{name}/etc/lldb_*.py*
513 %defattr(644,root,root,755)
514 %attr(755,root,root) %{_bindir}/rust-gdb
515 %attr(755,root,root) %{_bindir}/rust-gdbgui
516 %{_datadir}/%{name}/etc/gdb_*.py*
519 %defattr(644,root,root,755)
520 %attr(755,root,root) %{_bindir}/rls
523 %defattr(644,root,root,755)
524 %dir %{_docdir}/%{name}
525 %doc %{_docdir}/%{name}/html
528 %defattr(644,root,root,755)
529 %attr(755,root,root) %{_bindir}/cargo
530 %attr(755,root,root) %{_bindir}/cargo-clippy
531 %attr(755,root,root) %{_bindir}/cargo-fmt
532 %attr(755,root,root) %{_bindir}/clippy-driver
533 %attr(755,root,root) %{_libexecdir}/cargo-credential-1password
534 %{_mandir}/man1/cargo*.1*
535 %dir %{_datadir}/cargo
536 %dir %{_datadir}/cargo/registry
538 %files -n bash-completion-cargo
539 %defattr(644,root,root,755)
540 %{_sysconfdir}/bash_completion.d/cargo
542 %files -n zsh-completion-cargo
543 %defattr(644,root,root,755)
544 %{zsh_compdir}/_cargo