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.txt
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.54.0
26 %define bootstrap_cargo 1.54.0
27 %define bootstrap_date 2021-07-29
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: bb05ec6801c08eb1353fa7316e02ee26
47 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
48 # Source1-md5: 12cfee7377dafd0583fe53d7ed5d45fb
49 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
50 # Source2-md5: ec48712d83df42479eebca05bca06201
51 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
52 # Source3-md5: b8c06e3435e8f37cfd8911273255019c
53 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
54 # Source4-md5: ed4754c59f8476fa60e8266002b8f1ba
55 Source5: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-armv7-unknown-linux-gnueabihf.tar.xz
56 # Source5-md5: 9ceab67a2b1299a9314756280d90548b
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: python >= 1:2.7
64 BuildRequires: rpmbuild(macros) >= 1.752
66 BuildRequires: curl-devel
67 BuildRequires: libgit2-devel >= 1.1.0
68 BuildRequires: libstdc++-devel
69 %if %{with system_llvm}
70 BuildRequires: llvm >= 10.0
71 BuildRequires: llvm-devel >= 10.0
73 BuildRequires: openssl-devel >= 1.0.1
74 BuildRequires: tar >= 1:1.22
76 BuildRequires: zlib-devel
78 %if %{without bootstrap}
79 BuildRequires: %{name} >= %{bootstrap_rust}
80 BuildRequires: cargo >= %{bootstrap_cargo}
81 BuildConflicts: %{name} > %{version}
84 BuildRequires: glibc-devel(x86-64)
85 BuildRequires: glibc-devel(x86-x32)
86 %if "%{_host_cpu}" == "x86_64"
87 # building on x86_64 host with --target x32-pld-linux
88 BuildRequires: curl-devel
89 BuildRequires: gcc-multilib-x32
90 BuildRequires: libgit2-devel >= 1.1.0
91 BuildRequires: libstdc++-devel
92 %{?with_system_llvm:BuildRequires: llvm-devel >= 10.0}
93 BuildRequires: openssl-devel >= 1.0.1
94 BuildRequires: zlib-devel
96 # building x86_64-hosted crosscompiler on x32 host
97 BuildRequires: curl-devel(x86-64)
98 BuildRequires: curl-devel(x86-x32)
99 BuildRequires: gcc-multilib-64
100 BuildRequires: libgit2-devel(x86-64) >= 1.1.0
101 BuildRequires: libgit2-devel(x86-x32) >= 1.1.0
102 BuildRequires: libstdc++-multilib-64-devel
103 %if %{with system_llvm}
104 BuildRequires: llvm-devel(x86-64) >= 10.0
105 BuildRequires: llvm-devel(x86-x32) >= 10.0
107 BuildRequires: openssl-devel(x86-64)
108 BuildRequires: openssl-devel(x86-x32)
109 BuildRequires: zlib-devel(x86-64)
110 BuildRequires: zlib-devel(x86-x32)
113 # The C compiler is needed at runtime just for linking. Someday rustc might
114 # invoke the linker directly, and then we'll only need binutils.
115 # https://github.com/rust-lang/rust/issues/11937
117 Requires: %{name}-std%{?_isa} = %{version}-%{release}
119 Requires: %{name}-std(x86-64) = %{version}-%{release}
121 Obsoletes: rust-analyzer < 1.53.0
122 # Only x86_64 and i686 are Tier 1 platforms at this time.
123 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
124 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
125 ExclusiveArch: %{x8664} %{ix86} x32 aarch64 armv6hl armv7hl armv7hnl
126 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
129 %define rust_triple x86_64-unknown-linux-gnux32
130 %define rust_host_triple x86_64-unknown-linux-gnu
131 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
132 # libs in _libdir are x86_64 64bit
134 %define _libdir %{_prefix}/lib64
137 %define rust_triple arm-unknown-linux-gnueabihf
138 %define rust_host_triple %{rust_triple}
139 %define rust_bootstrap_triple %{rust_triple}
141 %ifarch armv7hl armv7hnl
142 %define rust_triple armv7-unknown-linux-gnueabihf
143 %define rust_host_triple %{rust_triple}
144 %define rust_bootstrap_triple %{rust_triple}
146 %define rust_triple %{_target_cpu}-unknown-linux-gnu
147 %define rust_host_triple %{rust_triple}
148 %define rust_bootstrap_triple %{rust_triple}
153 %if %{without bootstrap}
154 %define local_rust_root %{_prefix}
156 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
157 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
160 # We're going to override --libdir when configuring to get rustlib into a
161 # common path, but we'll fix the shared libraries during install.
162 # Without this ugly hack, rust would not be able to build itself
163 # for non-bootstrap build, lib64 is just too complicated for it.
164 %define common_libdir %{_prefix}/lib
165 %define rustlibdir %{common_libdir}/rustlib
167 # once_call/once_callable non-function libstdc++ symbols
168 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
170 # ALL Rust libraries are private, because they don't keep an ABI.
171 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
172 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
178 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
183 Rust is a systems programming language that runs blazingly fast,
184 prevents segfaults, and guarantees thread safety.
186 This package includes the Rust compiler, standard library, and
187 documentation generator.
189 %description -l pl.UTF-8
190 Rust to systemowy język programowania działający bardzo szybko,
191 zapobiegający naruszeniom ochrony pamięci i gwarantujący
192 bezpieczną wielowątkowość.
195 Summary: Metadata about the standard library
196 Summary(pl.UTF-8): Metadane o standardowej bibliotece
197 Group: Development/Tools
198 Requires: %{name} = %{version}-%{release}
200 %description analysis
201 Metadata about the standard library.
203 %description analysis -l pl.UTF-8
204 Metadane o standardowej bibliotece.
207 Summary: Standard library for Rust
208 Summary(pl.UTF-8): Standardowa biblioteka Rusta
209 Group: Development/Tools
210 Requires: %{name} = %{version}-%{release}
213 Standard library for Rust.
215 %description std -l pl.UTF-8
216 Standardowa biblioteka Rusta.
218 %package debugger-common
219 Summary: Common debugger pretty printers for Rust
220 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
221 Group: Development/Debuggers
224 %description debugger-common
225 This package includes the common functionality for rust-gdb and
228 %description debugger-common -l pl.UTF-8
229 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
232 Summary: GDB pretty printers for Rust
233 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
234 Group: Development/Debuggers
235 Requires: %{name}-debugger-common = %{version}-%{release}
240 This package includes the rust-gdb script, which allows easier
241 debugging of Rust programs.
243 %description gdb -l pl.UTF-8
244 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
245 odpluskwianie programów w języku Rust.
248 Summary: LLDB pretty printers for Rust
249 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
250 Group: Development/Debuggers
251 Requires: %{name}-debugger-common = %{version}-%{release}
256 This package includes the rust-lldb script, which allows easier
257 debugging of Rust programs.
259 %description lldb -l pl.UTF-8
260 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
261 odpluskwianie programów w języku Rust.
264 Summary: Rust Language Server for IDE integration
265 Summary(pl.UTF-8): Rust Language Server do integracji z IDE
266 Group: Development/Tools
267 Requires: %{name} = %{version}-%{release}
268 Requires: %{name}-analysis = %{version}-%{release}
271 Rust Language Server for IDE integration.
273 %description rls -l pl.UTF-8
274 Rust Language Server do integracji z IDE.
277 Summary: Documentation for Rust
278 Summary(pl.UTF-8): Dokumentacja do Rusta
283 This package includes HTML documentation for the Rust programming
284 language and its standard library.
286 %description doc -l pl.UTF-8
287 Ten pakiet zawiera dokumentację w formacie HTML do języka
288 programowania Rust i jego biblioteki standardowej.
291 Summary: Rust's package manager and build tool
292 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
293 Group: Development/Tools
294 Requires: %{name}%{?_isa}
296 %description -n cargo
297 Cargo is a tool that allows Rust projects to declare their various
298 dependencies and ensure that you'll always get a repeatable build.
300 %description -n cargo -l pl.UTF-8
301 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
302 zależności i zapewniające powtarzalność procesu budowania.
304 %package -n bash-completion-cargo
305 Summary: Bash completion for cargo command
306 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
307 Group: Applications/Shells
308 Requires: %{name} = %{version}-%{release}
309 Requires: bash-completion
311 %description -n bash-completion-cargo
312 Bash completion for cargo command.
314 %description -n bash-completion-cargo -l pl.UTF-8
315 Bashowe dopełnianie parametrów polecenia cargo.
317 %package -n zsh-completion-cargo
318 Summary: Zsh completion for cargo command
319 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
320 Group: Applications/Shells
321 Requires: %{name} = %{version}-%{release}
324 %description -n zsh-completion-cargo
325 Zsh completion for cargo command.
327 %description -n zsh-completion-cargo -l pl.UTF-8
328 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
331 %setup -q -n %{rustc_package}
333 %if %{with bootstrap}
346 %ifarch armv7hl armv7hnl
349 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
350 %{bootstrap_root}-root/install.sh \
351 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
352 --prefix=%{local_rust_root} \
354 test -f %{local_rust_root}/bin/cargo
355 test -f %{local_rust_root}/bin/rustc
359 # We're disabling jemalloc, but rust-src still wants it.
360 #%{__rm} -r src/jemalloc
361 %if %{with system_llvm}
362 %{__rm} -r src/llvm-project
363 mkdir -p src/llvm-project/libunwind
366 # extract bundled licenses for packaging
367 sed -e '/*\//q' library/backtrace/crates/backtrace-sys/src/libbacktrace/backtrace.h \
368 >library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
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 --build=%{rust_bootstrap_triple} \
392 --host=%{rust_host_triple} \
393 --target=%{rust_triple} \
394 --libdir=%{common_libdir} \
395 --disable-codegen-tests \
396 --disable-debuginfo-lines \
397 %if %{with full_debuginfo}
398 --disable-debuginfo-only-std \
401 --enable-debuginfo-only-std \
402 --disable-debuginfo \
405 --disable-option-checking \
408 --enable-llvm-link-shared \
410 --local-rust-root=%{local_rust_root} \
411 --llvm-root=%{_prefix} \
412 --release-channel=%{channel}
414 export RUST_BACKTRACE=full
417 %{?with_tests:%x_py test}
420 rm -rf $RPM_BUILD_ROOT
422 export DESTDIR=$RPM_BUILD_ROOT
425 # Make sure the shared libraries are in the proper libdir
426 %if "%{_libdir}" != "%{common_libdir}"
427 mkdir -p %{buildroot}%{_libdir}
428 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
429 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
432 # The shared libraries should be executable for debuginfo extraction.
433 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
435 # The libdir libraries are identical to those under rustlib/. It's easier on
436 # library loading if we keep them in libdir, but we do need them in rustlib/
437 # to support dynamic linking for compiler plugins, so we'll symlink.
438 for l in libstd libtest ; do
439 liblib=$RPM_BUILD_ROOT%{_libdir}/${l}-*.so
440 libstd=$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib/${l}-*.so
441 if [ "$(basename ${liblib})" = "$(basename ${libstd})" ]; then
442 ln -vfsr ${libstd} $RPM_BUILD_ROOT%{_libdir}/
446 # Remove installer artifacts (manifests, uninstall scripts, etc.)
447 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
449 # FIXME: __os_install_post will strip the rlibs
450 # -- should we find a way to preserve debuginfo?
452 # Remove unwanted documentation files (we already package them)
453 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
454 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
455 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
456 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
458 # Sanitize the HTML documentation
459 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
460 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
462 # Move rust-gdb's python scripts so they're noarch
463 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
464 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
466 # We don't need stdlib source
467 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
469 # Create the path for crate-devel packages
470 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
473 rm -rf $RPM_BUILD_ROOT
475 %post -p /sbin/ldconfig
476 %postun -p /sbin/ldconfig
479 %defattr(644,root,root,755)
480 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
481 %attr(755,root,root) %{_bindir}/rustc
482 %attr(755,root,root) %{_bindir}/rustdoc
483 %attr(755,root,root) %{_bindir}/rustfmt
484 %attr(755,root,root) %{_libdir}/librustc_driver-*.so
485 %attr(755,root,root) %{_libdir}/libstd-*.so
486 %attr(755,root,root) %{_libdir}/libtest-*.so
487 %{_mandir}/man1/rustc.1*
488 %{_mandir}/man1/rustdoc.1*
492 %defattr(644,root,root,755)
493 %{rustlibdir}/%{rust_triple}/analysis
496 %defattr(644,root,root,755)
497 %dir %{rustlibdir}/%{rust_triple}
498 %dir %{rustlibdir}/%{rust_triple}/lib
499 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
500 %{rustlibdir}/%{rust_triple}/lib/*.rlib
502 %files debugger-common
503 %defattr(644,root,root,755)
504 %dir %{_datadir}/%{name}
505 %dir %{_datadir}/%{name}/etc
506 %{_datadir}/%{name}/etc/lldb_commands
507 %{_datadir}/%{name}/etc/rust_types.py
510 %defattr(644,root,root,755)
511 %attr(755,root,root) %{_bindir}/rust-lldb
512 %{_datadir}/%{name}/etc/lldb_*.py*
515 %defattr(644,root,root,755)
516 %attr(755,root,root) %{_bindir}/rust-gdb
517 %attr(755,root,root) %{_bindir}/rust-gdbgui
518 %{_datadir}/%{name}/etc/gdb_*.py*
521 %defattr(644,root,root,755)
522 %attr(755,root,root) %{_bindir}/rls
525 %defattr(644,root,root,755)
526 %dir %{_docdir}/%{name}
527 %doc %{_docdir}/%{name}/html
530 %defattr(644,root,root,755)
531 %attr(755,root,root) %{_bindir}/cargo
532 %attr(755,root,root) %{_bindir}/cargo-clippy
533 %attr(755,root,root) %{_bindir}/cargo-fmt
534 %attr(755,root,root) %{_bindir}/clippy-driver
535 %attr(755,root,root) %{_libexecdir}/cargo-credential-1password
536 %{_mandir}/man1/cargo*.1*
537 %dir %{_datadir}/cargo
538 %dir %{_datadir}/cargo/registry
540 %files -n bash-completion-cargo
541 %defattr(644,root,root,755)
542 %{_sysconfdir}/bash_completion.d/cargo
544 %files -n zsh-completion-cargo
545 %defattr(644,root,root,755)
546 %{zsh_compdir}/_cargo