2 # - consider a rust-std package containing .../rustlib/$target
3 # This might allow multilib cross-compilation to work naturally.
5 # The channel can be stable, beta, or nightly
11 %bcond_without tests # build without tests
13 %if "%{channel}" == "stable"
14 %define rustc_package rustc-%{version}-src
16 %define rustc_package rustc-%{channel}-src
19 # To bootstrap from scratch, set the channel and date from src/stage0.txt
20 # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
21 # or nightly wants some beta-YYYY-MM-DD
22 %define bootstrap_rust 1.17.0
23 %define bootstrap_cargo 0.18.0
24 %define bootstrap_date 2017-04-27
25 %define bootstrap_base https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}
27 Summary: The Rust Programming Language
31 # Licenses: (rust itself) and (bundled libraries)
32 License: (ASL 2.0 or MIT) and (BSD and ISC and MIT)
33 Group: Development/Languages
34 Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.gz
35 # Source0-md5: c37c0cd9d500f6a9d1f2f44401351f88
36 Source1: %{bootstrap_base}-x86_64-unknown-linux-gnu.tar.gz
37 # Source1-md5: 98e8f479515969123b4c203191104a54
38 Source2: %{bootstrap_base}-i686-unknown-linux-gnu.tar.gz
39 # Source2-md5: 2d5de850c32aa8d40c8c21abacf749f8
40 URL: https://www.rust-lang.org/
44 BuildRequires: libstdc++-devel
45 BuildRequires: libstdc++-devel
46 BuildRequires: llvm-devel
47 BuildRequires: ncurses-devel
49 BuildRequires: zlib-devel
50 %if %{without bootstrap}
51 BuildRequires: %{name} < %{version}-%{release}
52 BuildRequires: %{name} >= %{bootstrap_rust}
53 BuildRequires: cargo >= %{bootstrap_cargo}
55 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
57 # The C compiler is needed at runtime just for linking. Someday rustc might
58 # invoke the linker directly, and then we'll only need binutils.
59 # https://github.com/rust-lang/rust/issues/11937
61 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
62 # Only x86_64 and i686 are Tier 1 platforms at this time.
63 # https://doc.rust-lang.org/stable/book/getting-started.html#tier-1
64 ExclusiveArch: %{x8664} %{ix86} %{arm}
66 %define rust_triple %{_target_cpu}-unknown-linux-gnu
68 %if %{without bootstrap}
69 %define local_rust_root %{_prefix}
71 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_triple}
72 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
75 # once_call/once_callable non-function libstdc++ symbols
76 %define skip_post_check_so 'librustc_llvm-.*\.so.*'
78 # ALL Rust libraries are private, because they don't keep an ABI.
79 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
80 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
83 Rust is a systems programming language that runs blazingly fast,
84 prevents segfaults, and guarantees thread safety.
86 This package includes the Rust compiler, standard library, and
87 documentation generator.
89 %package debugger-common
90 Summary: Common debugger pretty printers for Rust
91 Group: Development/Debuggers
94 %description debugger-common
95 This package includes the common functionality for %{name}-gdb and
99 Summary: GDB pretty printers for Rust
100 Group: Development/Debuggers
101 Requires: %{name}-debugger-common = %{version}-%{release}
106 This package includes the rust-gdb script, which allows easier
107 debugging of Rust programs.
110 Summary: LLDB pretty printers for Rust
111 Group: Development/Debuggers
112 Requires: %{name}-debugger-common = %{version}-%{release}
114 Requires: python-lldb
118 This package includes the rust-lldb script, which allows easier
119 debugging of Rust programs.
122 Summary: Documentation for Rust
127 This package includes HTML documentation for the Rust programming
128 language and its standard library.
131 %setup -q -n %{rustc_package}
132 %if %{with bootstrap}
139 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
140 %{bootstrap_root}-root/install.sh \
141 --components=cargo,rustc,rust-std-%{rust_triple} \
142 --prefix=%{local_rust_root} \
144 test -f %{local_rust_root}/bin/cargo
145 test -f %{local_rust_root}/bin/rustc
152 # extract bundled licenses for packaging
153 cp -p src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown
154 sed -e '/*\//q' src/libbacktrace/backtrace.h \
155 >src/libbacktrace/LICENSE-libbacktrace
157 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
158 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
161 # These tests assume that alloc_jemalloc is present
162 sed -i -e '1i // ignore-test jemalloc is disabled' \
163 src/test/compile-fail/allocator-dylib-is-system.rs \
164 src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs \
165 src/test/run-pass/allocator-default.rs
167 # Fedora's LLVM doesn't support any mips targets -- see "llc -version".
168 # Fixed properly by Rust PR36344, which should be released in 1.13.
169 sed -i -e '/target=mips/,+1s/^/# unsupported /' \
170 src/test/run-make/atomic-lock-free/Makefile
172 %if %{without bootstrap}
173 # The hardcoded stage0 "lib" is inappropriate when using Fedora's own rustc
174 sed -i -e '/^HLIB_RELATIVE/s/lib$/$$(CFG_LIBDIR_RELATIVE)/' mk/main.mk
179 --disable-option-checking \
180 --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
181 --enable-local-rust --local-rust-root=%{local_rust_root} \
182 --llvm-root=%{_prefix} --disable-codegen-tests \
187 --release-channel=%{channel}
192 rm -rf $RPM_BUILD_ROOT
194 DESTDIR=$RPM_BUILD_ROOT ./x.py dist --install
196 # The shared libraries should be executable for debuginfo extraction.
197 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
199 # The libdir libraries are identical to those under rustlib/. It's easier on
200 # library loading if we keep them in libdir, but we do need them in rustlib/
201 # to support dynamic linking for compiler plugins, so we'll symlink.
202 (cd "$RPM_BUILD_ROOT%{_libdir}/rustlib/%{rust_triple}/lib" &&
203 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
204 -exec ln -v -f -s -t . '{}' '+')
206 # Remove installer artifacts (manifests, uninstall scripts, etc.)
207 find $RPM_BUILD_ROOT%{_libdir}/rustlib/ -maxdepth 1 -type f -exec rm -v '{}' '+'
209 # FIXME: __os_install_post will strip the rlibs
210 # -- should we find a way to preserve debuginfo?
212 # Remove unwanted documentation files (we already package them)
213 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
214 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
215 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
216 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
218 # Sanitize the HTML documentation
219 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
220 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
222 # Move rust-gdb's python scripts so they're noarch
223 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
224 mv -v $RPM_BUILD_ROOT%{_libdir}/rustlib%{_sysconfdir} $RPM_BUILD_ROOT%{_datadir}/%{name}/
227 rm -rf $RPM_BUILD_ROOT
229 %post -p /sbin/ldconfig
230 %postun -p /sbin/ldconfig
233 %defattr(644,root,root,755)
234 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT
235 %doc src/libbacktrace/LICENSE-libbacktrace
236 %doc src/rt/hoedown/LICENSE-hoedown
238 %attr(755,root,root) %{_bindir}/rustc
239 %attr(755,root,root) %{_bindir}/rustdoc
240 %{_mandir}/man1/rustc.1*
241 %{_mandir}/man1/rustdoc.1*
243 %dir %{_libdir}/rustlib
244 %{_libdir}/rustlib/%{rust_triple}
246 %files debugger-common
247 %defattr(644,root,root,755)
248 %dir %{_datadir}/%{name}
249 %dir %{_datadir}/%{name}/etc
250 %{_datadir}/%{name}/etc/debugger_*.py*
253 %defattr(644,root,root,755)
254 %attr(755,root,root) %{_bindir}/rust-lldb
255 %{_datadir}/%{name}/etc/lldb_*.py*
258 %defattr(644,root,root,755)
259 %attr(755,root,root) %{_bindir}/rust-gdb
260 %{_datadir}/%{name}/etc/gdb_*.py*
263 %defattr(644,root,root,755)
264 %dir %{_docdir}/%{name}
265 %doc %{_docdir}/%{name}/html