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.41.1
27 %define bootstrap_cargo 1.41.0
28 %define bootstrap_date 2020-02-27
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: 03a6111956f8d3bfdfc21aedce7f06bc
44 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
45 # Source1-md5: 3336c39311a33005d51298c60b99f2c1
46 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
47 # Source2-md5: be3f4d5143483c754a3c272eb213cd07
48 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-std-%{bootstrap_rust}-x86_64-unknown-linux-gnux32.tar.xz
49 # Source3-md5: 38da0bf057e0801669f18f74555830bf
50 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
51 # Source4-md5: 3408e035e4257846e9417148e1f50412
52 URL: https://www.rust-lang.org/
54 BuildRequires: cmake >= 3.4.3
56 BuildRequires: libstdc++-devel
57 %{?with_system_llvm:BuildRequires: llvm-devel >= 7.0}
58 BuildRequires: openssl-devel >= 1.0.1
59 BuildRequires: python >= 1:2.7
60 BuildRequires: zlib-devel
61 %if %{without bootstrap}
62 BuildRequires: %{name} >= %{bootstrap_rust}
63 BuildRequires: cargo >= %{bootstrap_cargo}
64 BuildConflicts: %{name} > %{version}
66 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
68 # The C compiler is needed at runtime just for linking. Someday rustc might
69 # invoke the linker directly, and then we'll only need binutils.
70 # https://github.com/rust-lang/rust/issues/11937
72 # Only x86_64 and i686 are Tier 1 platforms at this time.
73 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
74 # https://doc.rust-lang.org/stable/book/getting-started.html#tier-1
75 ExclusiveArch: %{x8664} %{ix86} x32 aarch64
76 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
79 %define rust_triple x86_64-unknown-linux-gnux32
80 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
82 %define rust_triple %{_target_cpu}-unknown-linux-gnu
83 %define rust_bootstrap_triple %{_target_cpu}-unknown-linux-gnu
86 %if %{without bootstrap}
87 %define local_rust_root %{_prefix}
89 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
90 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
93 # We're going to override --libdir when configuring to get rustlib into a
94 # common path, but we'll fix the shared libraries during install.
95 # Without this ugly hack, rust would not be able to build itself
96 # for non-bootstrap build, lib64 is just too complicated for it.
97 %define common_libdir %{_prefix}/lib
98 %define rustlibdir %{common_libdir}/rustlib
100 # once_call/once_callable non-function libstdc++ symbols
101 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
103 # ALL Rust libraries are private, because they don't keep an ABI.
104 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
105 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
111 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
116 Rust is a systems programming language that runs blazingly fast,
117 prevents segfaults, and guarantees thread safety.
119 This package includes the Rust compiler, standard library, and
120 documentation generator.
122 %description -l pl.UTF-8
123 Rust to systemowy język programowania działający bardzo szybko,
124 zapobiegający naruszeniom ochrony pamięci i gwarantujący
125 bezpieczną wielowątkowość.
127 %package debugger-common
128 Summary: Common debugger pretty printers for Rust
129 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
130 Group: Development/Debuggers
133 %description debugger-common
134 This package includes the common functionality for rust-gdb and
137 %description debugger-common -l pl.UTF-8
138 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
141 Summary: GDB pretty printers for Rust
142 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
143 Group: Development/Debuggers
144 Requires: %{name}-debugger-common = %{version}-%{release}
149 This package includes the rust-gdb script, which allows easier
150 debugging of Rust programs.
152 %description gdb -l pl.UTF-8
153 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
154 odpluskwianie programów w języku Rust.
157 Summary: LLDB pretty printers for Rust
158 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
159 Group: Development/Debuggers
160 Requires: %{name}-debugger-common = %{version}-%{release}
165 This package includes the rust-lldb script, which allows easier
166 debugging of Rust programs.
168 %description lldb -l pl.UTF-8
169 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
170 odpluskwianie programów w języku Rust.
173 Summary: Documentation for Rust
174 Summary(pl.UTF-8): Dokumentacja do Rusta
179 This package includes HTML documentation for the Rust programming
180 language and its standard library.
182 %description doc -l pl.UTF-8
183 Ten pakiet zawiera dokumentację w formacie HTML do języka
184 programowania Rust i jego biblioteki standardowej.
187 Summary: Rust's package manager and build tool
188 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
189 Group: Development/Tools
192 %description -n cargo
193 Cargo is a tool that allows Rust projects to declare their various
194 dependencies and ensure that you'll always get a repeatable build.
196 %description -n cargo -l pl.UTF-8
197 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
198 zależności i zapewniające powtarzalność procesu budowania.
200 %package -n bash-completion-cargo
201 Summary: Bash completion for cargo command
202 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
203 Group: Applications/Shells
204 Requires: %{name} = %{version}-%{release}
205 Requires: bash-completion
207 %description -n bash-completion-cargo
208 Bash completion for cargo command.
210 %description -n bash-completion-cargo -l pl.UTF-8
211 Bashowe dopełnianie parametrów polecenia cargo.
213 %package -n zsh-completion-cargo
214 Summary: Zsh completion for cargo command
215 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
216 Group: Applications/Shells
217 Requires: %{name} = %{version}-%{release}
220 %description -n zsh-completion-cargo
221 Zsh completion for cargo command.
223 %description -n zsh-completion-cargo -l pl.UTF-8
224 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
227 %setup -q -n %{rustc_package}
229 %if %{with bootstrap}
240 %{__mv} rust-std-%{bootstrap_rust}-%{rust_triple} rust-std-%{rust_triple}
246 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
247 %{bootstrap_root}-root/install.sh \
248 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
249 --prefix=%{local_rust_root} \
251 test -f %{local_rust_root}/bin/cargo
252 test -f %{local_rust_root}/bin/rustc
254 %{bootstrap_root}-root/rust-std-%{rust_triple}/install.sh \
255 --components=rust-std-%{rust_triple} \
256 --prefix=%{local_rust_root} \
262 # We're disabling jemalloc, but rust-src still wants it.
263 #%{__rm} -r src/jemalloc
264 %{?with_system_llvm:%{__rm} -r src/llvm-project}
266 # extract bundled licenses for packaging
267 sed -e '/*\//q' vendor/backtrace-sys/src/libbacktrace/backtrace.h \
268 >vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
270 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
271 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
274 # The configure macro will modify some autoconf-related files, which upsets
275 # cargo when it tries to verify checksums in those files. If we just truncate
276 # that file list, cargo won't have anything to complain about.
277 find vendor -name .cargo-checksum.json \
278 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
282 --build=%{rust_triple} \
283 --host=%{rust_triple} \
284 --target=%{rust_triple} \
285 --libdir=%{common_libdir} \
286 --disable-codegen-tests \
287 --disable-debuginfo-lines \
288 %if %{with full_debuginfo}
289 --disable-debuginfo-only-std \
292 --enable-debuginfo-only-std \
293 --disable-debuginfo \
296 --disable-option-checking \
299 --enable-llvm-link-shared \
301 --local-rust-root=%{local_rust_root} \
302 --llvm-root=%{_prefix} \
303 --release-channel=%{channel}
305 export RUST_BACKTRACE=full
308 %{?with_tests:%x_py test}
311 rm -rf $RPM_BUILD_ROOT
313 export DESTDIR=$RPM_BUILD_ROOT
317 # Make sure the shared libraries are in the proper libdir
318 %if "%{_libdir}" != "%{common_libdir}"
319 mkdir -p %{buildroot}%{_libdir}
320 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
321 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
324 # The shared libraries should be executable for debuginfo extraction.
325 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
327 # The libdir libraries are identical to those under rustlib/. It's easier on
328 # library loading if we keep them in libdir, but we do need them in rustlib/
329 # to support dynamic linking for compiler plugins, so we'll symlink.
330 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
331 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
332 -exec ln -v -f -s -t . '{}' '+')
334 # Remove installer artifacts (manifests, uninstall scripts, etc.)
335 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
337 # FIXME: __os_install_post will strip the rlibs
338 # -- should we find a way to preserve debuginfo?
340 # Remove unwanted documentation files (we already package them)
341 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
342 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
343 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
344 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
346 # Sanitize the HTML documentation
347 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
348 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
350 # Move rust-gdb's python scripts so they're noarch
351 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
352 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
354 # We don't need stdlib source
355 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
357 # Create the path for crate-devel packages
358 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
361 rm -rf $RPM_BUILD_ROOT
363 %post -p /sbin/ldconfig
364 %postun -p /sbin/ldconfig
367 %defattr(644,root,root,755)
368 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
369 %attr(755,root,root) %{_bindir}/miri
370 %attr(755,root,root) %{_bindir}/rls
371 %attr(755,root,root) %{_bindir}/rustc
372 %attr(755,root,root) %{_bindir}/rustdoc
373 %attr(755,root,root) %{_bindir}/rustfmt
374 %attr(755,root,root) %{_libdir}/librustc*-*.so
375 %attr(755,root,root) %{_libdir}/libstd-*.so
376 %attr(755,root,root) %{_libdir}/libtest-*.so
377 %{_mandir}/man1/rustc.1*
378 %{_mandir}/man1/rustdoc.1*
380 %dir %{rustlibdir}/%{rust_triple}
381 %{rustlibdir}/%{rust_triple}/analysis
382 %dir %{rustlibdir}/%{rust_triple}/lib
383 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
384 %{rustlibdir}/%{rust_triple}/lib/*.rlib
386 %files debugger-common
387 %defattr(644,root,root,755)
388 %dir %{_datadir}/%{name}
389 %dir %{_datadir}/%{name}/etc
390 %{_datadir}/%{name}/etc/debugger_*.py*
393 %defattr(644,root,root,755)
394 %attr(755,root,root) %{_bindir}/rust-lldb
395 %{_datadir}/%{name}/etc/lldb_*.py*
398 %defattr(644,root,root,755)
399 %attr(755,root,root) %{_bindir}/rust-gdb
400 %attr(755,root,root) %{_bindir}/rust-gdbgui
401 %{_datadir}/%{name}/etc/gdb_*.py*
404 %defattr(644,root,root,755)
405 %dir %{_docdir}/%{name}
406 %doc %{_docdir}/%{name}/html
409 %defattr(644,root,root,755)
410 %attr(755,root,root) %{_bindir}/cargo
411 %attr(755,root,root) %{_bindir}/cargo-clippy
412 %attr(755,root,root) %{_bindir}/cargo-fmt
413 %attr(755,root,root) %{_bindir}/cargo-miri
414 %attr(755,root,root) %{_bindir}/clippy-driver
415 %{_mandir}/man1/cargo*.1*
416 %dir %{_datadir}/cargo
417 %dir %{_datadir}/cargo/registry
419 %files -n bash-completion-cargo
420 %defattr(644,root,root,755)
421 %{_sysconfdir}/bash_completion.d/cargo
423 %files -n zsh-completion-cargo
424 %defattr(644,root,root,755)
425 %{zsh_compdir}/_cargo