]> git.pld-linux.org Git - packages/rust.git/blob - rust.spec
- BRs compiler host curl-devel libgit2-devel
[packages/rust.git] / rust.spec
1 # TODO
2 # - consider a rust-std package containing .../rustlib/$target
3 #   This might allow multilib cross-compilation to work naturally.
4 # - package additional tools
5 #
6 # Conditional build:
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
11
12 # The channel can be stable, beta, or nightly
13 %define         channel         stable
14
15 %if "%{channel}" == "stable"
16 %define         rustc_package   rustc-%{version}-src
17 %else
18 %define         rustc_package   rustc-%{channel}-src
19 %endif
20
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.43.1
25 %define         bootstrap_cargo 1.43.1
26 %define         bootstrap_date  2020-05-07
27
28 %ifarch x32
29 %define         with_cross      1
30 %endif
31 Summary:        The Rust Programming Language
32 Summary(pl.UTF-8):      Język programowania Rust
33 Name:           rust
34 Version:        1.44.1
35 Release:        1
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:  0cc3b079ddb1eb9a17f9e7e52efcebc5
41 Source1:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
42 # Source1-md5:  62b0974a4bad5aeabd50c7a7fa74518c
43 Source2:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
44 # Source2-md5:  758d55172c8dddb1ec71913b5f532bb2
45 Source3:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-std-%{bootstrap_rust}-x86_64-unknown-linux-gnux32.tar.xz
46 # Source3-md5:  4b07c6922a0965791cf8eb28fee9e89d
47 Source4:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
48 # Source4-md5:  3a9d54ab96f96664b2f6077cccb4e70b
49 Patch0:         %{name}-no-miri.patch
50 Patch1:         %{name}-x32.patch
51 URL:            https://www.rust-lang.org/
52 # for src/compiler-rt
53 BuildRequires:  cmake >= 3.4.3
54 BuildRequires:  curl
55 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
56 BuildRequires:  procps
57 BuildRequires:  python >= 1:2.7
58 BuildRequires:  rpmbuild(macros) >= 1.752
59 %if %{without cross}
60 BuildRequires:  curl-devel
61 BuildRequires:  libgit2-devel
62 BuildRequires:  libstdc++-devel
63 %{?with_system_llvm:BuildRequires:      llvm-devel >= 7.0}
64 BuildRequires:  openssl-devel >= 1.0.1
65 BuildRequires:  zlib-devel
66 %endif
67 %if %{without bootstrap}
68 BuildRequires:  %{name} >= %{bootstrap_rust}
69 BuildRequires:  cargo >= %{bootstrap_cargo}
70 BuildConflicts: %{name} > %{version}
71 %endif
72 %ifarch x32
73 BuildRequires:  glibc-devel(x32)
74 BuildRequires:  glibc-devel(x86_64)
75 %if "%{_host_cpu}" == "x86_64"
76 # building on x86_64 host with --target x32-pld-linux
77 BuildRequires:  curl-devel
78 BuildRequires:  gcc-multilib-x32
79 BuildRequires:  libgit2-devel
80 BuildRequires:  libstdc++-devel
81 %{?with_system_llvm:BuildRequires:      llvm-devel >= 7.0}
82 BuildRequires:  openssl-devel >= 1.0.1
83 BuildRequires:  zlib-devel
84 %else
85 # building x86_64-hosted crosscompiler on x32 host
86 BuildRequires:  gcc-multilib-64
87 BuildRequires:  libstdc++-multilib-64-devel
88 # how to specify?
89 #BuildRequires: curl-devel.x86_64
90 #BuildRequires: libgit2-devel.x86_64
91 #BuildRequires: llvm-devel.x86_64 >= 7.0
92 #BuildRequires: openssl-devel.x86_64
93 #BuildRequires: zlib-devel.x86_64
94 %endif
95 %endif
96 # The C compiler is needed at runtime just for linking.  Someday rustc might
97 # invoke the linker directly, and then we'll only need binutils.
98 # https://github.com/rust-lang/rust/issues/11937
99 Requires:       gcc
100 # Only x86_64 and i686 are Tier 1 platforms at this time.
101 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
102 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
103 ExclusiveArch:  %{x8664} %{ix86} x32 aarch64
104 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
105
106 %ifarch x32
107 %define         rust_triple             x86_64-unknown-linux-gnux32
108 %define         rust_host_triple        x86_64-unknown-linux-gnu
109 %define         rust_bootstrap_triple   x86_64-unknown-linux-gnu
110 %else
111 %define         rust_triple             %{_target_cpu}-unknown-linux-gnu
112 %define         rust_host_triple        %{rust_triple}
113 %define         rust_bootstrap_triple   %{rust_triple}
114 %endif
115
116 %if %{without bootstrap}
117 %define         local_rust_root %{_prefix}
118 %else
119 %define         bootstrap_root  rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
120 %define         local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
121 %endif
122
123 # We're going to override --libdir when configuring to get rustlib into a
124 # common path, but we'll fix the shared libraries during install.
125 # Without this ugly hack, rust would not be able to build itself
126 # for non-bootstrap build, lib64 is just too complicated for it.
127 %define         common_libdir   %{_prefix}/lib
128 %define         rustlibdir      %{common_libdir}/rustlib
129
130 # once_call/once_callable non-function libstdc++ symbols
131 %define         skip_post_check_so      'librustc.*llvm.*\.so.*'
132
133 # ALL Rust libraries are private, because they don't keep an ABI.
134 %define         _noautoreqfiles         lib.*-[[:xdigit:]]{8}[.]so.*
135 %define         _noautoprovfiles        lib.*-[[:xdigit:]]{8}[.]so.*
136
137 %define         x_py { \
138         x_py() { \
139                 local cmd="$1"; \
140                 shift; \
141                 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
142         }; x_py }
143
144
145 %description
146 Rust is a systems programming language that runs blazingly fast,
147 prevents segfaults, and guarantees thread safety.
148
149 This package includes the Rust compiler, standard library, and
150 documentation generator.
151
152 %description -l pl.UTF-8
153 Rust to systemowy język programowania działający bardzo szybko,
154 zapobiegający naruszeniom ochrony pamięci i gwarantujący
155 bezpieczną wielowątkowość.
156
157 %package debugger-common
158 Summary:        Common debugger pretty printers for Rust
159 Summary(pl.UTF-8):      Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
160 Group:          Development/Debuggers
161 %{?noarchpackage}
162
163 %description debugger-common
164 This package includes the common functionality for rust-gdb and
165 rust-lldb.
166
167 %description debugger-common -l pl.UTF-8
168 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
169
170 %package gdb
171 Summary:        GDB pretty printers for Rust
172 Summary(pl.UTF-8):      Ładne wypisywanie struktur Rusta w GDB
173 Group:          Development/Debuggers
174 Requires:       %{name}-debugger-common = %{version}-%{release}
175 Requires:       gdb
176 %{?noarchpackage}
177
178 %description gdb
179 This package includes the rust-gdb script, which allows easier
180 debugging of Rust programs.
181
182 %description gdb -l pl.UTF-8
183 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
184 odpluskwianie programów w języku Rust.
185
186 %package lldb
187 Summary:        LLDB pretty printers for Rust
188 Summary(pl.UTF-8):      Ładne wypisywanie struktur Rusta w LLDB
189 Group:          Development/Debuggers
190 Requires:       %{name}-debugger-common = %{version}-%{release}
191 Requires:       lldb
192 %{?noarchpackage}
193
194 %description lldb
195 This package includes the rust-lldb script, which allows easier
196 debugging of Rust programs.
197
198 %description lldb -l pl.UTF-8
199 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
200 odpluskwianie programów w języku Rust.
201
202 %package doc
203 Summary:        Documentation for Rust
204 Summary(pl.UTF-8):      Dokumentacja do Rusta
205 Group:          Documentation
206 %{?noarchpackage}
207
208 %description doc
209 This package includes HTML documentation for the Rust programming
210 language and its standard library.
211
212 %description doc -l pl.UTF-8
213 Ten pakiet zawiera dokumentację w formacie HTML do języka
214 programowania Rust i jego biblioteki standardowej.
215
216 %package -n cargo
217 Summary:        Rust's package manager and build tool
218 Summary(pl.UTF-8):      Zarządca pakietów i narzędzie do budowania
219 Group:          Development/Tools
220 Requires:       %{name}
221
222 %description -n cargo
223 Cargo is a tool that allows Rust projects to declare their various
224 dependencies and ensure that you'll always get a repeatable build.
225
226 %description -n cargo -l pl.UTF-8
227 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
228 zależności i zapewniające powtarzalność procesu budowania.
229
230 %package -n bash-completion-cargo
231 Summary:        Bash completion for cargo command
232 Summary(pl.UTF-8):      Bashowe dopełnianie parametrów polecenia cargo
233 Group:          Applications/Shells
234 Requires:       %{name} = %{version}-%{release}
235 Requires:       bash-completion
236
237 %description -n bash-completion-cargo
238 Bash completion for cargo command.
239
240 %description -n bash-completion-cargo -l pl.UTF-8
241 Bashowe dopełnianie parametrów polecenia cargo.
242
243 %package -n zsh-completion-cargo
244 Summary:        Zsh completion for cargo command
245 Summary(pl.UTF-8):      Dopełnianie parametrów polecenia cargo w powłoce Zsh
246 Group:          Applications/Shells
247 Requires:       %{name} = %{version}-%{release}
248 Requires:       zsh
249
250 %description -n zsh-completion-cargo
251 Zsh completion for cargo command.
252
253 %description -n zsh-completion-cargo -l pl.UTF-8
254 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
255
256 %prep
257 %setup -q -n %{rustc_package}
258 %patch0 -p1
259 # irrelevant when not building rustc for x32
260 #patch1 -p1
261
262 %if %{with bootstrap}
263 %ifarch %{x8664} x32
264 tar xf %{SOURCE1}
265 %endif
266 %ifarch %{ix86}
267 tar xf %{SOURCE2}
268 %endif
269 %ifarch x32
270 cd %{bootstrap_root}
271 tar xf %{SOURCE3}
272 %{__mv} rust-std-%{bootstrap_rust}-%{rust_triple} rust-std-%{rust_triple}
273 cd ..
274 %endif
275 %ifarch aarch64
276 tar xf %{SOURCE4}
277 %endif
278 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
279 %{bootstrap_root}-root/install.sh \
280         --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
281         --prefix=%{local_rust_root} \
282         --disable-ldconfig
283 test -f %{local_rust_root}/bin/cargo
284 test -f %{local_rust_root}/bin/rustc
285 %ifarch x32
286 %{bootstrap_root}-root/rust-std-%{rust_triple}/install.sh \
287         --components=rust-std-%{rust_triple} \
288         --prefix=%{local_rust_root} \
289         --disable-ldconfig
290 %endif
291 %endif
292
293 # unbundle
294 # We're disabling jemalloc, but rust-src still wants it.
295 #%{__rm} -r src/jemalloc
296 %{?with_system_llvm:%{__rm} -r src/llvm-project}
297
298 # extract bundled licenses for packaging
299 sed -e '/*\//q' vendor/backtrace-sys/src/libbacktrace/backtrace.h \
300         >vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
301
302 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
303 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
304         src/etc/rust-gdb
305
306 # The configure macro will modify some autoconf-related files, which upsets
307 # cargo when it tries to verify checksums in those files.  If we just truncate
308 # that file list, cargo won't have anything to complain about.
309 find vendor -name .cargo-checksum.json \
310         -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
311
312 %build
313 %configure \
314         --build=%{rust_bootstrap_triple} \
315         --host=%{rust_host_triple} \
316         --target=%{rust_triple} \
317         --libdir=%{common_libdir} \
318         --disable-codegen-tests \
319         --disable-debuginfo-lines \
320 %if %{with full_debuginfo}
321         --disable-debuginfo-only-std \
322         --enable-debuginfo \
323 %else
324         --enable-debuginfo-only-std \
325         --disable-debuginfo \
326 %endif
327         --disable-jemalloc \
328         --disable-option-checking \
329         --disable-rpath \
330         --enable-extended \
331         --enable-llvm-link-shared \
332         --enable-vendor \
333         --local-rust-root=%{local_rust_root} \
334         --llvm-root=%{_prefix} \
335         --release-channel=%{channel}
336
337 export RUST_BACKTRACE=full
338 %x_py dist --verbose
339
340 %{?with_tests:%x_py test}
341
342 %install
343 rm -rf $RPM_BUILD_ROOT
344
345 export DESTDIR=$RPM_BUILD_ROOT
346 %x_py install
347 %x_py install src
348
349 # Make sure the shared libraries are in the proper libdir
350 %if "%{_libdir}" != "%{common_libdir}"
351 mkdir -p %{buildroot}%{_libdir}
352 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
353         -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
354 %endif
355
356 # The shared libraries should be executable for debuginfo extraction.
357 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
358
359 # The libdir libraries are identical to those under rustlib/.  It's easier on
360 # library loading if we keep them in libdir, but we do need them in rustlib/
361 # to support dynamic linking for compiler plugins, so we'll symlink.
362 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
363         find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
364         -exec ln -v -f -s -t . '{}' '+')
365
366 # Remove installer artifacts (manifests, uninstall scripts, etc.)
367 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
368
369 # FIXME: __os_install_post will strip the rlibs
370 # -- should we find a way to preserve debuginfo?
371
372 # Remove unwanted documentation files (we already package them)
373 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
374 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
375 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
376 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
377
378 # Sanitize the HTML documentation
379 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
380 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
381
382 # Move rust-gdb's python scripts so they're noarch
383 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
384 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
385
386 # We don't need stdlib source
387 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
388
389 # Create the path for crate-devel packages
390 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
391
392 %clean
393 rm -rf $RPM_BUILD_ROOT
394
395 %post   -p /sbin/ldconfig
396 %postun -p /sbin/ldconfig
397
398 %files
399 %defattr(644,root,root,755)
400 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
401 %attr(755,root,root) %{_bindir}/rls
402 %attr(755,root,root) %{_bindir}/rustc
403 %attr(755,root,root) %{_bindir}/rustdoc
404 %attr(755,root,root) %{_bindir}/rustfmt
405 %attr(755,root,root) %{_libdir}/librustc*-*.so
406 %attr(755,root,root) %{_libdir}/libstd-*.so
407 %attr(755,root,root) %{_libdir}/libtest-*.so
408 %{_mandir}/man1/rustc.1*
409 %{_mandir}/man1/rustdoc.1*
410 %dir %{rustlibdir}
411 %dir %{rustlibdir}/%{rust_triple}
412 %{rustlibdir}/%{rust_triple}/analysis
413 %dir %{rustlibdir}/%{rust_triple}/lib
414 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
415 %{rustlibdir}/%{rust_triple}/lib/*.rlib
416
417 # for cross-compiler (e.g. x86_64-hosted x32 rust)
418 %if "%{rust_host_triple}" != "%{rust_triple}"
419 %dir %{rustlibdir}/%{rust_host_triple}
420 %{rustlibdir}/%{rust_host_triple}/analysis
421 %dir %{rustlibdir}/%{rust_host_triple}/lib
422 %attr(755,root,root) %{rustlibdir}/%{rust_host_triple}/lib/*.so
423 %{rustlibdir}/%{rust_host_triple}/lib/*.rlib
424 %endif
425
426 %files debugger-common
427 %defattr(644,root,root,755)
428 %dir %{_datadir}/%{name}
429 %dir %{_datadir}/%{name}/etc
430 %{_datadir}/%{name}/etc/debugger_*.py*
431
432 %files lldb
433 %defattr(644,root,root,755)
434 %attr(755,root,root) %{_bindir}/rust-lldb
435 %{_datadir}/%{name}/etc/lldb_*.py*
436
437 %files gdb
438 %defattr(644,root,root,755)
439 %attr(755,root,root) %{_bindir}/rust-gdb
440 %attr(755,root,root) %{_bindir}/rust-gdbgui
441 %{_datadir}/%{name}/etc/gdb_*.py*
442
443 %files doc
444 %defattr(644,root,root,755)
445 %dir %{_docdir}/%{name}
446 %doc %{_docdir}/%{name}/html
447
448 %files -n cargo
449 %defattr(644,root,root,755)
450 %attr(755,root,root) %{_bindir}/cargo
451 %attr(755,root,root) %{_bindir}/cargo-clippy
452 %attr(755,root,root) %{_bindir}/cargo-fmt
453 %attr(755,root,root) %{_bindir}/clippy-driver
454 %{_mandir}/man1/cargo*.1*
455 %dir %{_datadir}/cargo
456 %dir %{_datadir}/cargo/registry
457
458 %files -n bash-completion-cargo
459 %defattr(644,root,root,755)
460 %{_sysconfdir}/bash_completion.d/cargo
461
462 %files -n zsh-completion-cargo
463 %defattr(644,root,root,755)
464 %{zsh_compdir}/_cargo
This page took 0.094885 seconds and 4 git commands to generate.