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.51.0
25 %define bootstrap_cargo 1.51.0
26 %define bootstrap_date 2021-03-25
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: f95ca614a531b3c1edd4918eaa329732
46 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
47 # Source1-md5: 7640d6538716c6492e56f361e3af0631
48 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
49 # Source2-md5: 64f117dc1ae1543c8910eaa9a971ddd4
50 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
51 # Source3-md5: 3ac79872671df7ea0215fd351f52ffcf
52 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
53 # Source4-md5: f624772d7c7ba2e83a51b4e9c1657f7b
54 Patch0: %{name}-x32.patch
55 URL: https://www.rust-lang.org/
57 BuildRequires: cmake >= 3.4.3
59 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
61 BuildRequires: python >= 1:2.7
62 BuildRequires: rpmbuild(macros) >= 1.752
64 BuildRequires: curl-devel
65 BuildRequires: libgit2-devel
66 BuildRequires: libstdc++-devel
67 %{?with_system_llvm:BuildRequires: llvm-devel >= 9.0}
68 BuildRequires: openssl-devel >= 1.0.1
69 BuildRequires: tar >= 1:1.22
71 BuildRequires: zlib-devel
73 %if %{without bootstrap}
74 BuildRequires: %{name} >= %{bootstrap_rust}
75 BuildRequires: cargo >= %{bootstrap_cargo}
76 BuildConflicts: %{name} > %{version}
79 BuildRequires: glibc-devel(x32)
80 BuildRequires: glibc-devel(x86_64)
81 %if "%{_host_cpu}" == "x86_64"
82 # building on x86_64 host with --target x32-pld-linux
83 BuildRequires: curl-devel
84 BuildRequires: gcc-multilib-x32
85 BuildRequires: libgit2-devel
86 BuildRequires: libstdc++-devel
87 %{?with_system_llvm:BuildRequires: llvm-devel >= 9.0}
88 BuildRequires: openssl-devel >= 1.0.1
89 BuildRequires: zlib-devel
91 # building x86_64-hosted crosscompiler on x32 host
92 BuildRequires: gcc-multilib-64
93 BuildRequires: libstdc++-multilib-64-devel
94 # how to specify? - rpm.org adds arch provides on packages (__isa), uncomment once we switch
95 #BuildRequires: curl-devel(x86-64)
96 #BuildRequires: libgit2-devel(x86-64)
97 #BuildRequires: llvm-devel(x86-64)>= 7.0
98 #BuildRequires: openssl-devel(x86-64)
99 #BuildRequires: zlib-devel(x86-64)
102 # The C compiler is needed at runtime just for linking. Someday rustc might
103 # invoke the linker directly, and then we'll only need binutils.
104 # https://github.com/rust-lang/rust/issues/11937
106 # Only x86_64 and i686 are Tier 1 platforms at this time.
107 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
108 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
109 ExclusiveArch: %{x8664} %{ix86} x32 aarch64 armv6hl armv7hl armv7hnl
110 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
113 %define rust_triple x86_64-unknown-linux-gnux32
114 %define rust_host_triple x86_64-unknown-linux-gnu
115 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
117 %ifarch armv6hl armv7hl armv7hnl
118 %define rust_triple arm-unknown-linux-gnueabihf
119 %define rust_host_triple %{rust_triple}
120 %define rust_bootstrap_triple %{rust_triple}
122 %define rust_triple %{_target_cpu}-unknown-linux-gnu
123 %define rust_host_triple %{rust_triple}
124 %define rust_bootstrap_triple %{rust_triple}
128 %if %{without bootstrap}
129 %define local_rust_root %{_prefix}
131 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
132 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
135 # We're going to override --libdir when configuring to get rustlib into a
136 # common path, but we'll fix the shared libraries during install.
137 # Without this ugly hack, rust would not be able to build itself
138 # for non-bootstrap build, lib64 is just too complicated for it.
139 %define common_libdir %{_prefix}/lib
140 %define rustlibdir %{common_libdir}/rustlib
142 # once_call/once_callable non-function libstdc++ symbols
143 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
145 # ALL Rust libraries are private, because they don't keep an ABI.
146 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
147 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
153 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
158 Rust is a systems programming language that runs blazingly fast,
159 prevents segfaults, and guarantees thread safety.
161 This package includes the Rust compiler, standard library, and
162 documentation generator.
164 %description -l pl.UTF-8
165 Rust to systemowy język programowania działający bardzo szybko,
166 zapobiegający naruszeniom ochrony pamięci i gwarantujący
167 bezpieczną wielowątkowość.
170 Summary: Implementation of Language Server Protocol for Rust
171 Summary(pl.UTF-8): Implementacja Language Server Protocol dla Rusta
172 Group: Development/Tools
173 Requires: %{name} = %{version}-%{release}
175 %description analyzer
176 Implementation of Language Server Protocol for Rust.
178 %description analyzer -l pl.UTF-8
179 Implementacja Language Server Protocol dla Rusta.
181 %package debugger-common
182 Summary: Common debugger pretty printers for Rust
183 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
184 Group: Development/Debuggers
187 %description debugger-common
188 This package includes the common functionality for rust-gdb and
191 %description debugger-common -l pl.UTF-8
192 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
195 Summary: GDB pretty printers for Rust
196 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
197 Group: Development/Debuggers
198 Requires: %{name}-debugger-common = %{version}-%{release}
203 This package includes the rust-gdb script, which allows easier
204 debugging of Rust programs.
206 %description gdb -l pl.UTF-8
207 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
208 odpluskwianie programów w języku Rust.
211 Summary: LLDB pretty printers for Rust
212 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
213 Group: Development/Debuggers
214 Requires: %{name}-debugger-common = %{version}-%{release}
219 This package includes the rust-lldb script, which allows easier
220 debugging of Rust programs.
222 %description lldb -l pl.UTF-8
223 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
224 odpluskwianie programów w języku Rust.
227 Summary: Rust Language Server for IDE integration
228 Summary(pl.UTF-8): Rust Language Server do integracji z IDE
229 Group: Development/Tools
230 Requires: %{name} = %{version}-%{release}
233 Rust Language Server for IDE integration.
235 %description rls -l pl.UTF-8
236 Rust Language Server do integracji z IDE.
239 Summary: Documentation for Rust
240 Summary(pl.UTF-8): Dokumentacja do Rusta
245 This package includes HTML documentation for the Rust programming
246 language and its standard library.
248 %description doc -l pl.UTF-8
249 Ten pakiet zawiera dokumentację w formacie HTML do języka
250 programowania Rust i jego biblioteki standardowej.
253 Summary: Rust's package manager and build tool
254 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
255 Group: Development/Tools
258 %description -n cargo
259 Cargo is a tool that allows Rust projects to declare their various
260 dependencies and ensure that you'll always get a repeatable build.
262 %description -n cargo -l pl.UTF-8
263 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
264 zależności i zapewniające powtarzalność procesu budowania.
266 %package -n bash-completion-cargo
267 Summary: Bash completion for cargo command
268 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
269 Group: Applications/Shells
270 Requires: %{name} = %{version}-%{release}
271 Requires: bash-completion
273 %description -n bash-completion-cargo
274 Bash completion for cargo command.
276 %description -n bash-completion-cargo -l pl.UTF-8
277 Bashowe dopełnianie parametrów polecenia cargo.
279 %package -n zsh-completion-cargo
280 Summary: Zsh completion for cargo command
281 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
282 Group: Applications/Shells
283 Requires: %{name} = %{version}-%{release}
286 %description -n zsh-completion-cargo
287 Zsh completion for cargo command.
289 %description -n zsh-completion-cargo -l pl.UTF-8
290 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
293 %setup -q -n %{rustc_package}
294 # irrelevant when not building rustc for x32
297 %if %{with bootstrap}
307 %ifarch armv6hl armv7hl armv7hnl
310 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
311 %{bootstrap_root}-root/install.sh \
312 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
313 --prefix=%{local_rust_root} \
315 test -f %{local_rust_root}/bin/cargo
316 test -f %{local_rust_root}/bin/rustc
320 # We're disabling jemalloc, but rust-src still wants it.
321 #%{__rm} -r src/jemalloc
322 %if %{with system_llvm}
323 %{__rm} -r src/llvm-project
324 mkdir -p src/llvm-project/libunwind
327 # extract bundled licenses for packaging
328 sed -e '/*\//q' library/backtrace/crates/backtrace-sys/src/libbacktrace/backtrace.h \
329 >library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
331 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
332 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
335 # The configure macro will modify some autoconf-related files, which upsets
336 # cargo when it tries to verify checksums in those files. If we just truncate
337 # that file list, cargo won't have anything to complain about.
338 find vendor -name .cargo-checksum.json \
339 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
343 --build=%{rust_bootstrap_triple} \
344 --host=%{rust_host_triple} \
345 --target=%{rust_triple} \
346 --libdir=%{common_libdir} \
347 --disable-codegen-tests \
348 --disable-debuginfo-lines \
349 %if %{with full_debuginfo}
350 --disable-debuginfo-only-std \
353 --enable-debuginfo-only-std \
354 --disable-debuginfo \
357 --disable-option-checking \
360 --enable-llvm-link-shared \
362 --local-rust-root=%{local_rust_root} \
363 --llvm-root=%{_prefix} \
364 --release-channel=%{channel}
366 export RUST_BACKTRACE=full
369 %{?with_tests:%x_py test}
372 rm -rf $RPM_BUILD_ROOT
374 export DESTDIR=$RPM_BUILD_ROOT
377 # Make sure the shared libraries are in the proper libdir
378 %if "%{_libdir}" != "%{common_libdir}"
379 mkdir -p %{buildroot}%{_libdir}
380 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
381 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
384 # The shared libraries should be executable for debuginfo extraction.
385 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
387 # The libdir libraries are identical to those under rustlib/. It's easier on
388 # library loading if we keep them in libdir, but we do need them in rustlib/
389 # to support dynamic linking for compiler plugins, so we'll symlink.
390 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
391 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
392 -exec ln -v -f -s -t . '{}' '+')
394 # Remove installer artifacts (manifests, uninstall scripts, etc.)
395 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
397 # FIXME: __os_install_post will strip the rlibs
398 # -- should we find a way to preserve debuginfo?
400 # Remove unwanted documentation files (we already package them)
401 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
402 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
403 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
404 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
406 # Sanitize the HTML documentation
407 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
408 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
410 # Move rust-gdb's python scripts so they're noarch
411 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
412 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
414 # We don't need stdlib source
415 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
417 # Create the path for crate-devel packages
418 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
421 rm -rf $RPM_BUILD_ROOT
423 %post -p /sbin/ldconfig
424 %postun -p /sbin/ldconfig
427 %defattr(644,root,root,755)
428 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
429 %attr(755,root,root) %{_bindir}/miri
430 %attr(755,root,root) %{_bindir}/rustc
431 %attr(755,root,root) %{_bindir}/rustdoc
432 %attr(755,root,root) %{_bindir}/rustfmt
433 %attr(755,root,root) %{_libdir}/librustc*-*.so
434 %attr(755,root,root) %{_libdir}/libstd-*.so
435 %attr(755,root,root) %{_libdir}/libtest-*.so
436 %{_mandir}/man1/rustc.1*
437 %{_mandir}/man1/rustdoc.1*
439 %dir %{rustlibdir}/%{rust_triple}
440 %{rustlibdir}/%{rust_triple}/analysis
441 %dir %{rustlibdir}/%{rust_triple}/lib
442 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
443 %{rustlibdir}/%{rust_triple}/lib/*.rlib
446 %defattr(644,root,root,755)
447 %attr(755,root,root) %{_bindir}/rust-analyzer
449 %files debugger-common
450 %defattr(644,root,root,755)
451 %dir %{_datadir}/%{name}
452 %dir %{_datadir}/%{name}/etc
453 %{_datadir}/%{name}/etc/lldb_commands
454 %{_datadir}/%{name}/etc/rust_types.py
457 %defattr(644,root,root,755)
458 %attr(755,root,root) %{_bindir}/rust-lldb
459 %{_datadir}/%{name}/etc/lldb_*.py*
462 %defattr(644,root,root,755)
463 %attr(755,root,root) %{_bindir}/rust-gdb
464 %attr(755,root,root) %{_bindir}/rust-gdbgui
465 %{_datadir}/%{name}/etc/gdb_*.py*
468 %defattr(644,root,root,755)
469 %attr(755,root,root) %{_bindir}/rls
472 %defattr(644,root,root,755)
473 %dir %{_docdir}/%{name}
474 %doc %{_docdir}/%{name}/html
477 %defattr(644,root,root,755)
478 %attr(755,root,root) %{_bindir}/cargo
479 %attr(755,root,root) %{_bindir}/cargo-clippy
480 %attr(755,root,root) %{_bindir}/cargo-fmt
481 %attr(755,root,root) %{_bindir}/cargo-miri
482 %attr(755,root,root) %{_bindir}/clippy-driver
483 %attr(755,root,root) %{_libexecdir}/cargo-credential-1password
484 %{_mandir}/man1/cargo*.1*
485 %dir %{_datadir}/cargo
486 %dir %{_datadir}/cargo/registry
488 %files -n bash-completion-cargo
489 %defattr(644,root,root,755)
490 %{_sysconfdir}/bash_completion.d/cargo
492 %files -n zsh-completion-cargo
493 %defattr(644,root,root,755)
494 %{zsh_compdir}/_cargo