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.48.0
25 %define bootstrap_cargo 1.48.0
26 %define bootstrap_date 2020-11-19
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: f13014e17f84a99ff749f81e0cd1d2b1
41 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
42 # Source1-md5: 9aab1315df1f461bc988c5b5abcb8c89
43 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
44 # Source2-md5: 107dda909166a9c57d7907ac956eecd9
45 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
46 # Source3-md5: 905c4ad9d3737fdf04c1acfd1b612b7c
47 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
48 # Source4-md5: f8502775faa60c018e38eda59c43147e
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 >= 8.0}
63 BuildRequires: openssl-devel >= 1.0.1
64 BuildRequires: zlib-devel
66 %if %{without bootstrap}
67 BuildRequires: %{name} >= %{bootstrap_rust}
68 BuildRequires: cargo >= %{bootstrap_cargo}
69 BuildConflicts: %{name} > %{version}
72 BuildRequires: glibc-devel(x32)
73 BuildRequires: glibc-devel(x86_64)
74 %if "%{_host_cpu}" == "x86_64"
75 # building on x86_64 host with --target x32-pld-linux
76 BuildRequires: curl-devel
77 BuildRequires: gcc-multilib-x32
78 BuildRequires: libgit2-devel
79 BuildRequires: libstdc++-devel
80 %{?with_system_llvm:BuildRequires: llvm-devel >= 8.0}
81 BuildRequires: openssl-devel >= 1.0.1
82 BuildRequires: zlib-devel
84 # building x86_64-hosted crosscompiler on x32 host
85 BuildRequires: gcc-multilib-64
86 BuildRequires: libstdc++-multilib-64-devel
87 # how to specify? - rpm.org adds arch provides on packages (__isa), uncomment once we switch
88 #BuildRequires: curl-devel(x86-64)
89 #BuildRequires: libgit2-devel(x86-64)
90 #BuildRequires: llvm-devel(x86-64)>= 7.0
91 #BuildRequires: openssl-devel(x86-64)
92 #BuildRequires: zlib-devel(x86-64)
95 # The C compiler is needed at runtime just for linking. Someday rustc might
96 # invoke the linker directly, and then we'll only need binutils.
97 # https://github.com/rust-lang/rust/issues/11937
99 # Only x86_64 and i686 are Tier 1 platforms at this time.
100 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
101 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
102 ExclusiveArch: %{x8664} %{ix86} x32 aarch64 armv6hl armv7hl armv7hnl
103 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
106 %define rust_triple x86_64-unknown-linux-gnux32
107 %define rust_host_triple x86_64-unknown-linux-gnu
108 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
110 %ifarch armv6hl armv7hl armv7hnl
111 %define rust_triple arm-unknown-linux-gnueabihf
112 %define rust_host_triple %{rust_triple}
113 %define rust_bootstrap_triple %{rust_triple}
115 %define rust_triple %{_target_cpu}-unknown-linux-gnu
116 %define rust_host_triple %{rust_triple}
117 %define rust_bootstrap_triple %{rust_triple}
121 %if %{without bootstrap}
122 %define local_rust_root %{_prefix}
124 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
125 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
128 # We're going to override --libdir when configuring to get rustlib into a
129 # common path, but we'll fix the shared libraries during install.
130 # Without this ugly hack, rust would not be able to build itself
131 # for non-bootstrap build, lib64 is just too complicated for it.
132 %define common_libdir %{_prefix}/lib
133 %define rustlibdir %{common_libdir}/rustlib
135 # once_call/once_callable non-function libstdc++ symbols
136 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
138 # ALL Rust libraries are private, because they don't keep an ABI.
139 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
140 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
146 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
151 Rust is a systems programming language that runs blazingly fast,
152 prevents segfaults, and guarantees thread safety.
154 This package includes the Rust compiler, standard library, and
155 documentation generator.
157 %description -l pl.UTF-8
158 Rust to systemowy język programowania działający bardzo szybko,
159 zapobiegający naruszeniom ochrony pamięci i gwarantujący
160 bezpieczną wielowątkowość.
163 Summary: Implementation of Language Server Protocol for Rust
164 Summary(pl.UTF-8): Implementacja Language Server Protocol dla Rusta
165 Group: Development/Tools
166 Requires: %{name} = %{version}-%{release}
168 %description analyzer
169 Implementation of Language Server Protocol for Rust.
171 %description analyzer -l pl.UTF-8
172 Implementacja Language Server Protocol dla Rusta.
174 %package debugger-common
175 Summary: Common debugger pretty printers for Rust
176 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
177 Group: Development/Debuggers
180 %description debugger-common
181 This package includes the common functionality for rust-gdb and
184 %description debugger-common -l pl.UTF-8
185 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
188 Summary: GDB pretty printers for Rust
189 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
190 Group: Development/Debuggers
191 Requires: %{name}-debugger-common = %{version}-%{release}
196 This package includes the rust-gdb script, which allows easier
197 debugging of Rust programs.
199 %description gdb -l pl.UTF-8
200 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
201 odpluskwianie programów w języku Rust.
204 Summary: LLDB pretty printers for Rust
205 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
206 Group: Development/Debuggers
207 Requires: %{name}-debugger-common = %{version}-%{release}
212 This package includes the rust-lldb script, which allows easier
213 debugging of Rust programs.
215 %description lldb -l pl.UTF-8
216 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
217 odpluskwianie programów w języku Rust.
220 Summary: Rust Language Server for IDE integration
221 Summary(pl.UTF-8): Rust Language Server do integracji z IDE
222 Group: Development/Tools
223 Requires: %{name} = %{version}-%{release}
226 Rust Language Server for IDE integration.
228 %description rls -l pl.UTF-8
229 Rust Language Server do integracji z IDE.
232 Summary: Documentation for Rust
233 Summary(pl.UTF-8): Dokumentacja do Rusta
238 This package includes HTML documentation for the Rust programming
239 language and its standard library.
241 %description doc -l pl.UTF-8
242 Ten pakiet zawiera dokumentację w formacie HTML do języka
243 programowania Rust i jego biblioteki standardowej.
246 Summary: Rust's package manager and build tool
247 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
248 Group: Development/Tools
251 %description -n cargo
252 Cargo is a tool that allows Rust projects to declare their various
253 dependencies and ensure that you'll always get a repeatable build.
255 %description -n cargo -l pl.UTF-8
256 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
257 zależności i zapewniające powtarzalność procesu budowania.
259 %package -n bash-completion-cargo
260 Summary: Bash completion for cargo command
261 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
262 Group: Applications/Shells
263 Requires: %{name} = %{version}-%{release}
264 Requires: bash-completion
266 %description -n bash-completion-cargo
267 Bash completion for cargo command.
269 %description -n bash-completion-cargo -l pl.UTF-8
270 Bashowe dopełnianie parametrów polecenia cargo.
272 %package -n zsh-completion-cargo
273 Summary: Zsh completion for cargo command
274 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
275 Group: Applications/Shells
276 Requires: %{name} = %{version}-%{release}
279 %description -n zsh-completion-cargo
280 Zsh completion for cargo command.
282 %description -n zsh-completion-cargo -l pl.UTF-8
283 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
286 %setup -q -n %{rustc_package}
287 # irrelevant when not building rustc for x32
290 %if %{with bootstrap}
300 %ifarch armv6hl armv7hl armv7hnl
303 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
304 %{bootstrap_root}-root/install.sh \
305 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
306 --prefix=%{local_rust_root} \
308 test -f %{local_rust_root}/bin/cargo
309 test -f %{local_rust_root}/bin/rustc
313 # We're disabling jemalloc, but rust-src still wants it.
314 #%{__rm} -r src/jemalloc
315 %if %{with system_llvm}
316 %{__rm} -r src/llvm-project
317 mkdir -p src/llvm-project/libunwind
320 # extract bundled licenses for packaging
321 sed -e '/*\//q' library/backtrace/crates/backtrace-sys/src/libbacktrace/backtrace.h \
322 >library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
324 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
325 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
328 # The configure macro will modify some autoconf-related files, which upsets
329 # cargo when it tries to verify checksums in those files. If we just truncate
330 # that file list, cargo won't have anything to complain about.
331 find vendor -name .cargo-checksum.json \
332 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
336 --build=%{rust_bootstrap_triple} \
337 --host=%{rust_host_triple} \
338 --target=%{rust_triple} \
339 --libdir=%{common_libdir} \
340 --disable-codegen-tests \
341 --disable-debuginfo-lines \
342 %if %{with full_debuginfo}
343 --disable-debuginfo-only-std \
346 --enable-debuginfo-only-std \
347 --disable-debuginfo \
350 --disable-option-checking \
353 --enable-llvm-link-shared \
355 --local-rust-root=%{local_rust_root} \
356 --llvm-root=%{_prefix} \
357 --release-channel=%{channel}
359 export RUST_BACKTRACE=full
362 %{?with_tests:%x_py test}
365 rm -rf $RPM_BUILD_ROOT
367 export DESTDIR=$RPM_BUILD_ROOT
370 # Make sure the shared libraries are in the proper libdir
371 %if "%{_libdir}" != "%{common_libdir}"
372 mkdir -p %{buildroot}%{_libdir}
373 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
374 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
377 # The shared libraries should be executable for debuginfo extraction.
378 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
380 # The libdir libraries are identical to those under rustlib/. It's easier on
381 # library loading if we keep them in libdir, but we do need them in rustlib/
382 # to support dynamic linking for compiler plugins, so we'll symlink.
383 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
384 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
385 -exec ln -v -f -s -t . '{}' '+')
387 # Remove installer artifacts (manifests, uninstall scripts, etc.)
388 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
390 # FIXME: __os_install_post will strip the rlibs
391 # -- should we find a way to preserve debuginfo?
393 # Remove unwanted documentation files (we already package them)
394 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
395 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
396 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
397 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
399 # Sanitize the HTML documentation
400 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
401 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
403 # Move rust-gdb's python scripts so they're noarch
404 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
405 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
407 # We don't need stdlib source
408 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
410 # Create the path for crate-devel packages
411 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
414 rm -rf $RPM_BUILD_ROOT
416 %post -p /sbin/ldconfig
417 %postun -p /sbin/ldconfig
420 %defattr(644,root,root,755)
421 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
422 %attr(755,root,root) %{_bindir}/miri
423 %attr(755,root,root) %{_bindir}/rustc
424 %attr(755,root,root) %{_bindir}/rustdoc
425 %attr(755,root,root) %{_bindir}/rustfmt
426 %attr(755,root,root) %{_libdir}/libchalk_derive-*.so
427 %attr(755,root,root) %{_libdir}/librustc*-*.so
428 %attr(755,root,root) %{_libdir}/libstd-*.so
429 %attr(755,root,root) %{_libdir}/libtest-*.so
430 %attr(755,root,root) %{_libdir}/libtracing_attributes-*.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 %{_mandir}/man1/cargo*.1*
479 %dir %{_datadir}/cargo
480 %dir %{_datadir}/cargo/registry
482 %files -n bash-completion-cargo
483 %defattr(644,root,root,755)
484 %{_sysconfdir}/bash_completion.d/cargo
486 %files -n zsh-completion-cargo
487 %defattr(644,root,root,755)
488 %{zsh_compdir}/_cargo