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.46.0
25 %define bootstrap_cargo 1.46.0
26 %define bootstrap_date 2020-08-27
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: 6283a61cac54bb0a7d32bc447d07fadc
41 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
42 # Source1-md5: 45eaf35327db0bac923c65048637a2f5
43 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
44 # Source2-md5: 6a2422d81e98df5b71a959c70aa4c81b
45 Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
46 # Source3-md5: 144376df8b0ddfef57900b867746a9ab
47 Patch0: %{name}-x32.patch
48 URL: https://www.rust-lang.org/
50 BuildRequires: cmake >= 3.4.3
52 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
54 BuildRequires: python >= 1:2.7
55 BuildRequires: rpmbuild(macros) >= 1.752
57 BuildRequires: curl-devel
58 BuildRequires: libgit2-devel
59 BuildRequires: libstdc++-devel
60 %{?with_system_llvm:BuildRequires: llvm-devel >= 8.0}
61 BuildRequires: openssl-devel >= 1.0.1
62 BuildRequires: zlib-devel
64 %if %{without bootstrap}
65 BuildRequires: %{name} >= %{bootstrap_rust}
66 BuildRequires: cargo >= %{bootstrap_cargo}
67 BuildConflicts: %{name} > %{version}
70 BuildRequires: glibc-devel(x32)
71 BuildRequires: glibc-devel(x86_64)
72 %if "%{_host_cpu}" == "x86_64"
73 # building on x86_64 host with --target x32-pld-linux
74 BuildRequires: curl-devel
75 BuildRequires: gcc-multilib-x32
76 BuildRequires: libgit2-devel
77 BuildRequires: libstdc++-devel
78 %{?with_system_llvm:BuildRequires: llvm-devel >= 8.0}
79 BuildRequires: openssl-devel >= 1.0.1
80 BuildRequires: zlib-devel
82 # building x86_64-hosted crosscompiler on x32 host
83 BuildRequires: gcc-multilib-64
84 BuildRequires: libstdc++-multilib-64-devel
86 #BuildRequires: curl-devel.x86_64
87 #BuildRequires: libgit2-devel.x86_64
88 #BuildRequires: llvm-devel.x86_64 >= 7.0
89 #BuildRequires: openssl-devel.x86_64
90 #BuildRequires: zlib-devel.x86_64
93 # The C compiler is needed at runtime just for linking. Someday rustc might
94 # invoke the linker directly, and then we'll only need binutils.
95 # https://github.com/rust-lang/rust/issues/11937
97 # Only x86_64 and i686 are Tier 1 platforms at this time.
98 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
99 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
100 ExclusiveArch: %{x8664} %{ix86} x32 aarch64
101 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
104 %define rust_triple x86_64-unknown-linux-gnux32
105 %define rust_host_triple x86_64-unknown-linux-gnu
106 %define rust_bootstrap_triple x86_64-unknown-linux-gnu
108 %define rust_triple %{_target_cpu}-unknown-linux-gnu
109 %define rust_host_triple %{rust_triple}
110 %define rust_bootstrap_triple %{rust_triple}
113 %if %{without bootstrap}
114 %define local_rust_root %{_prefix}
116 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
117 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
120 # We're going to override --libdir when configuring to get rustlib into a
121 # common path, but we'll fix the shared libraries during install.
122 # Without this ugly hack, rust would not be able to build itself
123 # for non-bootstrap build, lib64 is just too complicated for it.
124 %define common_libdir %{_prefix}/lib
125 %define rustlibdir %{common_libdir}/rustlib
127 # once_call/once_callable non-function libstdc++ symbols
128 %define skip_post_check_so 'librustc.*llvm.*\.so.*'
130 # ALL Rust libraries are private, because they don't keep an ABI.
131 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
132 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
138 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
143 Rust is a systems programming language that runs blazingly fast,
144 prevents segfaults, and guarantees thread safety.
146 This package includes the Rust compiler, standard library, and
147 documentation generator.
149 %description -l pl.UTF-8
150 Rust to systemowy język programowania działający bardzo szybko,
151 zapobiegający naruszeniom ochrony pamięci i gwarantujący
152 bezpieczną wielowątkowość.
154 %package debugger-common
155 Summary: Common debugger pretty printers for Rust
156 Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
157 Group: Development/Debuggers
160 %description debugger-common
161 This package includes the common functionality for rust-gdb and
164 %description debugger-common -l pl.UTF-8
165 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
168 Summary: GDB pretty printers for Rust
169 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB
170 Group: Development/Debuggers
171 Requires: %{name}-debugger-common = %{version}-%{release}
176 This package includes the rust-gdb script, which allows easier
177 debugging of Rust programs.
179 %description gdb -l pl.UTF-8
180 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
181 odpluskwianie programów w języku Rust.
184 Summary: LLDB pretty printers for Rust
185 Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB
186 Group: Development/Debuggers
187 Requires: %{name}-debugger-common = %{version}-%{release}
192 This package includes the rust-lldb script, which allows easier
193 debugging of Rust programs.
195 %description lldb -l pl.UTF-8
196 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
197 odpluskwianie programów w języku Rust.
200 Summary: Documentation for Rust
201 Summary(pl.UTF-8): Dokumentacja do Rusta
206 This package includes HTML documentation for the Rust programming
207 language and its standard library.
209 %description doc -l pl.UTF-8
210 Ten pakiet zawiera dokumentację w formacie HTML do języka
211 programowania Rust i jego biblioteki standardowej.
214 Summary: Rust's package manager and build tool
215 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
216 Group: Development/Tools
219 %description -n cargo
220 Cargo is a tool that allows Rust projects to declare their various
221 dependencies and ensure that you'll always get a repeatable build.
223 %description -n cargo -l pl.UTF-8
224 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
225 zależności i zapewniające powtarzalność procesu budowania.
227 %package -n bash-completion-cargo
228 Summary: Bash completion for cargo command
229 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
230 Group: Applications/Shells
231 Requires: %{name} = %{version}-%{release}
232 Requires: bash-completion
234 %description -n bash-completion-cargo
235 Bash completion for cargo command.
237 %description -n bash-completion-cargo -l pl.UTF-8
238 Bashowe dopełnianie parametrów polecenia cargo.
240 %package -n zsh-completion-cargo
241 Summary: Zsh completion for cargo command
242 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
243 Group: Applications/Shells
244 Requires: %{name} = %{version}-%{release}
247 %description -n zsh-completion-cargo
248 Zsh completion for cargo command.
250 %description -n zsh-completion-cargo -l pl.UTF-8
251 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
254 %setup -q -n %{rustc_package}
255 # irrelevant when not building rustc for x32
258 %if %{with bootstrap}
268 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
269 %{bootstrap_root}-root/install.sh \
270 --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
271 --prefix=%{local_rust_root} \
273 test -f %{local_rust_root}/bin/cargo
274 test -f %{local_rust_root}/bin/rustc
278 # We're disabling jemalloc, but rust-src still wants it.
279 #%{__rm} -r src/jemalloc
280 %{?with_system_llvm:%{__rm} -r src/llvm-project}
282 # extract bundled licenses for packaging
283 sed -e '/*\//q' library/backtrace/crates/backtrace-sys/src/libbacktrace/backtrace.h \
284 >library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
286 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
287 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
290 # The configure macro will modify some autoconf-related files, which upsets
291 # cargo when it tries to verify checksums in those files. If we just truncate
292 # that file list, cargo won't have anything to complain about.
293 find vendor -name .cargo-checksum.json \
294 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
298 --build=%{rust_bootstrap_triple} \
299 --host=%{rust_host_triple} \
300 --target=%{rust_triple} \
301 --libdir=%{common_libdir} \
302 --disable-codegen-tests \
303 --disable-debuginfo-lines \
304 %if %{with full_debuginfo}
305 --disable-debuginfo-only-std \
308 --enable-debuginfo-only-std \
309 --disable-debuginfo \
312 --disable-option-checking \
315 --enable-llvm-link-shared \
317 --local-rust-root=%{local_rust_root} \
318 --llvm-root=%{_prefix} \
319 --release-channel=%{channel}
321 export RUST_BACKTRACE=full
324 %{?with_tests:%x_py test}
327 rm -rf $RPM_BUILD_ROOT
329 export DESTDIR=$RPM_BUILD_ROOT
333 # Make sure the shared libraries are in the proper libdir
334 %if "%{_libdir}" != "%{common_libdir}"
335 mkdir -p %{buildroot}%{_libdir}
336 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
337 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
340 # The shared libraries should be executable for debuginfo extraction.
341 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
343 # The libdir libraries are identical to those under rustlib/. It's easier on
344 # library loading if we keep them in libdir, but we do need them in rustlib/
345 # to support dynamic linking for compiler plugins, so we'll symlink.
346 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
347 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
348 -exec ln -v -f -s -t . '{}' '+')
350 # Remove installer artifacts (manifests, uninstall scripts, etc.)
351 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
353 # FIXME: __os_install_post will strip the rlibs
354 # -- should we find a way to preserve debuginfo?
356 # Remove unwanted documentation files (we already package them)
357 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
358 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
359 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
360 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
362 # Sanitize the HTML documentation
363 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
364 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
366 # Move rust-gdb's python scripts so they're noarch
367 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
368 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
370 # We don't need stdlib source
371 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
373 # Create the path for crate-devel packages
374 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
377 rm -rf $RPM_BUILD_ROOT
379 %post -p /sbin/ldconfig
380 %postun -p /sbin/ldconfig
383 %defattr(644,root,root,755)
384 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
385 %attr(755,root,root) %{_bindir}/rls
386 %attr(755,root,root) %{_bindir}/rust-analyzer
387 %attr(755,root,root) %{_bindir}/rustc
388 %attr(755,root,root) %{_bindir}/rustdoc
389 %attr(755,root,root) %{_bindir}/rustfmt
390 %attr(755,root,root) %{_libdir}/libchalk_derive-*.so
391 %attr(755,root,root) %{_libdir}/librustc*-*.so
392 %attr(755,root,root) %{_libdir}/libstd-*.so
393 %attr(755,root,root) %{_libdir}/libtest-*.so
394 %attr(755,root,root) %{_libdir}/libtracing_attributes-*.so
395 %{_mandir}/man1/rustc.1*
396 %{_mandir}/man1/rustdoc.1*
398 %dir %{rustlibdir}/%{rust_triple}
399 %{rustlibdir}/%{rust_triple}/analysis
400 %dir %{rustlibdir}/%{rust_triple}/lib
401 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
402 %{rustlibdir}/%{rust_triple}/lib/*.rlib
404 # for cross-compiler (e.g. x86_64-hosted x32 rust)
405 %if "%{rust_host_triple}" != "%{rust_triple}"
406 %dir %{rustlibdir}/%{rust_host_triple}
407 %{rustlibdir}/%{rust_host_triple}/analysis
408 %dir %{rustlibdir}/%{rust_host_triple}/lib
409 %attr(755,root,root) %{rustlibdir}/%{rust_host_triple}/lib/*.so
410 %{rustlibdir}/%{rust_host_triple}/lib/*.rlib
413 %files debugger-common
414 %defattr(644,root,root,755)
415 %dir %{_datadir}/%{name}
416 %dir %{_datadir}/%{name}/etc
417 %{_datadir}/%{name}/etc/lldb_commands
418 %{_datadir}/%{name}/etc/rust_types.py
421 %defattr(644,root,root,755)
422 %attr(755,root,root) %{_bindir}/rust-lldb
423 %{_datadir}/%{name}/etc/lldb_*.py*
426 %defattr(644,root,root,755)
427 %attr(755,root,root) %{_bindir}/rust-gdb
428 %attr(755,root,root) %{_bindir}/rust-gdbgui
429 %{_datadir}/%{name}/etc/gdb_*.py*
432 %defattr(644,root,root,755)
433 %dir %{_docdir}/%{name}
434 %doc %{_docdir}/%{name}/html
437 %defattr(644,root,root,755)
438 %attr(755,root,root) %{_bindir}/cargo
439 %attr(755,root,root) %{_bindir}/cargo-clippy
440 %attr(755,root,root) %{_bindir}/cargo-fmt
441 %attr(755,root,root) %{_bindir}/clippy-driver
442 %{_mandir}/man1/cargo*.1*
443 %dir %{_datadir}/cargo
444 %dir %{_datadir}/cargo/registry
446 %files -n bash-completion-cargo
447 %defattr(644,root,root,755)
448 %{_sysconfdir}/bash_completion.d/cargo
450 %files -n zsh-completion-cargo
451 %defattr(644,root,root,755)
452 %{zsh_compdir}/_cargo