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_without rustc # rustc building
11 %bcond_without cargo # cargo building
12 %bcond_with tests # build without tests
14 # The channel can be stable, beta, or nightly
15 %define channel stable
17 %if "%{channel}" == "stable"
18 %define rustc_package rustc-%{version}-src
20 %define rustc_package rustc-%{channel}-src
23 # To bootstrap from scratch, set the channel and date from src/stage0.txt
24 # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
25 # or nightly wants some beta-YYYY-MM-DD
26 %define bootstrap_rust 1.43.1
27 %define bootstrap_cargo 1.43.1
28 %define bootstrap_date 2020-05-07
34 Summary: The Rust Programming Language
35 Summary(pl.UTF-8): Język programowania Rust
39 # Licenses: (rust itself) and (bundled libraries)
40 License: (Apache v2.0 or MIT) and (BSD and ISC and MIT)
41 Group: Development/Languages
42 Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
43 # Source0-md5: 0cc3b079ddb1eb9a17f9e7e52efcebc5
44 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
45 # Source1-md5: 62b0974a4bad5aeabd50c7a7fa74518c
46 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
47 # Source2-md5: 758d55172c8dddb1ec71913b5f532bb2
48 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-std-%{bootstrap_rust}-x86_64-unknown-linux-gnux32.tar.xz
49 # Source3-md5: 4b07c6922a0965791cf8eb28fee9e89d
50 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
51 # Source4-md5: 3a9d54ab96f96664b2f6077cccb4e70b
52 Patch0: %{name}-x32.patch
53 URL: https://www.rust-lang.org/
55 BuildRequires: cmake >= 3.4.3
57 BuildRequires: libstdc++-devel
58 %{?with_system_llvm:BuildRequires: llvm-devel >= 7.0}
59 BuildRequires: openssl-devel >= 1.0.1
60 BuildRequires: python >= 1:2.7
61 BuildRequires: zlib-devel
62 %if %{without bootstrap}
63 BuildRequires: %{name} >= %{bootstrap_rust}
64 BuildRequires: cargo >= %{bootstrap_cargo}
65 BuildConflicts: %{name} > %{version}
67 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
69 # The C compiler is needed at runtime just for linking. Someday rustc might
70 # invoke the linker directly, and then we'll only need binutils.
71 # https://github.com/rust-lang/rust/issues/11937
73 # Only x86_64 and i686 are Tier 1 platforms at this time.
74 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
75 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
76 ExclusiveArch: %{x8664} %{ix86} x32 aarch64
77 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
80 %define rust_triple x86_64-unknown-linux-gnux32
81 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
83 %define rust_triple %{_target_cpu}-unknown-linux-gnu
84 %define rust_bootstrap_triple %{_target_cpu}-unknown-linux-gnu
87 %if %{without bootstrap}
88 %define local_rust_root %{_prefix}
90 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
91 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
94 # We're going to override --libdir when configuring to get rustlib into a
95 # common path, but we'll fix the shared libraries during install.
96 # Without this ugly hack, rust would not be able to build itself
97 # for non-bootstrap build, lib64 is just too complicated for it.
98 %define common_libdir %{_prefix}/lib
99 %define rustlibdir %{common_libdir}/rustlib
101 # once_call/once_callable non-function libstdc++ symbols
102 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
104 # ALL Rust libraries are private, because they don't keep an ABI.
105 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
106 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
112 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
117 Rust is a systems programming language that runs blazingly fast,
118 prevents segfaults, and guarantees thread safety.
120 This package includes the Rust compiler, standard library, and
121 documentation generator.
123 %description -l pl.UTF-8
124 Rust to systemowy język programowania działający bardzo szybko,
125 zapobiegający naruszeniom ochrony pamięci i gwarantujący
126 bezpieczną wielowątkowość.
128 %package debugger-common
129 Summary: Common debugger pretty printers for Rust
130 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
131 Group: Development/Debuggers
134 %description debugger-common
135 This package includes the common functionality for rust-gdb and
138 %description debugger-common -l pl.UTF-8
139 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
142 Summary: GDB pretty printers for Rust
143 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
144 Group: Development/Debuggers
145 Requires: %{name}-debugger-common = %{version}-%{release}
150 This package includes the rust-gdb script, which allows easier
151 debugging of Rust programs.
153 %description gdb -l pl.UTF-8
154 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
155 odpluskwianie programów w języku Rust.
158 Summary: LLDB pretty printers for Rust
159 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
160 Group: Development/Debuggers
161 Requires: %{name}-debugger-common = %{version}-%{release}
166 This package includes the rust-lldb script, which allows easier
167 debugging of Rust programs.
169 %description lldb -l pl.UTF-8
170 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
171 odpluskwianie programów w języku Rust.
174 Summary: Documentation for Rust
175 Summary(pl.UTF-8): Dokumentacja do Rusta
180 This package includes HTML documentation for the Rust programming
181 language and its standard library.
183 %description doc -l pl.UTF-8
184 Ten pakiet zawiera dokumentację w formacie HTML do języka
185 programowania Rust i jego biblioteki standardowej.
188 Summary: Rust's package manager and build tool
189 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
190 Group: Development/Tools
193 %description -n cargo
194 Cargo is a tool that allows Rust projects to declare their various
195 dependencies and ensure that you'll always get a repeatable build.
197 %description -n cargo -l pl.UTF-8
198 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
199 zależności i zapewniające powtarzalność procesu budowania.
201 %package -n bash-completion-cargo
202 Summary: Bash completion for cargo command
203 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
204 Group: Applications/Shells
205 Requires: %{name} = %{version}-%{release}
206 Requires: bash-completion
208 %description -n bash-completion-cargo
209 Bash completion for cargo command.
211 %description -n bash-completion-cargo -l pl.UTF-8
212 Bashowe dopełnianie parametrów polecenia cargo.
214 %package -n zsh-completion-cargo
215 Summary: Zsh completion for cargo command
216 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
217 Group: Applications/Shells
218 Requires: %{name} = %{version}-%{release}
221 %description -n zsh-completion-cargo
222 Zsh completion for cargo command.
224 %description -n zsh-completion-cargo -l pl.UTF-8
225 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
228 %setup -q -n %{rustc_package}
231 %if %{with bootstrap}
242 %{__mv} rust-std-%{bootstrap_rust}-%{rust_triple} rust-std-%{rust_triple}
248 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
249 %{bootstrap_root}-root/install.sh \
250 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
251 --prefix=%{local_rust_root} \
253 test -f %{local_rust_root}/bin/cargo
254 test -f %{local_rust_root}/bin/rustc
256 %{bootstrap_root}-root/rust-std-%{rust_triple}/install.sh \
257 --components=rust-std-%{rust_triple} \
258 --prefix=%{local_rust_root} \
264 # We're disabling jemalloc, but rust-src still wants it.
265 #%{__rm} -r src/jemalloc
266 %{?with_system_llvm:%{__rm} -r src/llvm-project}
268 # extract bundled licenses for packaging
269 sed -e '/*\//q' vendor/backtrace-sys/src/libbacktrace/backtrace.h \
270 >vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
272 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
273 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
276 # The configure macro will modify some autoconf-related files, which upsets
277 # cargo when it tries to verify checksums in those files. If we just truncate
278 # that file list, cargo won't have anything to complain about.
279 find vendor -name .cargo-checksum.json \
280 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
283 export PKG_CONFIG_ALLOW_CROSS=1
285 --build=%{rust_triple} \
286 --host=%{rust_triple} \
287 --target=%{rust_triple} \
288 --libdir=%{common_libdir} \
289 --disable-codegen-tests \
290 --disable-debuginfo-lines \
291 %if %{with full_debuginfo}
292 --disable-debuginfo-only-std \
295 --enable-debuginfo-only-std \
296 --disable-debuginfo \
299 --disable-option-checking \
302 --enable-llvm-link-shared \
304 --local-rust-root=%{local_rust_root} \
305 --llvm-root=%{_prefix} \
306 --release-channel=%{channel}
308 export RUST_BACKTRACE=full
311 %{?with_tests:%x_py test}
314 rm -rf $RPM_BUILD_ROOT
316 export DESTDIR=$RPM_BUILD_ROOT
320 # Make sure the shared libraries are in the proper libdir
321 %if "%{_libdir}" != "%{common_libdir}"
322 mkdir -p %{buildroot}%{_libdir}
323 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
324 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
327 # The shared libraries should be executable for debuginfo extraction.
328 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
330 # The libdir libraries are identical to those under rustlib/. It's easier on
331 # library loading if we keep them in libdir, but we do need them in rustlib/
332 # to support dynamic linking for compiler plugins, so we'll symlink.
333 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
334 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
335 -exec ln -v -f -s -t . '{}' '+')
337 # Remove installer artifacts (manifests, uninstall scripts, etc.)
338 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
340 # FIXME: __os_install_post will strip the rlibs
341 # -- should we find a way to preserve debuginfo?
343 # Remove unwanted documentation files (we already package them)
344 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
345 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
346 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
347 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
349 # Sanitize the HTML documentation
350 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
351 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
353 # Move rust-gdb's python scripts so they're noarch
354 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
355 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
357 # We don't need stdlib source
358 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
360 # Create the path for crate-devel packages
361 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
364 rm -rf $RPM_BUILD_ROOT
366 %post -p /sbin/ldconfig
367 %postun -p /sbin/ldconfig
370 %defattr(644,root,root,755)
371 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
372 %attr(755,root,root) %{_bindir}/rls
373 %attr(755,root,root) %{_bindir}/rustc
374 %attr(755,root,root) %{_bindir}/rustdoc
375 %attr(755,root,root) %{_bindir}/rustfmt
376 %attr(755,root,root) %{_libdir}/librustc*-*.so
377 %attr(755,root,root) %{_libdir}/libstd-*.so
378 %attr(755,root,root) %{_libdir}/libtest-*.so
379 %{_mandir}/man1/rustc.1*
380 %{_mandir}/man1/rustdoc.1*
382 %dir %{rustlibdir}/%{rust_triple}
383 %{rustlibdir}/%{rust_triple}/analysis
384 %dir %{rustlibdir}/%{rust_triple}/lib
385 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
386 %{rustlibdir}/%{rust_triple}/lib/*.rlib
388 %files debugger-common
389 %defattr(644,root,root,755)
390 %dir %{_datadir}/%{name}
391 %dir %{_datadir}/%{name}/etc
392 %{_datadir}/%{name}/etc/debugger_*.py*
395 %defattr(644,root,root,755)
396 %attr(755,root,root) %{_bindir}/rust-lldb
397 %{_datadir}/%{name}/etc/lldb_*.py*
400 %defattr(644,root,root,755)
401 %attr(755,root,root) %{_bindir}/rust-gdb
402 %attr(755,root,root) %{_bindir}/rust-gdbgui
403 %{_datadir}/%{name}/etc/gdb_*.py*
406 %defattr(644,root,root,755)
407 %dir %{_docdir}/%{name}
408 %doc %{_docdir}/%{name}/html
411 %defattr(644,root,root,755)
412 %attr(755,root,root) %{_bindir}/cargo
413 %attr(755,root,root) %{_bindir}/cargo-clippy
414 %attr(755,root,root) %{_bindir}/cargo-fmt
415 %attr(755,root,root) %{_bindir}/clippy-driver
416 %{_mandir}/man1/cargo*.1*
417 %dir %{_datadir}/cargo
418 %dir %{_datadir}/cargo/registry
420 %files -n bash-completion-cargo
421 %defattr(644,root,root,755)
422 %{_sysconfdir}/bash_completion.d/cargo
424 %files -n zsh-completion-cargo
425 %defattr(644,root,root,755)
426 %{zsh_compdir}/_cargo