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
31 Summary: The Rust Programming Language
32 Summary(pl.UTF-8): Język programowania Rust
36 # Licenses: (rust itself) and (bundled libraries)
37 License: (Apache v2.0 or MIT) and (BSD and ISC and MIT)
38 Group: Development/Languages
39 Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
40 # Source0-md5: f95ca614a531b3c1edd4918eaa329732
41 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
42 # Source1-md5: 7640d6538716c6492e56f361e3af0631
43 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
44 # Source2-md5: 64f117dc1ae1543c8910eaa9a971ddd4
45 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
46 # Source3-md5: 3ac79872671df7ea0215fd351f52ffcf
47 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
48 # Source4-md5: f624772d7c7ba2e83a51b4e9c1657f7b
49 Patch0: %{name}-x32.patch
50 URL: https://www.rust-lang.org/
52 BuildRequires: cmake >= 3.4.3
54 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
56 BuildRequires: python >= 1:2.7
57 BuildRequires: rpmbuild(macros) >= 1.752
59 BuildRequires: curl-devel
60 BuildRequires: libgit2-devel
61 BuildRequires: libstdc++-devel
62 %{?with_system_llvm:BuildRequires: llvm-devel >= 9.0}
63 BuildRequires: openssl-devel >= 1.0.1
64 BuildRequires: tar >= 1:1.22
66 BuildRequires: zlib-devel
68 %if %{without bootstrap}
69 BuildRequires: %{name} >= %{bootstrap_rust}
70 BuildRequires: cargo >= %{bootstrap_cargo}
71 BuildConflicts: %{name} > %{version}
74 BuildRequires: glibc-devel(x32)
75 BuildRequires: glibc-devel(x86_64)
76 %if "%{_host_cpu}" == "x86_64"
77 # building on x86_64 host with --target x32-pld-linux
78 BuildRequires: curl-devel
79 BuildRequires: gcc-multilib-x32
80 BuildRequires: libgit2-devel
81 BuildRequires: libstdc++-devel
82 %{?with_system_llvm:BuildRequires: llvm-devel >= 9.0}
83 BuildRequires: openssl-devel >= 1.0.1
84 BuildRequires: zlib-devel
86 # building x86_64-hosted crosscompiler on x32 host
87 BuildRequires: gcc-multilib-64
88 BuildRequires: libstdc++-multilib-64-devel
89 # how to specify? - rpm.org adds arch provides on packages (__isa), uncomment once we switch
90 #BuildRequires: curl-devel(x86-64)
91 #BuildRequires: libgit2-devel(x86-64)
92 #BuildRequires: llvm-devel(x86-64)>= 7.0
93 #BuildRequires: openssl-devel(x86-64)
94 #BuildRequires: zlib-devel(x86-64)
97 # The C compiler is needed at runtime just for linking. Someday rustc might
98 # invoke the linker directly, and then we'll only need binutils.
99 # https://github.com/rust-lang/rust/issues/11937
101 # Only x86_64 and i686 are Tier 1 platforms at this time.
102 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
103 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
104 ExclusiveArch: %{x8664} %{ix86} x32 aarch64 armv6hl armv7hl armv7hnl
105 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
108 %define rust_triple x86_64-unknown-linux-gnux32
109 %define rust_host_triple x86_64-unknown-linux-gnu
110 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
112 %ifarch armv6hl armv7hl armv7hnl
113 %define rust_triple arm-unknown-linux-gnueabihf
114 %define rust_host_triple %{rust_triple}
115 %define rust_bootstrap_triple %{rust_triple}
117 %define rust_triple %{_target_cpu}-unknown-linux-gnu
118 %define rust_host_triple %{rust_triple}
119 %define rust_bootstrap_triple %{rust_triple}
123 %if %{without bootstrap}
124 %define local_rust_root %{_prefix}
126 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
127 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
130 # We're going to override --libdir when configuring to get rustlib into a
131 # common path, but we'll fix the shared libraries during install.
132 # Without this ugly hack, rust would not be able to build itself
133 # for non-bootstrap build, lib64 is just too complicated for it.
134 %define common_libdir %{_prefix}/lib
135 %define rustlibdir %{common_libdir}/rustlib
137 # once_call/once_callable non-function libstdc++ symbols
138 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
140 # ALL Rust libraries are private, because they don't keep an ABI.
141 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
142 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
148 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
153 Rust is a systems programming language that runs blazingly fast,
154 prevents segfaults, and guarantees thread safety.
156 This package includes the Rust compiler, standard library, and
157 documentation generator.
159 %description -l pl.UTF-8
160 Rust to systemowy język programowania działający bardzo szybko,
161 zapobiegający naruszeniom ochrony pamięci i gwarantujący
162 bezpieczną wielowątkowość.
165 Summary: Implementation of Language Server Protocol for Rust
166 Summary(pl.UTF-8): Implementacja Language Server Protocol dla Rusta
167 Group: Development/Tools
168 Requires: %{name} = %{version}-%{release}
170 %description analyzer
171 Implementation of Language Server Protocol for Rust.
173 %description analyzer -l pl.UTF-8
174 Implementacja Language Server Protocol dla Rusta.
176 %package debugger-common
177 Summary: Common debugger pretty printers for Rust
178 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
179 Group: Development/Debuggers
182 %description debugger-common
183 This package includes the common functionality for rust-gdb and
186 %description debugger-common -l pl.UTF-8
187 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
190 Summary: GDB pretty printers for Rust
191 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
192 Group: Development/Debuggers
193 Requires: %{name}-debugger-common = %{version}-%{release}
198 This package includes the rust-gdb script, which allows easier
199 debugging of Rust programs.
201 %description gdb -l pl.UTF-8
202 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
203 odpluskwianie programów w języku Rust.
206 Summary: LLDB pretty printers for Rust
207 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
208 Group: Development/Debuggers
209 Requires: %{name}-debugger-common = %{version}-%{release}
214 This package includes the rust-lldb script, which allows easier
215 debugging of Rust programs.
217 %description lldb -l pl.UTF-8
218 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
219 odpluskwianie programów w języku Rust.
222 Summary: Rust Language Server for IDE integration
223 Summary(pl.UTF-8): Rust Language Server do integracji z IDE
224 Group: Development/Tools
225 Requires: %{name} = %{version}-%{release}
228 Rust Language Server for IDE integration.
230 %description rls -l pl.UTF-8
231 Rust Language Server do integracji z IDE.
234 Summary: Documentation for Rust
235 Summary(pl.UTF-8): Dokumentacja do Rusta
240 This package includes HTML documentation for the Rust programming
241 language and its standard library.
243 %description doc -l pl.UTF-8
244 Ten pakiet zawiera dokumentację w formacie HTML do języka
245 programowania Rust i jego biblioteki standardowej.
248 Summary: Rust's package manager and build tool
249 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
250 Group: Development/Tools
253 %description -n cargo
254 Cargo is a tool that allows Rust projects to declare their various
255 dependencies and ensure that you'll always get a repeatable build.
257 %description -n cargo -l pl.UTF-8
258 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
259 zależności i zapewniające powtarzalność procesu budowania.
261 %package -n bash-completion-cargo
262 Summary: Bash completion for cargo command
263 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
264 Group: Applications/Shells
265 Requires: %{name} = %{version}-%{release}
266 Requires: bash-completion
268 %description -n bash-completion-cargo
269 Bash completion for cargo command.
271 %description -n bash-completion-cargo -l pl.UTF-8
272 Bashowe dopełnianie parametrów polecenia cargo.
274 %package -n zsh-completion-cargo
275 Summary: Zsh completion for cargo command
276 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
277 Group: Applications/Shells
278 Requires: %{name} = %{version}-%{release}
281 %description -n zsh-completion-cargo
282 Zsh completion for cargo command.
284 %description -n zsh-completion-cargo -l pl.UTF-8
285 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
288 %setup -q -n %{rustc_package}
289 # irrelevant when not building rustc for x32
292 %if %{with bootstrap}
302 %ifarch armv6hl armv7hl armv7hnl
305 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
306 %{bootstrap_root}-root/install.sh \
307 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
308 --prefix=%{local_rust_root} \
310 test -f %{local_rust_root}/bin/cargo
311 test -f %{local_rust_root}/bin/rustc
315 # We're disabling jemalloc, but rust-src still wants it.
316 #%{__rm} -r src/jemalloc
317 %if %{with system_llvm}
318 %{__rm} -r src/llvm-project
319 mkdir -p src/llvm-project/libunwind
322 # extract bundled licenses for packaging
323 sed -e '/*\//q' library/backtrace/crates/backtrace-sys/src/libbacktrace/backtrace.h \
324 >library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
326 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
327 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
330 # The configure macro will modify some autoconf-related files, which upsets
331 # cargo when it tries to verify checksums in those files. If we just truncate
332 # that file list, cargo won't have anything to complain about.
333 find vendor -name .cargo-checksum.json \
334 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
338 --build=%{rust_bootstrap_triple} \
339 --host=%{rust_host_triple} \
340 --target=%{rust_triple} \
341 --libdir=%{common_libdir} \
342 --disable-codegen-tests \
343 --disable-debuginfo-lines \
344 %if %{with full_debuginfo}
345 --disable-debuginfo-only-std \
348 --enable-debuginfo-only-std \
349 --disable-debuginfo \
352 --disable-option-checking \
355 --enable-llvm-link-shared \
357 --local-rust-root=%{local_rust_root} \
358 --llvm-root=%{_prefix} \
359 --release-channel=%{channel}
361 export RUST_BACKTRACE=full
364 %{?with_tests:%x_py test}
367 rm -rf $RPM_BUILD_ROOT
369 export DESTDIR=$RPM_BUILD_ROOT
372 # Make sure the shared libraries are in the proper libdir
373 %if "%{_libdir}" != "%{common_libdir}"
374 mkdir -p %{buildroot}%{_libdir}
375 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
376 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
379 # The shared libraries should be executable for debuginfo extraction.
380 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
382 # The libdir libraries are identical to those under rustlib/. It's easier on
383 # library loading if we keep them in libdir, but we do need them in rustlib/
384 # to support dynamic linking for compiler plugins, so we'll symlink.
385 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
386 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
387 -exec ln -v -f -s -t . '{}' '+')
389 # Remove installer artifacts (manifests, uninstall scripts, etc.)
390 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
392 # FIXME: __os_install_post will strip the rlibs
393 # -- should we find a way to preserve debuginfo?
395 # Remove unwanted documentation files (we already package them)
396 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
397 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
398 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
399 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
401 # Sanitize the HTML documentation
402 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
403 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
405 # Move rust-gdb's python scripts so they're noarch
406 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
407 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
409 # We don't need stdlib source
410 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
412 # Create the path for crate-devel packages
413 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
416 rm -rf $RPM_BUILD_ROOT
418 %post -p /sbin/ldconfig
419 %postun -p /sbin/ldconfig
422 %defattr(644,root,root,755)
423 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
424 %attr(755,root,root) %{_bindir}/miri
425 %attr(755,root,root) %{_bindir}/rustc
426 %attr(755,root,root) %{_bindir}/rustdoc
427 %attr(755,root,root) %{_bindir}/rustfmt
428 %attr(755,root,root) %{_libdir}/librustc*-*.so
429 %attr(755,root,root) %{_libdir}/libstd-*.so
430 %attr(755,root,root) %{_libdir}/libtest-*.so
431 %{_mandir}/man1/rustc.1*
432 %{_mandir}/man1/rustdoc.1*
434 %dir %{rustlibdir}/%{rust_triple}
435 %{rustlibdir}/%{rust_triple}/analysis
436 %dir %{rustlibdir}/%{rust_triple}/lib
437 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
438 %{rustlibdir}/%{rust_triple}/lib/*.rlib
441 %defattr(644,root,root,755)
442 %attr(755,root,root) %{_bindir}/rust-analyzer
444 %files debugger-common
445 %defattr(644,root,root,755)
446 %dir %{_datadir}/%{name}
447 %dir %{_datadir}/%{name}/etc
448 %{_datadir}/%{name}/etc/lldb_commands
449 %{_datadir}/%{name}/etc/rust_types.py
452 %defattr(644,root,root,755)
453 %attr(755,root,root) %{_bindir}/rust-lldb
454 %{_datadir}/%{name}/etc/lldb_*.py*
457 %defattr(644,root,root,755)
458 %attr(755,root,root) %{_bindir}/rust-gdb
459 %attr(755,root,root) %{_bindir}/rust-gdbgui
460 %{_datadir}/%{name}/etc/gdb_*.py*
463 %defattr(644,root,root,755)
464 %attr(755,root,root) %{_bindir}/rls
467 %defattr(644,root,root,755)
468 %dir %{_docdir}/%{name}
469 %doc %{_docdir}/%{name}/html
472 %defattr(644,root,root,755)
473 %attr(755,root,root) %{_bindir}/cargo
474 %attr(755,root,root) %{_bindir}/cargo-clippy
475 %attr(755,root,root) %{_bindir}/cargo-fmt
476 %attr(755,root,root) %{_bindir}/cargo-miri
477 %attr(755,root,root) %{_bindir}/clippy-driver
478 %attr(755,root,root) %{_libexecdir}/cargo-credential-1password
479 %{_mandir}/man1/cargo*.1*
480 %dir %{_datadir}/cargo
481 %dir %{_datadir}/cargo/registry
483 %files -n bash-completion-cargo
484 %defattr(644,root,root,755)
485 %{_sysconfdir}/bash_completion.d/cargo
487 %files -n zsh-completion-cargo
488 %defattr(644,root,root,755)
489 %{zsh_compdir}/_cargo