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