]>
Commit | Line | Data |
---|---|---|
e361528e ER |
1 | # TODO |
2 | # - consider a rust-std package containing .../rustlib/$target | |
3 | # This might allow multilib cross-compilation to work naturally. | |
e361528e ER |
4 | # |
5 | # Conditional build: | |
8a073211 | 6 | %bcond_with bootstrap |
cace5bf9 | 7 | %bcond_with tests # build without tests |
e361528e | 8 | |
8a073211 JR |
9 | # The channel can be stable, beta, or nightly |
10 | %define channel stable | |
11 | ||
e361528e | 12 | %if "%{channel}" == "stable" |
8a073211 | 13 | %define rustc_package rustc-%{version}-src |
e361528e | 14 | %else |
8a073211 | 15 | %define rustc_package rustc-%{channel}-src |
e361528e ER |
16 | %endif |
17 | ||
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 | |
8a073211 JR |
21 | %define bootstrap_rust 1.17.0 |
22 | %define bootstrap_cargo 0.18.0 | |
23 | %define bootstrap_date 2017-04-27 | |
e361528e ER |
24 | |
25 | Summary: The Rust Programming Language | |
26 | Name: rust | |
d6d4cb2b | 27 | Version: 1.18.0 |
c9b8e3ee | 28 | Release: 2 |
d1b96fd8 | 29 | # Licenses: (rust itself) and (bundled libraries) |
e361528e | 30 | License: (ASL 2.0 or MIT) and (BSD and ISC and MIT) |
e361528e | 31 | Group: Development/Languages |
d6d4cb2b JR |
32 | Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.gz |
33 | # Source0-md5: c37c0cd9d500f6a9d1f2f44401351f88 | |
8a073211 | 34 | Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.gz |
d6d4cb2b | 35 | # Source1-md5: 98e8f479515969123b4c203191104a54 |
8a073211 | 36 | Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.gz |
d6d4cb2b | 37 | # Source2-md5: 2d5de850c32aa8d40c8c21abacf749f8 |
b5eceb5e | 38 | Patch0: rust-1.16.0-configure-no-override.patch |
e361528e ER |
39 | URL: https://www.rust-lang.org/ |
40 | BuildRequires: cmake | |
41 | BuildRequires: curl | |
42 | BuildRequires: gcc | |
43 | BuildRequires: libstdc++-devel | |
d1b96fd8 | 44 | BuildRequires: libstdc++-devel |
e361528e | 45 | BuildRequires: llvm-devel |
d1b96fd8 | 46 | BuildRequires: ncurses-devel |
e361528e ER |
47 | BuildRequires: python |
48 | BuildRequires: zlib-devel | |
49 | %if %{without bootstrap} | |
d6d4cb2b | 50 | BuildRequires: %{name} >= %{bootstrap_rust} |
d1b96fd8 | 51 | BuildRequires: cargo >= %{bootstrap_cargo} |
ff5a5e0b | 52 | BuildConflicts: %{name} > %{version} |
e361528e ER |
53 | %endif |
54 | # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs | |
55 | BuildRequires: procps | |
e361528e ER |
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 | |
59 | Requires: gcc | |
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 | |
d36946a0 | 63 | ExclusiveArch: %{x8664} %{ix86} |
e361528e | 64 | |
8a073211 | 65 | %define rust_triple %{_target_cpu}-unknown-linux-gnu |
e361528e ER |
66 | |
67 | %if %{without bootstrap} | |
8a073211 | 68 | %define local_rust_root %{_prefix} |
e361528e | 69 | %else |
8a073211 JR |
70 | %define bootstrap_root rust-%{bootstrap_rust}-%{rust_triple} |
71 | %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root} | |
e361528e ER |
72 | %endif |
73 | ||
18a1004b JR |
74 | # We're going to override --libdir when configuring to get rustlib into a |
75 | # common path, but we'll fix the shared libraries during install. | |
76 | # Without this ugly hack, rust would not be able to buld itself | |
77 | # for non-bootstrap build, lib64 is just too complicated for it. | |
78 | %define common_libdir %{_prefix}/lib | |
79 | %define rustlibdir %{common_libdir}/rustlib | |
80 | ||
19f98749 | 81 | # once_call/once_callable non-function libstdc++ symbols |
8a073211 | 82 | %define skip_post_check_so 'librustc_llvm-.*\.so.*' |
19f98749 | 83 | |
e361528e | 84 | # ALL Rust libraries are private, because they don't keep an ABI. |
8a073211 JR |
85 | %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.* |
86 | %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.* | |
e361528e ER |
87 | |
88 | %description | |
89 | Rust is a systems programming language that runs blazingly fast, | |
90 | prevents segfaults, and guarantees thread safety. | |
91 | ||
92 | This package includes the Rust compiler, standard library, and | |
93 | documentation generator. | |
94 | ||
d1b96fd8 JR |
95 | %package debugger-common |
96 | Summary: Common debugger pretty printers for Rust | |
97 | Group: Development/Debuggers | |
b19b9d51 | 98 | %if "%{_rpmversion}" >= "5" |
d1b96fd8 | 99 | BuildArch: noarch |
b19b9d51 | 100 | %endif |
d1b96fd8 JR |
101 | |
102 | %description debugger-common | |
103 | This package includes the common functionality for %{name}-gdb and | |
104 | %{name}-lldb. | |
105 | ||
e361528e ER |
106 | %package gdb |
107 | Summary: GDB pretty printers for Rust | |
d1b96fd8 JR |
108 | Group: Development/Debuggers |
109 | Requires: %{name}-debugger-common = %{version}-%{release} | |
e361528e | 110 | Requires: gdb |
b19b9d51 | 111 | %if "%{_rpmversion}" >= "5" |
e361528e | 112 | BuildArch: noarch |
b19b9d51 | 113 | %endif |
e361528e ER |
114 | |
115 | %description gdb | |
116 | This package includes the rust-gdb script, which allows easier | |
117 | debugging of Rust programs. | |
118 | ||
d1b96fd8 JR |
119 | %package lldb |
120 | Summary: LLDB pretty printers for Rust | |
121 | Group: Development/Debuggers | |
122 | Requires: %{name}-debugger-common = %{version}-%{release} | |
123 | Requires: lldb | |
b19b9d51 | 124 | %if "%{_rpmversion}" >= "5" |
d1b96fd8 | 125 | BuildArch: noarch |
b19b9d51 | 126 | %endif |
d1b96fd8 JR |
127 | |
128 | %description lldb | |
129 | This package includes the rust-lldb script, which allows easier | |
130 | debugging of Rust programs. | |
131 | ||
e361528e ER |
132 | %package doc |
133 | Summary: Documentation for Rust | |
d1b96fd8 | 134 | Group: Documentation |
b19b9d51 | 135 | %if "%{_rpmversion}" >= "5" |
d1b96fd8 | 136 | BuildArch: noarch |
b19b9d51 | 137 | %endif |
e361528e ER |
138 | |
139 | %description doc | |
140 | This package includes HTML documentation for the Rust programming | |
141 | language and its standard library. | |
142 | ||
143 | %prep | |
144 | %setup -q -n %{rustc_package} | |
b5eceb5e JR |
145 | %patch0 -p1 |
146 | ||
e361528e ER |
147 | %if %{with bootstrap} |
148 | %ifarch %{x8664} | |
149 | tar xf %{SOURCE1} | |
150 | %endif | |
151 | %ifarch %{ix86} | |
152 | tar xf %{SOURCE2} | |
153 | %endif | |
d6d4cb2b JR |
154 | %{__mv} %{bootstrap_root} %{bootstrap_root}-root |
155 | %{bootstrap_root}-root/install.sh \ | |
156 | --components=cargo,rustc,rust-std-%{rust_triple} \ | |
157 | --prefix=%{local_rust_root} \ | |
158 | --disable-ldconfig | |
159 | test -f %{local_rust_root}/bin/cargo | |
e361528e ER |
160 | test -f %{local_rust_root}/bin/rustc |
161 | %endif | |
162 | ||
163 | # unbundle | |
164 | rm -r src/jemalloc/ | |
165 | rm -r src/llvm/ | |
166 | ||
167 | # extract bundled licenses for packaging | |
168 | cp -p src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown | |
169 | sed -e '/*\//q' src/libbacktrace/backtrace.h \ | |
170 | >src/libbacktrace/LICENSE-libbacktrace | |
171 | ||
172 | # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch | |
173 | sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \ | |
174 | src/etc/rust-gdb | |
175 | ||
176 | # These tests assume that alloc_jemalloc is present | |
177 | sed -i -e '1i // ignore-test jemalloc is disabled' \ | |
178 | src/test/compile-fail/allocator-dylib-is-system.rs \ | |
179 | src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs \ | |
180 | src/test/run-pass/allocator-default.rs | |
181 | ||
e361528e ER |
182 | %build |
183 | %configure \ | |
18a1004b | 184 | --libdir=%{common_libdir} \ |
e361528e ER |
185 | --disable-option-checking \ |
186 | --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \ | |
187 | --enable-local-rust --local-rust-root=%{local_rust_root} \ | |
188 | --llvm-root=%{_prefix} --disable-codegen-tests \ | |
b5eceb5e | 189 | --enable-llvm-link-shared \ |
e361528e ER |
190 | --disable-jemalloc \ |
191 | --disable-rpath \ | |
192 | --enable-debuginfo \ | |
d6d4cb2b | 193 | --enable-vendor \ |
e361528e ER |
194 | --release-channel=%{channel} |
195 | ||
d6d4cb2b | 196 | ./x.py dist |
e361528e | 197 | |
8a073211 JR |
198 | %{?with_tests:./x.py test} |
199 | ||
e361528e ER |
200 | %install |
201 | rm -rf $RPM_BUILD_ROOT | |
e361528e | 202 | |
d1b96fd8 | 203 | DESTDIR=$RPM_BUILD_ROOT ./x.py dist --install |
e361528e | 204 | |
18a1004b JR |
205 | # Make sure the shared libraries are in the proper libdir |
206 | %if "%{_libdir}" != "%{common_libdir}" | |
207 | mkdir -p %{buildroot}%{_libdir} | |
208 | find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \ | |
209 | -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+' | |
210 | %endif | |
211 | ||
d1b96fd8 | 212 | # The shared libraries should be executable for debuginfo extraction. |
e361528e ER |
213 | find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+' |
214 | ||
d1b96fd8 JR |
215 | # The libdir libraries are identical to those under rustlib/. It's easier on |
216 | # library loading if we keep them in libdir, but we do need them in rustlib/ | |
217 | # to support dynamic linking for compiler plugins, so we'll symlink. | |
18a1004b | 218 | (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" && |
d1b96fd8 JR |
219 | find ../../../../%{_lib} -maxdepth 1 -name '*.so' \ |
220 | -exec ln -v -f -s -t . '{}' '+') | |
221 | ||
222 | # Remove installer artifacts (manifests, uninstall scripts, etc.) | |
18a1004b | 223 | find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+' |
e361528e ER |
224 | |
225 | # FIXME: __os_install_post will strip the rlibs | |
226 | # -- should we find a way to preserve debuginfo? | |
227 | ||
228 | # Remove unwanted documentation files (we already package them) | |
229 | rm $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md | |
230 | rm $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT | |
231 | rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE | |
232 | rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT | |
233 | ||
234 | # Sanitize the HTML documentation | |
235 | find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete | |
236 | find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+' | |
237 | ||
238 | # Move rust-gdb's python scripts so they're noarch | |
239 | install -d $RPM_BUILD_ROOT%{_datadir}/%{name} | |
18a1004b | 240 | mv -v $RPM_BUILD_ROOT%{rustlibdir}/%{_sysconfdir} $RPM_BUILD_ROOT%{_datadir}/%{name}/ |
e361528e ER |
241 | |
242 | %clean | |
243 | rm -rf $RPM_BUILD_ROOT | |
244 | ||
245 | %post -p /sbin/ldconfig | |
246 | %postun -p /sbin/ldconfig | |
247 | ||
248 | %files | |
249 | %defattr(644,root,root,755) | |
250 | %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT | |
251 | %doc src/libbacktrace/LICENSE-libbacktrace | |
252 | %doc src/rt/hoedown/LICENSE-hoedown | |
253 | %doc README.md | |
254 | %attr(755,root,root) %{_bindir}/rustc | |
255 | %attr(755,root,root) %{_bindir}/rustdoc | |
18a1004b | 256 | %attr(755,root,root) %{_libdir}/lib*.so |
e361528e ER |
257 | %{_mandir}/man1/rustc.1* |
258 | %{_mandir}/man1/rustdoc.1* | |
18a1004b JR |
259 | %dir %{rustlibdir} |
260 | %dir %{rustlibdir}/%{rust_triple} | |
261 | %dir %{rustlibdir}/%{rust_triple}/lib | |
262 | %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so | |
263 | %{rustlibdir}/%{rust_triple}/lib/*.rlib | |
e361528e | 264 | |
d1b96fd8 JR |
265 | %files debugger-common |
266 | %defattr(644,root,root,755) | |
267 | %dir %{_datadir}/%{name} | |
268 | %dir %{_datadir}/%{name}/etc | |
269 | %{_datadir}/%{name}/etc/debugger_*.py* | |
270 | ||
271 | %files lldb | |
272 | %defattr(644,root,root,755) | |
273 | %attr(755,root,root) %{_bindir}/rust-lldb | |
274 | %{_datadir}/%{name}/etc/lldb_*.py* | |
275 | ||
e361528e ER |
276 | %files gdb |
277 | %defattr(644,root,root,755) | |
278 | %attr(755,root,root) %{_bindir}/rust-gdb | |
d1b96fd8 | 279 | %{_datadir}/%{name}/etc/gdb_*.py* |
e361528e ER |
280 | |
281 | %files doc | |
282 | %defattr(644,root,root,755) | |
283 | %dir %{_docdir}/%{name} | |
d1b96fd8 | 284 | %doc %{_docdir}/%{name}/html |