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.json
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.68.2
25 %define bootstrap_cargo %{bootstrap_rust}
26 %define bootstrap_date 2023-03-28
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: 2fac6c46422e743f5f05287e89e72f22
46 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
47 # Source1-md5: b82ae74e630a849d6675b93ddf0ed6ca
48 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
49 # Source2-md5: a2affbb1e831228c71f972a270717ce3
50 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
51 # Source3-md5: 489073dd8a8380c28a570bf70c9fbd6e
52 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
53 # Source4-md5: bb43d3fca2893f2de0b892e0f4a8fdb3
54 Source5: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-armv7-unknown-linux-gnueabihf.tar.xz
55 # Source5-md5: 5691b194302d66b40c3e4eee0eeb1813
56 Patch0: llvm-tools-install.patch
57 URL: https://www.rust-lang.org/
59 BuildRequires: cmake >= 3.4.3
61 %ifarch %{arm} %{mips32} %{ppc}
62 BuildRequires: libatomic-devel
64 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
66 BuildRequires: python3
67 BuildRequires: python3-modules
68 BuildRequires: rpm-build >= 4.6
69 BuildRequires: rpmbuild(macros) >= 1.752
71 BuildRequires: curl-devel
72 BuildRequires: libgit2-devel >= 1.4.0
73 BuildRequires: libstdc++-devel
74 %if %{with system_llvm}
75 BuildRequires: llvm >= 14.0
76 BuildRequires: llvm-devel >= 14.0
78 BuildRequires: openssl-devel >= 1.0.1
79 BuildRequires: tar >= 1:1.22
81 BuildRequires: xz-devel
82 BuildRequires: zlib-devel
84 %if %{without bootstrap}
85 BuildRequires: %{name} >= %{bootstrap_rust}
86 BuildRequires: cargo >= %{bootstrap_cargo}
87 BuildConflicts: %{name} > %{version}
90 BuildRequires: glibc-devel(x86-64)
91 BuildRequires: glibc-devel(x86-x32)
92 %if "%{_host_cpu}" == "x86_64"
93 # building on x86_64 host with --target x32-pld-linux
94 BuildRequires: curl-devel
95 BuildRequires: gcc-multilib-x32
96 BuildRequires: libgit2-devel >= 1.4.0
97 BuildRequires: libstdc++-devel
98 %{?with_system_llvm:BuildRequires: llvm-devel >= 14.0}
99 BuildRequires: openssl-devel >= 1.0.1
100 BuildRequires: xz-devel
101 BuildRequires: zlib-devel
103 # building x86_64-hosted crosscompiler on x32 host
104 BuildRequires: curl-devel(x86-64)
105 BuildRequires: curl-devel(x86-x32)
106 BuildRequires: gcc-multilib-64
107 BuildRequires: libgit2-devel(x86-64) >= 1.4.0
108 BuildRequires: libgit2-devel(x86-x32) >= 1.4.0
109 BuildRequires: libstdc++-multilib-64-devel
110 %if %{with system_llvm}
111 BuildRequires: llvm-devel(x86-64) >= 14.0
112 BuildRequires: llvm-devel(x86-x32) >= 14.0
114 BuildRequires: openssl-devel(x86-64)
115 BuildRequires: openssl-devel(x86-x32)
116 BuildRequires: xz-devel(x86-64)
117 BuildRequires: xz-devel(x86-x32)
118 BuildRequires: zlib-devel(x86-64)
119 BuildRequires: zlib-devel(x86-x32)
122 # The C compiler is needed at runtime just for linking. Someday rustc might
123 # invoke the linker directly, and then we'll only need binutils.
124 # https://github.com/rust-lang/rust/issues/11937
126 Requires: %{name}-std%{?_isa} = %{version}-%{release}
128 Requires: %{name}-std(x86-64) = %{version}-%{release}
129 Requires: gcc-multilib-64
131 Obsoletes: rust-analysis < 1.69.0
132 # Only x86_64 and i686 are Tier 1 platforms at this time.
133 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
134 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
135 ExclusiveArch: %{x8664} %{ix86} x32 aarch64 armv6hl armv7hl armv7hnl
136 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
139 %define rust_triple x86_64-unknown-linux-gnux32
140 %define rust_host_triple x86_64-unknown-linux-gnu
141 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
142 # libs in _libdir are x86_64 64bit
144 %define _libdir %{_prefix}/lib64
147 %define rust_triple arm-unknown-linux-gnueabihf
148 %define rust_host_triple %{rust_triple}
149 %define rust_bootstrap_triple %{rust_triple}
151 %ifarch armv7hl armv7hnl
152 %define rust_triple armv7-unknown-linux-gnueabihf
153 %define rust_host_triple %{rust_triple}
154 %define rust_bootstrap_triple %{rust_triple}
155 %define rust_suppl_targets thumbv7neon-unknown-linux-gnueabihf
157 %define rust_triple %{_target_cpu}-unknown-linux-gnu
158 %define rust_host_triple %{rust_triple}
159 %define rust_bootstrap_triple %{rust_triple}
164 %define rust_targets %rust_triple %{?rust_suppl_targets}
166 %if %{without bootstrap}
167 %define local_rust_root %{_prefix}
169 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
170 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
173 # We're going to override --libdir when configuring to get rustlib into a
174 # common path, but we'll fix the shared libraries during install.
175 # Without this ugly hack, rust would not be able to build itself
176 # for non-bootstrap build, lib64 is just too complicated for it.
177 %define common_libdir %{_prefix}/lib
178 %define rustlibdir %{common_libdir}/rustlib
180 # once_call/once_callable non-function libstdc++ symbols
181 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
183 # ALL Rust libraries are private, because they don't keep an ABI.
184 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
185 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
191 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }%{__python3} ./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
196 Rust is a systems programming language that runs blazingly fast,
197 prevents segfaults, and guarantees thread safety.
199 This package includes the Rust compiler, standard library, and
200 documentation generator.
202 %description -l pl.UTF-8
203 Rust to systemowy język programowania działający bardzo szybko,
204 zapobiegający naruszeniom ochrony pamięci i gwarantujący
205 bezpieczną wielowątkowość.
208 Summary: Standard library for Rust
209 Summary(pl.UTF-8): Standardowa biblioteka Rusta
210 Group: Development/Tools
211 Requires: %{name} = %{version}-%{release}
214 Standard library for Rust.
216 %description std -l pl.UTF-8
217 Standardowa biblioteka Rusta.
220 Summary: Implementation of Language Server Protocol for Rust
221 Summary(pl.UTF-8): Implementacja Language Server Protocol dla Rusta
222 Group: Development/Tools
223 Requires: %{name} = %{version}-%{release}
224 Obsoletes: rust-rls < 1.65.0
226 %description analyzer
227 Implementation of Language Server Protocol for Rust.
229 %description analyzer -l pl.UTF-8
230 Implementacja Language Server Protocol dla Rusta.
232 %package debugger-common
233 Summary: Common debugger pretty printers for Rust
234 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
235 Group: Development/Debuggers
238 %description debugger-common
239 This package includes the common functionality for rust-gdb and
242 %description debugger-common -l pl.UTF-8
243 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
246 Summary: GDB pretty printers for Rust
247 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
248 Group: Development/Debuggers
249 Requires: %{name}-debugger-common = %{version}-%{release}
254 This package includes the rust-gdb script, which allows easier
255 debugging of Rust programs.
257 %description gdb -l pl.UTF-8
258 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
259 odpluskwianie programów w języku Rust.
262 Summary: LLDB pretty printers for Rust
263 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
264 Group: Development/Debuggers
265 Requires: %{name}-debugger-common = %{version}-%{release}
270 This package includes the rust-lldb script, which allows easier
271 debugging of Rust programs.
273 %description lldb -l pl.UTF-8
274 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
275 odpluskwianie programów w języku Rust.
278 Summary: Documentation for Rust
279 Summary(pl.UTF-8): Dokumentacja do Rusta
284 This package includes HTML documentation for the Rust programming
285 language and its standard library.
287 %description doc -l pl.UTF-8
288 Ten pakiet zawiera dokumentację w formacie HTML do języka
289 programowania Rust i jego biblioteki standardowej.
292 Summary: Rust's package manager and build tool
293 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
294 Group: Development/Tools
295 Requires: %{name}%{?_isa}
297 %description -n cargo
298 Cargo is a tool that allows Rust projects to declare their various
299 dependencies and ensure that you'll always get a repeatable build.
301 %description -n cargo -l pl.UTF-8
302 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
303 zależności i zapewniające powtarzalność procesu budowania.
305 %package -n bash-completion-cargo
306 Summary: Bash completion for cargo command
307 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
308 Group: Applications/Shells
309 Requires: %{name} = %{version}-%{release}
310 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}
327 %description -n zsh-completion-cargo
328 Zsh completion for cargo command.
330 %description -n zsh-completion-cargo -l pl.UTF-8
331 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
334 %setup -q -n %{rustc_package}
337 %if %{with bootstrap}
350 %ifarch armv7hl armv7hnl
353 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
354 %{bootstrap_root}-root/install.sh \
355 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
356 --prefix=%{local_rust_root} \
358 test -f %{local_rust_root}/bin/cargo
359 test -f %{local_rust_root}/bin/rustc
363 # We're disabling jemalloc, but rust-src still wants it.
364 #%{__rm} -r src/jemalloc
365 %if %{with system_llvm}
366 %{__rm} -r src/llvm-project
367 mkdir -p src/llvm-project/libunwind
370 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
371 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
374 # cargo has hardcoded libexec path - honour rpm _libexecdir
375 %if "%{_libexecdir}" != "%{_prefix}/libexec"
376 suffix="%(echo "%{_libexecdir}" | %{__sed} -e 's,^%{_prefix}/,,')"
377 %{__sed} -i -e 's,"libexec","'${suffix}'",' \
378 src/bootstrap/dist.rs \
379 src/tools/cargo/src/cargo/ops/registry/auth.rs
380 %{__sed} -i -e 's,libexec/,'${suffix}'/,' src/tools/cargo/tests/testsuite/credential_process.rs
383 # The configure macro will modify some autoconf-related files, which upsets
384 # cargo when it tries to verify checksums in those files. If we just truncate
385 # that file list, cargo won't have anything to complain about.
386 find vendor -name .cargo-checksum.json \
387 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
391 export CXX="%{__cxx}"
394 --build=%{rust_bootstrap_triple} \
395 --host=%{rust_host_triple} \
396 --target="%(echo %rust_targets | tr ' ' ,)" \
397 --libdir=%{common_libdir} \
398 --disable-codegen-tests \
399 --disable-debuginfo-lines \
400 %if %{with full_debuginfo}
401 --disable-debuginfo-only-std \
404 --enable-debuginfo-only-std \
405 --disable-debuginfo \
408 --disable-option-checking \
411 --enable-llvm-link-shared \
413 --local-rust-root=%{local_rust_root} \
414 --llvm-root=%{_prefix} \
415 --release-channel=%{channel} \
416 --set=llvm.static-libstdcpp=false
418 export RUST_BACKTRACE=full
421 %{?with_tests:%x_py test}
424 rm -rf $RPM_BUILD_ROOT
427 export CXX="%{__cxx}"
429 export DESTDIR=$RPM_BUILD_ROOT
432 # Make sure the shared libraries are in the proper libdir
433 %if "%{_libdir}" != "%{common_libdir}"
434 mkdir -p %{buildroot}%{_libdir}
435 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
436 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
439 # The shared libraries should be executable for debuginfo extraction.
440 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
442 # The libdir libraries are identical to those under rustlib/. It's easier on
443 # library loading if we keep them in libdir, but we do need them in rustlib/
444 # to support dynamic linking for compiler plugins, so we'll symlink.
445 for rust_target in %rust_targets; do
446 for l in libstd libtest ; do
447 liblib=$RPM_BUILD_ROOT%{_libdir}/${l}-*.so
448 libstd=$RPM_BUILD_ROOT%{rustlibdir}/${rust_target}/lib/${l}-*.so
449 if [ "$(basename ${liblib})" = "$(basename ${libstd})" ]; then
450 ln -vfsr ${libstd} $RPM_BUILD_ROOT%{_libdir}/
455 # Remove installer artifacts (manifests, uninstall scripts, etc.)
456 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
458 # FIXME: __os_install_post will strip the rlibs
459 # -- should we find a way to preserve debuginfo?
461 # Remove unwanted documentation files (we already package them)
462 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
463 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
464 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
465 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
467 # Sanitize the HTML documentation
468 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
469 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
471 # Move rust-gdb's python scripts so they're noarch
472 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
473 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
475 # We don't need stdlib source
476 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
478 # Create the path for crate-devel packages
479 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
482 rm -rf $RPM_BUILD_ROOT
484 %post -p /sbin/ldconfig
485 %postun -p /sbin/ldconfig
488 %defattr(644,root,root,755)
489 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md
490 %attr(755,root,root) %{_bindir}/rust-demangler
491 %attr(755,root,root) %{_bindir}/rustc
492 %attr(755,root,root) %{_bindir}/rustdoc
493 %attr(755,root,root) %{_bindir}/rustfmt
494 %attr(755,root,root) %{_libdir}/librustc_driver-*.so
495 %attr(755,root,root) %{_libdir}/libstd-*.so
496 %attr(755,root,root) %{_libdir}/libtest-*.so
497 %{_mandir}/man1/rustc.1*
498 %{_mandir}/man1/rustdoc.1*
502 %defattr(644,root,root,755)
503 %(for rust_target in %rust_targets; do
505 %dir %{rustlibdir}/$rust_target
506 %dir %{rustlibdir}/$rust_target/lib
507 %attr(755,root,root) %{rustlibdir}/$rust_target/lib/*.so
508 %{rustlibdir}/$rust_target/lib/*.rlib
514 %defattr(644,root,root,755)
515 %attr(755,root,root) %{_bindir}/rust-analyzer
516 %attr(755,root,root) %{_libexecdir}/rust-analyzer-proc-macro-srv
518 %files debugger-common
519 %defattr(644,root,root,755)
520 %dir %{_datadir}/%{name}
521 %dir %{_datadir}/%{name}/etc
522 %{_datadir}/%{name}/etc/lldb_commands
523 %{_datadir}/%{name}/etc/rust_types.py
526 %defattr(644,root,root,755)
527 %attr(755,root,root) %{_bindir}/rust-lldb
528 %{_datadir}/%{name}/etc/lldb_*.py*
531 %defattr(644,root,root,755)
532 %attr(755,root,root) %{_bindir}/rust-gdb
533 %attr(755,root,root) %{_bindir}/rust-gdbgui
534 %{_datadir}/%{name}/etc/gdb_*.py*
537 %defattr(644,root,root,755)
538 %dir %{_docdir}/%{name}
539 %doc %{_docdir}/%{name}/html
542 %defattr(644,root,root,755)
543 %attr(755,root,root) %{_bindir}/cargo
544 %attr(755,root,root) %{_bindir}/cargo-clippy
545 %attr(755,root,root) %{_bindir}/cargo-fmt
546 %attr(755,root,root) %{_bindir}/clippy-driver
547 %attr(755,root,root) %{_libexecdir}/cargo-credential-1password
548 %{_mandir}/man1/cargo*.1*
549 %dir %{_datadir}/cargo
550 %dir %{_datadir}/cargo/registry
552 %files -n bash-completion-cargo
553 %defattr(644,root,root,755)
554 %{_sysconfdir}/bash_completion.d/cargo
556 %files -n zsh-completion-cargo
557 %defattr(644,root,root,755)
558 %{zsh_compdir}/_cargo