2 # - consider a rust-std package containing .../rustlib/$target
3 # This might allow multilib cross-compilation to work naturally.
7 %bcond_with tests # build without tests
9 # The channel can be stable, beta, or nightly
10 %define channel stable
12 %if "%{channel}" == "stable"
13 %define rustc_package rustc-%{version}-src
15 %define rustc_package rustc-%{channel}-src
18 # To bootstrap from scratch, set the channel and date from src/stage0.txt
19 # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
20 # or nightly wants some beta-YYYY-MM-DD
21 %define bootstrap_rust 1.17.0
22 %define bootstrap_cargo 0.18.0
23 %define bootstrap_date 2017-04-27
25 Summary: The Rust Programming Language
29 # Licenses: (rust itself) and (bundled libraries)
30 License: (ASL 2.0 or MIT) and (BSD and ISC and MIT)
31 Group: Development/Languages
32 Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.gz
33 # Source0-md5: c37c0cd9d500f6a9d1f2f44401351f88
34 Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.gz
35 # Source1-md5: 98e8f479515969123b4c203191104a54
36 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.gz
37 # Source2-md5: 2d5de850c32aa8d40c8c21abacf749f8
38 Patch0: rust-1.16.0-configure-no-override.patch
39 URL: https://www.rust-lang.org/
43 BuildRequires: libstdc++-devel
44 BuildRequires: libstdc++-devel
45 BuildRequires: llvm-devel
46 BuildRequires: ncurses-devel
48 BuildRequires: zlib-devel
49 %if %{without bootstrap}
50 BuildRequires: %{name} < %{version}-%{release}
51 BuildRequires: %{name} >= %{bootstrap_rust}
52 BuildRequires: cargo >= %{bootstrap_cargo}
54 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
56 # The C compiler is needed at runtime just for linking. Someday rustc might
57 # invoke the linker directly, and then we'll only need binutils.
58 # https://github.com/rust-lang/rust/issues/11937
60 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
61 # Only x86_64 and i686 are Tier 1 platforms at this time.
62 # https://doc.rust-lang.org/stable/book/getting-started.html#tier-1
63 ExclusiveArch: %{x8664} %{ix86}
65 %define rust_triple %{_target_cpu}-unknown-linux-gnu
67 %if %{without bootstrap}
68 %define local_rust_root %{_prefix}
70 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_triple}
71 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
74 # once_call/once_callable non-function libstdc++ symbols
75 %define skip_post_check_so 'librustc_llvm-.*\.so.*'
77 # ALL Rust libraries are private, because they don't keep an ABI.
78 %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
79 %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
82 Rust is a systems programming language that runs blazingly fast,
83 prevents segfaults, and guarantees thread safety.
85 This package includes the Rust compiler, standard library, and
86 documentation generator.
88 %package debugger-common
89 Summary: Common debugger pretty printers for Rust
90 Group: Development/Debuggers
93 %description debugger-common
94 This package includes the common functionality for %{name}-gdb and
98 Summary: GDB pretty printers for Rust
99 Group: Development/Debuggers
100 Requires: %{name}-debugger-common = %{version}-%{release}
105 This package includes the rust-gdb script, which allows easier
106 debugging of Rust programs.
109 Summary: LLDB pretty printers for Rust
110 Group: Development/Debuggers
111 Requires: %{name}-debugger-common = %{version}-%{release}
113 Requires: python-lldb
117 This package includes the rust-lldb script, which allows easier
118 debugging of Rust programs.
121 Summary: Documentation for Rust
126 This package includes HTML documentation for the Rust programming
127 language and its standard library.
130 %setup -q -n %{rustc_package}
133 %if %{with bootstrap}
140 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
141 %{bootstrap_root}-root/install.sh \
142 --components=cargo,rustc,rust-std-%{rust_triple} \
143 --prefix=%{local_rust_root} \
145 test -f %{local_rust_root}/bin/cargo
146 test -f %{local_rust_root}/bin/rustc
153 # extract bundled licenses for packaging
154 cp -p src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown
155 sed -e '/*\//q' src/libbacktrace/backtrace.h \
156 >src/libbacktrace/LICENSE-libbacktrace
158 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
159 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
162 # These tests assume that alloc_jemalloc is present
163 sed -i -e '1i // ignore-test jemalloc is disabled' \
164 src/test/compile-fail/allocator-dylib-is-system.rs \
165 src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs \
166 src/test/run-pass/allocator-default.rs
170 --disable-option-checking \
171 --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
172 --enable-local-rust --local-rust-root=%{local_rust_root} \
173 --llvm-root=%{_prefix} --disable-codegen-tests \
174 --enable-llvm-link-shared \
179 --release-channel=%{channel}
183 %{?with_tests:./x.py test}
186 rm -rf $RPM_BUILD_ROOT
188 DESTDIR=$RPM_BUILD_ROOT ./x.py dist --install
190 # The shared libraries should be executable for debuginfo extraction.
191 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
193 # The libdir libraries are identical to those under rustlib/. It's easier on
194 # library loading if we keep them in libdir, but we do need them in rustlib/
195 # to support dynamic linking for compiler plugins, so we'll symlink.
196 (cd "$RPM_BUILD_ROOT%{_libdir}/rustlib/%{rust_triple}/lib" &&
197 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
198 -exec ln -v -f -s -t . '{}' '+')
200 # Remove installer artifacts (manifests, uninstall scripts, etc.)
201 find $RPM_BUILD_ROOT%{_libdir}/rustlib/ -maxdepth 1 -type f -exec rm -v '{}' '+'
203 # FIXME: __os_install_post will strip the rlibs
204 # -- should we find a way to preserve debuginfo?
206 # Remove unwanted documentation files (we already package them)
207 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
208 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
209 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
210 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
212 # Sanitize the HTML documentation
213 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
214 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
216 # Move rust-gdb's python scripts so they're noarch
217 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
218 mv -v $RPM_BUILD_ROOT%{_libdir}/rustlib%{_sysconfdir} $RPM_BUILD_ROOT%{_datadir}/%{name}/
221 rm -rf $RPM_BUILD_ROOT
223 %post -p /sbin/ldconfig
224 %postun -p /sbin/ldconfig
227 %defattr(644,root,root,755)
228 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT
229 %doc src/libbacktrace/LICENSE-libbacktrace
230 %doc src/rt/hoedown/LICENSE-hoedown
232 %attr(755,root,root) %{_bindir}/rustc
233 %attr(755,root,root) %{_bindir}/rustdoc
234 %{_mandir}/man1/rustc.1*
235 %{_mandir}/man1/rustdoc.1*
237 %dir %{_libdir}/rustlib
238 %{_libdir}/rustlib/%{rust_triple}
240 %files debugger-common
241 %defattr(644,root,root,755)
242 %dir %{_datadir}/%{name}
243 %dir %{_datadir}/%{name}/etc
244 %{_datadir}/%{name}/etc/debugger_*.py*
247 %defattr(644,root,root,755)
248 %attr(755,root,root) %{_bindir}/rust-lldb
249 %{_datadir}/%{name}/etc/lldb_*.py*
252 %defattr(644,root,root,755)
253 %attr(755,root,root) %{_bindir}/rust-gdb
254 %{_datadir}/%{name}/etc/gdb_*.py*
257 %defattr(644,root,root,755)
258 %dir %{_docdir}/%{name}
259 %doc %{_docdir}/%{name}/html