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}
16 %define rustc_package rustc-%{channel}
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_channel 1.11.0
23 %define bootstrap_date 2016-08-16
24 %define bootstrap_base https://static.rust-lang.org/dist/%{bootstrap_date}/rustc-%{bootstrap_channel}
26 Summary: The Rust Programming Language
30 License: (ASL 2.0 or MIT) and (BSD and ISC and MIT)
31 # ^ written as: (rust itself) and (bundled libraries)
32 Group: Development/Languages
33 Source0: https://static.rust-lang.org/dist/%{rustc_package}-src.tar.gz
35 Source1: %{bootstrap_base}-x86_64-unknown-linux-gnu.tar.gz
36 Source2: %{bootstrap_base}-i686-unknown-linux-gnu.tar.gz
38 URL: https://www.rust-lang.org/
42 BuildRequires: libstdc++-devel
43 BuildRequires: llvm-devel
45 BuildRequires: zlib-devel
46 %if %{without bootstrap}
47 BuildRequires: %{name} < %{version}-%{release}
48 BuildRequires: %{name} >= %{bootstrap_channel}
50 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
52 # TODO: work on unbundling these!
53 Provides: bundled(hoedown) = 3.0.5
54 Provides: bundled(jquery) = 2.1.4
55 Provides: bundled(libbacktrace) = 6.1.0
56 Provides: bundled(miniz) = 1.14
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 rustc-%{bootstrap_channel}-%{rust_triple}
72 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}/rustc
75 # ALL Rust libraries are private, because they don't keep an ABI.
76 %global _privatelibs lib.*-[[:xdigit:]]{8}[.]so.*
77 %global __provides_exclude ^(%{_privatelibs})$
78 %global __requires_exclude ^(%{_privatelibs})$
81 Rust is a systems programming language that runs blazingly fast,
82 prevents segfaults, and guarantees thread safety.
84 This package includes the Rust compiler, standard library, and
85 documentation generator.
88 Summary: GDB pretty printers for Rust
90 %if "%{_rpmversion}" >= "5"
95 This package includes the rust-gdb script, which allows easier
96 debugging of Rust programs.
99 Summary: Documentation for Rust
100 # NOT BuildArch: noarch
101 # Note, while docs are mostly noarch, some things do vary by target_arch.
102 # Koji will fail the build in rpmdiff if two architectures build a noarch
103 # subpackage differently, so instead we have to keep its arch.
106 This package includes HTML documentation for the Rust programming
107 language and its standard library.
110 %setup -q -n %{rustc_package}
111 %if %{with bootstrap}
118 test -f %{local_rust_root}/bin/rustc
125 # extract bundled licenses for packaging
126 cp -p src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown
127 sed -e '/*\//q' src/libbacktrace/backtrace.h \
128 >src/libbacktrace/LICENSE-libbacktrace
130 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
131 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
134 # These tests assume that alloc_jemalloc is present
135 sed -i -e '1i // ignore-test jemalloc is disabled' \
136 src/test/compile-fail/allocator-dylib-is-system.rs \
137 src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs \
138 src/test/run-pass/allocator-default.rs
140 # Fedora's LLVM doesn't support any mips targets -- see "llc -version".
141 # Fixed properly by Rust PR36344, which should be released in 1.13.
142 sed -i -e '/target=mips/,+1s/^/# unsupported /' \
143 src/test/run-make/atomic-lock-free/Makefile
145 %if %{without bootstrap}
146 # The hardcoded stage0 "lib" is inappropriate when using Fedora's own rustc
147 sed -i -e '/^HLIB_RELATIVE/s/lib$/$$(CFG_LIBDIR_RELATIVE)/' mk/main.mk
152 --disable-option-checking \
153 --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
154 --enable-local-rust --local-rust-root=%{local_rust_root} \
155 --llvm-root=%{_prefix} --disable-codegen-tests \
159 --release-channel=%{channel}
164 # Note, many of the tests execute in parallel threads,
165 # so it's better not to use a parallel make here.
166 %{__make} -j1 check-lite VERBOSE=1 -k
171 rm -rf $RPM_BUILD_ROOT
174 DESTDIR=$RPM_BUILD_ROOT
176 # Remove installer artifacts (manifests, uninstall scripts, etc.)
177 find $RPM_BUILD_ROOT%{_libdir}/rustlib/ -maxdepth 1 -type f -exec rm -v '{}' '+'
179 # We don't want to ship the target shared libraries for lack of any Rust ABI.
180 find $RPM_BUILD_ROOT%{_libdir}/rustlib/ -type f -name '*.so' -exec rm -v '{}' '+'
182 # The remaining shared libraries should be executable for debuginfo extraction.
183 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
185 # They also don't need the .rustc metadata anymore, so they won't support linking.
186 # (but direct section removal breaks dynamic symbols -- leave it for now...)
187 #find $RPM_BUILD_ROOT/%{_libdir}/ -type f -name '*.so' -exec objcopy -R .rustc '{}' ';'
189 # FIXME: __os_install_post will strip the rlibs
190 # -- should we find a way to preserve debuginfo?
192 # Remove unwanted documentation files (we already package them)
193 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
194 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
195 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
196 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
198 # Sanitize the HTML documentation
199 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
200 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
202 # Move rust-gdb's python scripts so they're noarch
203 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
204 mv -v $RPM_BUILD_ROOT%{_libdir}/rustlib%{_sysconfdir} $RPM_BUILD_ROOT%{_datadir}/%{name}/
207 rm -rf $RPM_BUILD_ROOT
209 %post -p /sbin/ldconfig
210 %postun -p /sbin/ldconfig
213 %defattr(644,root,root,755)
214 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT
215 %doc src/libbacktrace/LICENSE-libbacktrace
216 %doc src/rt/hoedown/LICENSE-hoedown
218 %attr(755,root,root) %{_bindir}/rustc
219 %attr(755,root,root) %{_bindir}/rustdoc
220 %{_mandir}/man1/rustc.1*
221 %{_mandir}/man1/rustdoc.1*
223 %dir %{_libdir}/rustlib
224 %{_libdir}/rustlib/%{rust_triple}
227 %defattr(644,root,root,755)
228 %attr(755,root,root) %{_bindir}/rust-gdb
232 %defattr(644,root,root,755)
233 %dir %{_docdir}/%{name}
234 %doc %{_docdir}/%{name}/html/FiraSans-LICENSE.txt
235 %doc %{_docdir}/%{name}/html/Heuristica-LICENSE.txt
236 %doc %{_docdir}/%{name}/html/LICENSE-APACHE.txt
237 %doc %{_docdir}/%{name}/html/LICENSE-MIT.txt
238 %doc %{_docdir}/%{name}/html/SourceCodePro-LICENSE.txt
239 %doc %{_docdir}/%{name}/html/SourceSerifPro-LICENSE.txt
240 %doc %{_docdir}/%{name}/html/