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.36.0
27 %define bootstrap_cargo 0.37.0
28 %define bootstrap_date 2019-07-04
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.gz
43 # Source0-md5: e67432b37150f13e186ebfb67e5192fb
44 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.gz
45 # Source1-md5: 487d17bbb86891f58160ccf6f0347b49
46 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.gz
47 # Source2-md5: 5f969ed3c9ef2a7e2a8011be7eb796c3
48 URL: https://www.rust-lang.org/
50 BuildRequires: cmake >= 3.4.3
52 BuildRequires: libstdc++-devel
53 %{?with_system_llvm:BuildRequires: llvm-devel}
54 BuildRequires: ncurses-devel
55 BuildRequires: python >= 1:2.7
56 BuildRequires: zlib-devel
57 %if %{without bootstrap}
58 BuildRequires: %{name} >= %{bootstrap_rust}
59 BuildRequires: cargo >= %{bootstrap_cargo}
60 BuildConflicts: %{name} > %{version}
62 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
64 # The C compiler is needed at runtime just for linking. Someday rustc might
65 # invoke the linker directly, and then we'll only need binutils.
66 # https://github.com/rust-lang/rust/issues/11937
68 # Only x86_64 and i686 are Tier 1 platforms at this time.
69 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
70 # https://doc.rust-lang.org/stable/book/getting-started.html#tier-1
71 ExclusiveArch: %{x8664} %{ix86} x32
72 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
75 %define rust_triple x86_64-unknown-linux-gnux32
76 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
78 %define rust_triple %{_target_cpu}-unknown-linux-gnu
79 %define rust_bootstrap_triple %{_target_cpu}-unknown-linux-gnu
82 %if %{without bootstrap}
83 %define local_rust_root %{_prefix}
85 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
86 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
89 # We're going to override --libdir when configuring to get rustlib into a
90 # common path, but we'll fix the shared libraries during install.
91 # Without this ugly hack, rust would not be able to build itself
92 # for non-bootstrap build, lib64 is just too complicated for it.
93 %define common_libdir %{_prefix}/lib
94 %define rustlibdir %{common_libdir}/rustlib
96 # once_call/once_callable non-function libstdc++ symbols
97 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
99 # ALL Rust libraries are private, because they don't keep an ABI.
100 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
101 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
104 Rust is a systems programming language that runs blazingly fast,
105 prevents segfaults, and guarantees thread safety.
107 This package includes the Rust compiler, standard library, and
108 documentation generator.
110 %description -l pl.UTF-8
111 Rust to systemowy język programowania działający bardzo szybko,
112 zapobiegający naruszeniom ochrony pamięci i gwarantujący
113 bezpieczną wielowątkowość.
115 %package debugger-common
116 Summary: Common debugger pretty printers for Rust
117 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
118 Group: Development/Debuggers
121 %description debugger-common
122 This package includes the common functionality for rust-gdb and
125 %description debugger-common -l pl.UTF-8
126 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
129 Summary: GDB pretty printers for Rust
130 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
131 Group: Development/Debuggers
132 Requires: %{name}-debugger-common = %{version}-%{release}
137 This package includes the rust-gdb script, which allows easier
138 debugging of Rust programs.
140 %description gdb -l pl.UTF-8
141 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
142 odpluskwianie programów w języku Rust.
145 Summary: LLDB pretty printers for Rust
146 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
147 Group: Development/Debuggers
148 Requires: %{name}-debugger-common = %{version}-%{release}
153 This package includes the rust-lldb script, which allows easier
154 debugging of Rust programs.
156 %description lldb -l pl.UTF-8
157 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
158 odpluskwianie programów w języku Rust.
161 Summary: Documentation for Rust
162 Summary(pl.UTF-8): Dokumentacja do Rusta
167 This package includes HTML documentation for the Rust programming
168 language and its standard library.
170 %description doc -l pl.UTF-8
171 Ten pakiet zawiera dokumentację w formacie HTML do języka
172 programowania Rust i jego biblioteki standardowej.
175 Summary: Rust's package manager and build tool
176 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
177 Group: Development/Tools
180 %description -n cargo
181 Cargo is a tool that allows Rust projects to declare their various
182 dependencies and ensure that you'll always get a repeatable build.
184 %description -n cargo -l pl.UTF-8
185 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
186 zależności i zapewniające powtarzalność procesu budowania.
188 %package -n bash-completion-cargo
189 Summary: Bash completion for cargo command
190 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
191 Group: Applications/Shells
192 Requires: %{name} = %{version}-%{release}
193 Requires: bash-completion
195 %description -n bash-completion-cargo
196 Bash completion for cargo command.
198 %description -n bash-completion-cargo -l pl.UTF-8
199 Bashowe dopełnianie parametrów polecenia cargo.
201 %package -n zsh-completion-cargo
202 Summary: Zsh completion for cargo command
203 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
204 Group: Applications/Shells
205 Requires: %{name} = %{version}-%{release}
208 %description -n zsh-completion-cargo
209 Zsh completion for cargo command.
211 %description -n zsh-completion-cargo -l pl.UTF-8
212 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
215 %setup -q -n %{rustc_package}
217 %if %{with bootstrap}
224 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
225 %{bootstrap_root}-root/install.sh \
226 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
227 --prefix=%{local_rust_root} \
229 test -f %{local_rust_root}/bin/cargo
230 test -f %{local_rust_root}/bin/rustc
234 # We're disabling jemalloc, but rust-src still wants it.
235 #%{__rm} -r src/jemalloc
236 %{?with_system_llvm:%{__rm} -r src/llvm-project}
238 # extract bundled licenses for packaging
239 sed -e '/*\//q' vendor/backtrace-sys/src/libbacktrace/backtrace.h \
240 >vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
242 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
243 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
246 # The configure macro will modify some autoconf-related files, which upsets
247 # cargo when it tries to verify checksums in those files. If we just truncate
248 # that file list, cargo won't have anything to complain about.
249 find vendor -name .cargo-checksum.json \
250 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
254 --build=%{rust_triple} \
255 --host=%{rust_triple} \
256 --target=%{rust_triple} \
257 --libdir=%{common_libdir} \
258 --disable-codegen-tests \
259 --disable-debuginfo-lines \
260 %if %{with full_debuginfo}
261 --disable-debuginfo-only-std \
264 --enable-debuginfo-only-std \
265 --disable-debuginfo \
268 --disable-option-checking \
271 --enable-llvm-link-shared \
273 --local-rust-root=%{local_rust_root} \
274 --llvm-root=%{_prefix} \
275 --release-channel=%{channel}
277 RUST_BACKTRACE=full \
278 ./x.py dist --verbose
280 %{?with_tests:./x.py test}
283 rm -rf $RPM_BUILD_ROOT
285 DESTDIR=$RPM_BUILD_ROOT ./x.py install
286 DESTDIR=$RPM_BUILD_ROOT ./x.py install src
288 # Make sure the shared libraries are in the proper libdir
289 %if "%{_libdir}" != "%{common_libdir}"
290 mkdir -p %{buildroot}%{_libdir}
291 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
292 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
295 # The shared libraries should be executable for debuginfo extraction.
296 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
298 # The libdir libraries are identical to those under rustlib/. It's easier on
299 # library loading if we keep them in libdir, but we do need them in rustlib/
300 # to support dynamic linking for compiler plugins, so we'll symlink.
301 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
302 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
303 -exec ln -v -f -s -t . '{}' '+')
305 # Remove installer artifacts (manifests, uninstall scripts, etc.)
306 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
308 # FIXME: __os_install_post will strip the rlibs
309 # -- should we find a way to preserve debuginfo?
311 # Remove unwanted documentation files (we already package them)
312 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
313 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
314 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
315 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
317 # Sanitize the HTML documentation
318 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
319 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
321 # Move rust-gdb's python scripts so they're noarch
322 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
323 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
325 # We don't need stdlib source
326 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
328 # Create the path for crate-devel packages
329 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
332 rm -rf $RPM_BUILD_ROOT
334 %post -p /sbin/ldconfig
335 %postun -p /sbin/ldconfig
338 %defattr(644,root,root,755)
339 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
340 %attr(755,root,root) %{_bindir}/miri
341 %attr(755,root,root) %{_bindir}/rls
342 %attr(755,root,root) %{_bindir}/rustc
343 %attr(755,root,root) %{_bindir}/rustdoc
344 %attr(755,root,root) %{_bindir}/rustfmt
345 %attr(755,root,root) %{_libdir}/libarena-*.so
346 %attr(755,root,root) %{_libdir}/libfmt_macros-*.so
347 %attr(755,root,root) %{_libdir}/libgraphviz-*.so
348 %attr(755,root,root) %{_libdir}/librustc*-*.so
349 %attr(755,root,root) %{_libdir}/libserialize-*.so
350 %attr(755,root,root) %{_libdir}/libstd-*.so
351 %attr(755,root,root) %{_libdir}/libsyntax-*.so
352 %attr(755,root,root) %{_libdir}/libsyntax_ext-*.so
353 %attr(755,root,root) %{_libdir}/libsyntax_pos-*.so
354 %attr(755,root,root) %{_libdir}/libterm-*.so
355 %attr(755,root,root) %{_libdir}/libtest-*.so
356 %{_mandir}/man1/rustc.1*
357 %{_mandir}/man1/rustdoc.1*
359 %dir %{rustlibdir}/%{rust_triple}
360 %{rustlibdir}/%{rust_triple}/analysis
361 %dir %{rustlibdir}/%{rust_triple}/codegen-backends
362 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/codegen-backends/*.so
363 %dir %{rustlibdir}/%{rust_triple}/lib
364 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
365 %{rustlibdir}/%{rust_triple}/lib/*.rlib
367 %files debugger-common
368 %defattr(644,root,root,755)
369 %dir %{_datadir}/%{name}
370 %dir %{_datadir}/%{name}/etc
371 %{_datadir}/%{name}/etc/debugger_*.py*
374 %defattr(644,root,root,755)
375 %attr(755,root,root) %{_bindir}/rust-lldb
376 %{_datadir}/%{name}/etc/lldb_*.py*
379 %defattr(644,root,root,755)
380 %attr(755,root,root) %{_bindir}/rust-gdb
381 %attr(755,root,root) %{_bindir}/rust-gdbgui
382 %{_datadir}/%{name}/etc/gdb_*.py*
385 %defattr(644,root,root,755)
386 %dir %{_docdir}/%{name}
387 %doc %{_docdir}/%{name}/html
390 %defattr(644,root,root,755)
391 %attr(755,root,root) %{_bindir}/cargo
392 %attr(755,root,root) %{_bindir}/cargo-clippy
393 %attr(755,root,root) %{_bindir}/cargo-fmt
394 %attr(755,root,root) %{_bindir}/cargo-miri
395 %attr(755,root,root) %{_bindir}/clippy-driver
396 %{_mandir}/man1/cargo*.1*
397 %dir %{_datadir}/cargo
398 %dir %{_datadir}/cargo/registry
400 %files -n bash-completion-cargo
401 %defattr(644,root,root,755)
402 %{_sysconfdir}/bash_completion.d/cargo
404 %files -n zsh-completion-cargo
405 %defattr(644,root,root,755)
406 %{zsh_compdir}/_cargo