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.37.0
27 %define bootstrap_cargo 0.38.0
28 %define bootstrap_date 2019-08-15
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: 492d3fbedc865606119336d55b9c4f29
44 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
45 # Source1-md5: 5d874193878390be4acec3f2f54fff9c
46 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
47 # Source2-md5: c543ba5b28cc1c90eaf509e9d89effe9
48 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-std-%{bootstrap_rust}-x86_64-unknown-linux-gnux32.tar.xz
49 # Source3-md5: d3c7de339814808e79bd78f92e18f75b
50 URL: https://www.rust-lang.org/
52 BuildRequires: cmake >= 3.4.3
54 BuildRequires: libstdc++-devel
55 %{?with_system_llvm:BuildRequires: llvm-devel}
56 BuildRequires: ncurses-devel
57 BuildRequires: python >= 1:2.7
58 BuildRequires: zlib-devel
59 %if %{without bootstrap}
60 BuildRequires: %{name} >= %{bootstrap_rust}
61 BuildRequires: cargo >= %{bootstrap_cargo}
62 BuildConflicts: %{name} > %{version}
64 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
66 # The C compiler is needed at runtime just for linking. Someday rustc might
67 # invoke the linker directly, and then we'll only need binutils.
68 # https://github.com/rust-lang/rust/issues/11937
70 # Only x86_64 and i686 are Tier 1 platforms at this time.
71 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
72 # https://doc.rust-lang.org/stable/book/getting-started.html#tier-1
73 ExclusiveArch: %{x8664} %{ix86} x32
74 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
77 %define rust_triple x86_64-unknown-linux-gnux32
78 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
80 %define rust_triple %{_target_cpu}-unknown-linux-gnu
81 %define rust_bootstrap_triple %{_target_cpu}-unknown-linux-gnu
84 %if %{without bootstrap}
85 %define local_rust_root %{_prefix}
87 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
88 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
91 # We're going to override --libdir when configuring to get rustlib into a
92 # common path, but we'll fix the shared libraries during install.
93 # Without this ugly hack, rust would not be able to build itself
94 # for non-bootstrap build, lib64 is just too complicated for it.
95 %define common_libdir %{_prefix}/lib
96 %define rustlibdir %{common_libdir}/rustlib
98 # once_call/once_callable non-function libstdc++ symbols
99 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
101 # ALL Rust libraries are private, because they don't keep an ABI.
102 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
103 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
106 Rust is a systems programming language that runs blazingly fast,
107 prevents segfaults, and guarantees thread safety.
109 This package includes the Rust compiler, standard library, and
110 documentation generator.
112 %description -l pl.UTF-8
113 Rust to systemowy język programowania działający bardzo szybko,
114 zapobiegający naruszeniom ochrony pamięci i gwarantujący
115 bezpieczną wielowątkowość.
117 %package debugger-common
118 Summary: Common debugger pretty printers for Rust
119 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
120 Group: Development/Debuggers
123 %description debugger-common
124 This package includes the common functionality for rust-gdb and
127 %description debugger-common -l pl.UTF-8
128 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
131 Summary: GDB pretty printers for Rust
132 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
133 Group: Development/Debuggers
134 Requires: %{name}-debugger-common = %{version}-%{release}
139 This package includes the rust-gdb script, which allows easier
140 debugging of Rust programs.
142 %description gdb -l pl.UTF-8
143 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
144 odpluskwianie programów w języku Rust.
147 Summary: LLDB pretty printers for Rust
148 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
149 Group: Development/Debuggers
150 Requires: %{name}-debugger-common = %{version}-%{release}
155 This package includes the rust-lldb script, which allows easier
156 debugging of Rust programs.
158 %description lldb -l pl.UTF-8
159 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
160 odpluskwianie programów w języku Rust.
163 Summary: Documentation for Rust
164 Summary(pl.UTF-8): Dokumentacja do Rusta
169 This package includes HTML documentation for the Rust programming
170 language and its standard library.
172 %description doc -l pl.UTF-8
173 Ten pakiet zawiera dokumentację w formacie HTML do języka
174 programowania Rust i jego biblioteki standardowej.
177 Summary: Rust's package manager and build tool
178 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
179 Group: Development/Tools
182 %description -n cargo
183 Cargo is a tool that allows Rust projects to declare their various
184 dependencies and ensure that you'll always get a repeatable build.
186 %description -n cargo -l pl.UTF-8
187 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
188 zależności i zapewniające powtarzalność procesu budowania.
190 %package -n bash-completion-cargo
191 Summary: Bash completion for cargo command
192 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
193 Group: Applications/Shells
194 Requires: %{name} = %{version}-%{release}
195 Requires: bash-completion
197 %description -n bash-completion-cargo
198 Bash completion for cargo command.
200 %description -n bash-completion-cargo -l pl.UTF-8
201 Bashowe dopełnianie parametrów polecenia cargo.
203 %package -n zsh-completion-cargo
204 Summary: Zsh completion for cargo command
205 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
206 Group: Applications/Shells
207 Requires: %{name} = %{version}-%{release}
210 %description -n zsh-completion-cargo
211 Zsh completion for cargo command.
213 %description -n zsh-completion-cargo -l pl.UTF-8
214 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
217 %setup -q -n %{rustc_package}
219 %if %{with bootstrap}
226 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
227 %{bootstrap_root}-root/install.sh \
228 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
229 --prefix=%{local_rust_root} \
231 test -f %{local_rust_root}/bin/cargo
232 test -f %{local_rust_root}/bin/rustc
236 # We're disabling jemalloc, but rust-src still wants it.
237 #%{__rm} -r src/jemalloc
238 %{?with_system_llvm:%{__rm} -r src/llvm-project}
240 # extract bundled licenses for packaging
241 sed -e '/*\//q' vendor/backtrace-sys/src/libbacktrace/backtrace.h \
242 >vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
244 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
245 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
248 # The configure macro will modify some autoconf-related files, which upsets
249 # cargo when it tries to verify checksums in those files. If we just truncate
250 # that file list, cargo won't have anything to complain about.
251 find vendor -name .cargo-checksum.json \
252 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
256 --build=%{rust_triple} \
257 --host=%{rust_triple} \
258 --target=%{rust_triple} \
259 --libdir=%{common_libdir} \
260 --disable-codegen-tests \
261 --disable-debuginfo-lines \
262 %if %{with full_debuginfo}
263 --disable-debuginfo-only-std \
266 --enable-debuginfo-only-std \
267 --disable-debuginfo \
270 --disable-option-checking \
273 --enable-llvm-link-shared \
275 --local-rust-root=%{local_rust_root} \
276 --llvm-root=%{_prefix} \
277 --release-channel=%{channel}
279 RUST_BACKTRACE=full \
280 ./x.py dist --verbose
282 %{?with_tests:./x.py test}
285 rm -rf $RPM_BUILD_ROOT
287 DESTDIR=$RPM_BUILD_ROOT ./x.py install
288 DESTDIR=$RPM_BUILD_ROOT ./x.py install src
290 # Make sure the shared libraries are in the proper libdir
291 %if "%{_libdir}" != "%{common_libdir}"
292 mkdir -p %{buildroot}%{_libdir}
293 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
294 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
297 # The shared libraries should be executable for debuginfo extraction.
298 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
300 # The libdir libraries are identical to those under rustlib/. It's easier on
301 # library loading if we keep them in libdir, but we do need them in rustlib/
302 # to support dynamic linking for compiler plugins, so we'll symlink.
303 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
304 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
305 -exec ln -v -f -s -t . '{}' '+')
307 # Remove installer artifacts (manifests, uninstall scripts, etc.)
308 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
310 # FIXME: __os_install_post will strip the rlibs
311 # -- should we find a way to preserve debuginfo?
313 # Remove unwanted documentation files (we already package them)
314 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
315 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
316 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
317 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
319 # Sanitize the HTML documentation
320 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
321 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
323 # Move rust-gdb's python scripts so they're noarch
324 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
325 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
327 # We don't need stdlib source
328 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
330 # Create the path for crate-devel packages
331 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
334 rm -rf $RPM_BUILD_ROOT
336 %post -p /sbin/ldconfig
337 %postun -p /sbin/ldconfig
340 %defattr(644,root,root,755)
341 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
342 %attr(755,root,root) %{_bindir}/miri
343 %attr(755,root,root) %{_bindir}/rls
344 %attr(755,root,root) %{_bindir}/rustc
345 %attr(755,root,root) %{_bindir}/rustdoc
346 %attr(755,root,root) %{_bindir}/rustfmt
347 %attr(755,root,root) %{_libdir}/libarena-*.so
348 %attr(755,root,root) %{_libdir}/libfmt_macros-*.so
349 %attr(755,root,root) %{_libdir}/libgraphviz-*.so
350 %attr(755,root,root) %{_libdir}/librustc*-*.so
351 %attr(755,root,root) %{_libdir}/libserialize-*.so
352 %attr(755,root,root) %{_libdir}/libstd-*.so
353 %attr(755,root,root) %{_libdir}/libsyntax-*.so
354 %attr(755,root,root) %{_libdir}/libsyntax_ext-*.so
355 %attr(755,root,root) %{_libdir}/libsyntax_pos-*.so
356 %attr(755,root,root) %{_libdir}/libterm-*.so
357 %attr(755,root,root) %{_libdir}/libtest-*.so
358 %{_mandir}/man1/rustc.1*
359 %{_mandir}/man1/rustdoc.1*
361 %dir %{rustlibdir}/%{rust_triple}
362 %{rustlibdir}/%{rust_triple}/analysis
363 %dir %{rustlibdir}/%{rust_triple}/codegen-backends
364 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/codegen-backends/*.so
365 %dir %{rustlibdir}/%{rust_triple}/lib
366 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
367 %{rustlibdir}/%{rust_triple}/lib/*.rlib
369 %files debugger-common
370 %defattr(644,root,root,755)
371 %dir %{_datadir}/%{name}
372 %dir %{_datadir}/%{name}/etc
373 %{_datadir}/%{name}/etc/debugger_*.py*
376 %defattr(644,root,root,755)
377 %attr(755,root,root) %{_bindir}/rust-lldb
378 %{_datadir}/%{name}/etc/lldb_*.py*
381 %defattr(644,root,root,755)
382 %attr(755,root,root) %{_bindir}/rust-gdb
383 %attr(755,root,root) %{_bindir}/rust-gdbgui
384 %{_datadir}/%{name}/etc/gdb_*.py*
387 %defattr(644,root,root,755)
388 %dir %{_docdir}/%{name}
389 %doc %{_docdir}/%{name}/html
392 %defattr(644,root,root,755)
393 %attr(755,root,root) %{_bindir}/cargo
394 %attr(755,root,root) %{_bindir}/cargo-clippy
395 %attr(755,root,root) %{_bindir}/cargo-fmt
396 %attr(755,root,root) %{_bindir}/cargo-miri
397 %attr(755,root,root) %{_bindir}/clippy-driver
398 %{_mandir}/man1/cargo*.1*
399 %dir %{_datadir}/cargo
400 %dir %{_datadir}/cargo/registry
402 %files -n bash-completion-cargo
403 %defattr(644,root,root,755)
404 %{_sysconfdir}/bash_completion.d/cargo
406 %files -n zsh-completion-cargo
407 %defattr(644,root,root,755)
408 %{zsh_compdir}/_cargo