/[packages]/cauldron/rust/current/SPECS/rust.spec
ViewVC logotype

Contents of /cauldron/rust/current/SPECS/rust.spec

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1891744 - (show annotations) (download)
Fri Sep 23 08:39:59 2022 UTC (18 months ago) by akien
File size: 34960 byte(s)
- Sync with Fedora: Thu Sep 22 2022 Josh Stone <jistone@redhat.com> - 1.64.0-1
  o Update to 1.64.0.
  o Add rust-analyzer.

1 # (akien) This package is synced with Fedora / Josh Stone's spec.
2 # The aim is to work with them on a rust packaging policy we could share,
3 # so that we can ensure a good packaging and share the workload.
4
5
6 # Only x86_64 and i686 are Tier 1 platforms at this time.
7 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
8 %global rust_arches x86_64 i686 armv7hl aarch64 ppc64le s390x
9
10 # The channel can be stable, beta, or nightly
11 %{!?channel: %global channel stable}
12
13 # To bootstrap from scratch, set the channel and date from src/stage0.json
14 # e.g. 1.59.0 wants rustc: 1.58.0-2022-01-13
15 # or nightly wants some beta-YYYY-MM-DD
16 %global bootstrap_version 1.63.0
17 %global bootstrap_channel 1.63.0
18 %global bootstrap_date 2022-08-11
19
20 # Only the specified arches will use bootstrap binaries.
21 # NOTE: Those binaries used to be uploaded with every new release, but that was
22 # a waste of lookaside cache space when they're most often unused.
23 # Run "spectool -g rust.spec" after changing this and then "fedpkg upload" to
24 # add them to sources. Remember to remove them again after the bootstrap build!
25 #global bootstrap_arches %%{rust_arches}
26
27 # To bootstrap a compiler for a Tier 2 platform, we first need to build a
28 # compiler for a Tier 1 platform that targets the Tier 2 platform, then use
29 # the resulting compiler in a second build. Set bootstrap_build_arch to the
30 # Tier 1 arch for the first build, leave it undefined for the second build.
31 %bcond_with bootstrap_i586
32 %if %with bootstrap_i586
33 %ifarch i586
34 %global bootstrap_build_arch i686
35 %endif
36 %endif
37
38 # Define a space-separated list of targets to ship rust-std-static-$triple for
39 # cross-compilation. The packages are noarch, but they're not fully
40 # reproducible between hosts, so only x86_64 actually builds it.
41 %ifarch x86_64
42 %if 0%{?fedora} || 0%{?mageia} >= 9
43 %global mingw_targets i686-pc-windows-gnu x86_64-pc-windows-gnu
44 %endif
45 %if 0%{?fedora} || 0%{?rhel} >= 8 || 0%{?mageia} >= 9
46 %global wasm_targets wasm32-unknown-unknown wasm32-wasi
47 %endif
48 %endif
49
50 # We need CRT files for *-wasi targets, at least as new as the commit in
51 # src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh
52 # (updated per https://github.com/rust-lang/rust/pull/96907)
53 %global wasi_libc_url https://github.com/WebAssembly/wasi-libc
54 %global wasi_libc_commit 9886d3d6200fcc3726329966860fc058707406cd
55 %global wasi_libc_name wasi-libc-%{wasi_libc_commit}
56 %global wasi_libc_source %{wasi_libc_url}/archive/%{wasi_libc_commit}/%{wasi_libc_name}.tar.gz
57 %global wasi_libc_dir %{_builddir}/%{wasi_libc_name}
58
59 # Using llvm-static may be helpful as an opt-in, e.g. to aid LLVM rebases.
60 %bcond_with llvm_static
61
62 # We can also choose to just use Rust's bundled LLVM, in case the system LLVM
63 # is insufficient. Rust currently requires LLVM 12.0+.
64 %global min_llvm_version 12.0.0
65 %global bundled_llvm_version 14.0.6
66 %bcond_with bundled_llvm
67 # (akien) Hacks below are needed on mga's buildsystem when we have to rebootstrap llvm.
68 ## Bundled LLVM has underlinking issues:
69 #%%global _disable_ld_no_undefined 1
70 #%%ifarch %%{arm} %%ix86
71 ## Decrease debuginfo verbosity to reduce memory consumption during final library linking
72 #%%global optflags %%(echo %%{optflags} | sed 's/-g /-g1 /')
73 #%%endif
74
75 # Requires stable libgit2 1.4, and not the next minor soname change.
76 # This needs to be consistent with the bindings in vendor/libgit2-sys.
77 %global min_libgit2_version 1.4.0
78 %global next_libgit2_version 1.5.0~
79 %global bundled_libgit2_version 1.4.2
80 %if 0%{?fedora} >= 99 || 0%{?mageia} >= 99
81 %bcond_with bundled_libgit2
82 %else
83 %bcond_without bundled_libgit2
84 %endif
85
86 # needs libssh2_userauth_publickey_frommemory
87 %global min_libssh2_version 1.6.0
88 %if 0%{?rhel}
89 # Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949)
90 %bcond_without disabled_libssh2
91 %else
92 %bcond_with disabled_libssh2
93 %endif
94
95 %if 0%{?rhel} && 0%{?rhel} < 8
96 %bcond_with curl_http2
97 %else
98 %bcond_without curl_http2
99 %endif
100
101 # LLDB isn't available everywhere...
102 %if 0%{?rhel} && 0%{?rhel} < 8
103 %bcond_with lldb
104 %else
105 %bcond_without lldb
106 %endif
107
108 %if 0%{?mageia}
109 # (akien) Added by tv in mga8/rust 1.37.0.
110 %global _python_bytecompile_extra 0
111 %endif
112
113 Name: rust
114 Version: 1.64.0
115 Release: %mkrel 1
116 Summary: The Rust Programming Language
117 %if 0%{?mageia}
118 Group: Development/Other
119 %endif
120 License: (ASL 2.0 or MIT) and (BSD and MIT)
121 # ^ written as: (rust itself) and (bundled libraries)
122 URL: https://www.rust-lang.org
123 ExclusiveArch: %{rust_arches} i586
124
125 %if "%{channel}" == "stable"
126 %global rustc_package rustc-%{version}-src
127 %else
128 %global rustc_package rustc-%{channel}-src
129 %endif
130 Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
131 Source1: %{wasi_libc_source}
132 # Sources for bootstrap_arches are inserted by lua below
133
134 # By default, rust tries to use "rust-lld" as a linker for WebAssembly.
135 Patch1: 0001-Use-lld-provided-by-system-for-wasm.patch
136
137 # Set a substitute-path in rust-gdb for standard library sources.
138 Patch2: rustc-1.61.0-rust-gdb-substitute-path.patch
139
140 # (akien) Those tests fail on armv7 - on Fedora too, and jistone ignores them
141 # https://github.com/rust-lang/rust/issues/83453
142 Patch11: rustc-1.50.0-allow_fail-armv7-instruction_set.patch
143
144 ### RHEL-specific patches below ###
145
146 # Simple rpm macros for rust-toolset (as opposed to full rust-packaging)
147 Source100: macros.rust-toolset
148
149 # Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949)
150 Patch100: rustc-1.59.0-disable-libssh2.patch
151
152 # libcurl on RHEL7 doesn't have http2, but since cargo requests it, curl-sys
153 # will try to build it statically -- instead we turn off the feature.
154 Patch101: rustc-1.63.0-disable-http2.patch
155
156 # kernel rh1410097 causes too-small stacks for PIE.
157 # (affects RHEL6 kernels when building for RHEL7)
158 Patch102: rustc-1.64.0-no-default-pie.patch
159
160
161 # Get the Rust triple for any arch.
162 %{lua: function rust_triple(arch)
163 local abi = "gnu"
164 if arch == "armv7hl" then
165 arch = "armv7"
166 abi = "gnueabihf"
167 elseif arch == "ppc64" then
168 arch = "powerpc64"
169 elseif arch == "ppc64le" then
170 arch = "powerpc64le"
171 elseif arch == "riscv64" then
172 arch = "riscv64gc"
173 end
174 return arch.."-unknown-linux-"..abi
175 end}
176
177 %if %defined bootstrap_build_arch
178 %global rust_triple %{lua: print(rust_triple(rpm.expand("%{bootstrap_build_arch}")))}
179 %global target_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))}
180 %else
181 %global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))}
182 %global target_triple %{rust_triple}
183 %endif
184
185 %if %defined bootstrap_arches
186 # For each bootstrap arch, add an additional binary Source.
187 # Also define bootstrap_source just for the current target.
188 %{lua: do
189 local bootstrap_arches = {}
190 for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do
191 table.insert(bootstrap_arches, arch)
192 end
193 local base = rpm.expand("https://static.rust-lang.org/dist/%{bootstrap_date}")
194 local channel = rpm.expand("%{bootstrap_channel}")
195 local target_arch = rpm.expand("%{_target_cpu}")
196 for i, arch in ipairs(bootstrap_arches) do
197 i = 1000 + i * 3
198 local suffix = channel.."-"..rust_triple(arch)
199 print(string.format("Source%d: %s/cargo-%s.tar.xz\n", i, base, suffix))
200 print(string.format("Source%d: %s/rustc-%s.tar.xz\n", i+1, base, suffix))
201 print(string.format("Source%d: %s/rust-std-%s.tar.xz\n", i+2, base, suffix))
202 if arch == target_arch then
203 rpm.define("bootstrap_source_cargo "..i)
204 rpm.define("bootstrap_source_rustc "..i+1)
205 rpm.define("bootstrap_source_std "..i+2)
206 rpm.define("bootstrap_suffix "..suffix)
207 end
208 end
209 end}
210 %endif
211
212 %ifarch %{bootstrap_arches}
213 %global local_rust_root %{_builddir}/rust-%{bootstrap_suffix}
214 Provides: bundled(%{name}-bootstrap) = %{bootstrap_version}
215 %else
216 BuildRequires: cargo >= %{bootstrap_version}
217 %if (0%{?rhel} && 0%{?rhel} < 8) || 0%{?mageia}
218 BuildRequires: %{name} >= %{bootstrap_version}
219 BuildConflicts: %{name} > %{version}
220 %else
221 BuildRequires: (%{name} >= %{bootstrap_version} with %{name} <= %{version})
222 %endif
223 %global local_rust_root %{_prefix}
224 %endif
225
226 BuildRequires: make
227 BuildRequires: gcc
228 BuildRequires: gcc-c++
229 BuildRequires: ncurses-devel
230 # explicit curl-devel to avoid httpd24-curl (rhbz1540167)
231 BuildRequires: curl-devel
232 BuildRequires: pkgconfig(libcurl)
233 BuildRequires: pkgconfig(liblzma)
234 BuildRequires: pkgconfig(openssl)
235 BuildRequires: pkgconfig(zlib)
236
237 %if %{without bundled_libgit2}
238 BuildRequires: pkgconfig(libgit2) >= %{min_libgit2_version}
239 BuildRequires: pkgconfig(libgit2) < %{next_libgit2_version}
240 %endif
241
242 %if %{without disabled_libssh2}
243 BuildRequires: pkgconfig(libssh2) >= %{min_libssh2_version}
244 %endif
245
246 %if 0%{?rhel} == 8
247 BuildRequires: platform-python
248 %else
249 BuildRequires: python3
250 %endif
251 BuildRequires: python3-rpm-macros
252
253 %if %with bundled_llvm
254 BuildRequires: cmake3 >= 3.13.4
255 BuildRequires: ninja-build
256 Provides: bundled(llvm) = %{bundled_llvm_version}
257 %else
258 BuildRequires: cmake >= 2.8.11
259 %if 0%{?epel} == 7
260 %global llvm llvm13
261 %endif
262 %if %defined llvm
263 %if 0%{?mageia}
264 %global llvm_root %{_prefix}/lib/%{llvm}
265 %else
266 %global llvm_root %{_libdir}/%{llvm}
267 %endif
268 %else
269 %global llvm llvm
270 %global llvm_root %{_prefix}
271 %endif
272 BuildRequires: %{llvm}-devel >= %{min_llvm_version}
273 %if %with llvm_static
274 BuildRequires: %{llvm}-static
275 BuildRequires: libffi-devel
276 %endif
277 %endif
278
279 # make check needs "ps" for src/test/ui/wait-forked-but-failed-child.rs
280 BuildRequires: procps-ng
281
282 # debuginfo-gdb tests need gdb
283 BuildRequires: gdb
284
285 # For src/test/run-make/static-pie
286 %if 0%{?mageia}
287 BuildRequires: glibc-static-devel
288 %else
289 BuildRequires: glibc-static
290 %endif
291
292 # Virtual provides for folks who attempt "dnf install rustc"
293 Provides: rustc = %{version}-%{release}
294 Provides: rustc%{?_isa} = %{version}-%{release}
295
296 # Always require our exact standard library
297 Requires: %{name}-std-static%{?_isa} = %{version}-%{release}
298
299 # The C compiler is needed at runtime just for linking. Someday rustc might
300 # invoke the linker directly, and then we'll only need binutils.
301 # https://github.com/rust-lang/rust/issues/11937
302 %if 0%{?mageia}
303 Requires: gcc
304 %else
305 Requires: /usr/bin/cc
306 %endif
307
308 %if 0%{?epel} == 7
309 %global devtoolset_name devtoolset-9
310 BuildRequires: %{devtoolset_name}-binutils
311 BuildRequires: %{devtoolset_name}-gcc
312 BuildRequires: %{devtoolset_name}-gcc-c++
313 %global devtoolset_bindir /opt/rh/%{devtoolset_name}/root/usr/bin
314 %global __cc %{devtoolset_bindir}/gcc
315 %global __cxx %{devtoolset_bindir}/g++
316 %global __ar %{devtoolset_bindir}/ar
317 %global __ranlib %{devtoolset_bindir}/ranlib
318 %global __strip %{devtoolset_bindir}/strip
319 %else
320 %global __ranlib %{_bindir}/ranlib
321 %endif
322
323 # ALL Rust libraries are private, because they don't keep an ABI.
324 %global _privatelibs lib(.*-[[:xdigit:]]{16}*|rustc.*)[.]so.*
325 %global __provides_exclude ^(%{_privatelibs})$
326 %global __requires_exclude ^(%{_privatelibs})$
327 %global __provides_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$
328 %global __requires_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$
329
330 # While we don't want to encourage dynamic linking to Rust shared libraries, as
331 # there's no stable ABI, we still need the unallocated metadata (.rustc) to
332 # support custom-derive plugins like #[proc_macro_derive(Foo)].
333 %if 0%{?rhel} && 0%{?rhel} < 8
334 # eu-strip is very eager by default, so we have to limit it to -g, only debugging symbols.
335 %global _find_debuginfo_opts -g
336 %undefine _include_minidebuginfo
337 %else
338 # Newer find-debuginfo.sh supports --keep-section, which is preferable. rhbz1465997
339 %global _find_debuginfo_opts --keep-section .rustc
340 %endif
341
342 %if %{without bundled_llvm}
343 %if "%{llvm_root}" == "%{_prefix}" || 0%{?scl:1}
344 %global llvm_has_filecheck 1
345 %endif
346 %endif
347
348 # We're going to override --libdir when configuring to get rustlib into a
349 # common path, but we'll fix the shared libraries during install.
350 %global common_libdir %{_prefix}/lib
351 %global rustlibdir %{common_libdir}/rustlib
352
353 %if %defined mingw_targets
354 BuildRequires: mingw32-filesystem >= 95
355 BuildRequires: mingw64-filesystem >= 95
356 BuildRequires: mingw32-crt
357 BuildRequires: mingw64-crt
358 BuildRequires: mingw32-gcc
359 BuildRequires: mingw64-gcc
360 BuildRequires: mingw32-winpthreads-static
361 BuildRequires: mingw64-winpthreads-static
362 %endif
363
364 %if %defined wasm_targets
365 BuildRequires: clang
366 BuildRequires: lld
367 # brp-strip-static-archive breaks the archive index for wasm
368 %global __os_install_post \
369 %__os_install_post \
370 find '%{buildroot}%{rustlibdir}'/wasm*/lib -type f -regex '.*\\.\\(a\\|rlib\\)' -print -exec '%{llvm_root}/bin/llvm-ranlib' '{}' ';' \
371 %{nil}
372 %endif
373
374 %description
375 Rust is a systems programming language that runs blazingly fast, prevents
376 segfaults, and guarantees thread safety.
377
378 This package includes the Rust compiler and documentation generator.
379
380
381 %package std-static
382 Summary: Standard library for Rust
383 Requires: %{name} = %{version}-%{release}
384 Requires: glibc-devel%{?_isa} >= 2.11
385
386 %description std-static
387 This package includes the standard libraries for building applications
388 written in Rust.
389
390 %if %defined mingw_targets
391 %{lua: do
392 for triple in string.gmatch(rpm.expand("%{mingw_targets}"), "%S+") do
393 local subs = {
394 triple = triple,
395 name = rpm.expand("%{name}"),
396 verrel = rpm.expand("%{version}-%{release}"),
397 mingw = string.find(rpm.expand("%{ix86}"), string.sub(triple, 1, 4)) and "mingw32" or "mingw64",
398 }
399 local s = string.gsub([[
400
401 %package std-static-{{triple}}
402 Summary: Standard library for Rust {{triple}}
403 BuildArch: noarch
404 Provides: {{mingw}}-rust = {{verrel}}
405 Provides: {{mingw}}-rustc = {{verrel}}
406 Requires: {{mingw}}-crt
407 Requires: {{mingw}}-gcc
408 Requires: {{mingw}}-winpthreads-static
409 Requires: {{name}} = {{verrel}}
410
411 %description std-static-{{triple}}
412 This package includes the standard libraries for building applications
413 written in Rust for the MinGW target {{triple}}.
414
415 ]], "{{(%w+)}}", subs)
416 print(s)
417 end
418 end}
419 %endif
420
421 %if %defined wasm_targets
422 %{lua: do
423 for triple in string.gmatch(rpm.expand("%{wasm_targets}"), "%S+") do
424 local subs = {
425 triple = triple,
426 name = rpm.expand("%{name}"),
427 verrel = rpm.expand("%{version}-%{release}"),
428 wasi = string.find(triple, "-wasi") and 1 or 0,
429 }
430 local s = string.gsub([[
431
432 %package std-static-{{triple}}
433 Summary: Standard library for Rust {{triple}}
434 BuildArch: noarch
435 Requires: {{name}} = {{verrel}}
436 Requires: lld >= 8.0
437 %if {{wasi}}
438 Provides: bundled(wasi-libc)
439 %endif
440
441 %description std-static-{{triple}}
442 This package includes the standard libraries for building applications
443 written in Rust for the WebAssembly target {{triple}}.
444
445 ]], "{{(%w+)}}", subs)
446 print(s)
447 end
448 end}
449 %endif
450
451
452 %package debugger-common
453 Summary: Common debugger pretty printers for Rust
454 BuildArch: noarch
455
456 %description debugger-common
457 This package includes the common functionality for %{name}-gdb and %{name}-lldb.
458
459
460 %package gdb
461 Summary: GDB pretty printers for Rust
462 BuildArch: noarch
463 Requires: gdb
464 Requires: %{name}-debugger-common = %{version}-%{release}
465
466 %description gdb
467 This package includes the rust-gdb script, which allows easier debugging of Rust
468 programs.
469
470
471 %if %with lldb
472
473 %package lldb
474 Summary: LLDB pretty printers for Rust
475 BuildArch: noarch
476 Requires: lldb
477 Requires: python3-lldb
478 Requires: %{name}-debugger-common = %{version}-%{release}
479
480 %description lldb
481 This package includes the rust-lldb script, which allows easier debugging of Rust
482 programs.
483
484 %endif
485
486
487 %package doc
488 Summary: Documentation for Rust
489 # NOT BuildArch: noarch
490 # Note, while docs are mostly noarch, some things do vary by target_arch.
491 # Koji will fail the build in rpmdiff if two architectures build a noarch
492 # subpackage differently, so instead we have to keep its arch.
493
494 %description doc
495 This package includes HTML documentation for the Rust programming language and
496 its standard library.
497
498
499 %package -n cargo
500 Summary: Rust's package manager and build tool
501 %if %with bundled_libgit2
502 Provides: bundled(libgit2) = %{bundled_libgit2_version}
503 %endif
504 # For tests:
505 BuildRequires: git-core
506 # Cargo is not much use without Rust
507 Requires: %{name}
508
509 # "cargo vendor" is a builtin command starting with 1.37. The Obsoletes and
510 # Provides are mostly relevant to RHEL, but harmless to have on Fedora/etc. too
511 Obsoletes: cargo-vendor <= 0.1.23
512 Provides: cargo-vendor = %{version}-%{release}
513
514 %description -n cargo
515 Cargo is a tool that allows Rust projects to declare their various dependencies
516 and ensure that you'll always get a repeatable build.
517
518
519 %package -n cargo-doc
520 Summary: Documentation for Cargo
521 BuildArch: noarch
522 # Cargo no longer builds its own documentation
523 # https://github.com/rust-lang/cargo/pull/4904
524 Requires: %{name}-doc = %{version}-%{release}
525
526 %description -n cargo-doc
527 This package includes HTML documentation for Cargo.
528
529
530 %package -n rustfmt
531 Summary: Tool to find and fix Rust formatting issues
532 Requires: cargo
533
534 # The component/package was rustfmt-preview until Rust 1.31.
535 Obsoletes: rustfmt-preview < 1.0.0
536 Provides: rustfmt-preview = %{version}-%{release}
537
538 %description -n rustfmt
539 A tool for formatting Rust code according to style guidelines.
540
541
542 %package -n rls
543 Summary: Rust Language Server for IDE integration (deprecated)
544 %if %with bundled_libgit2
545 Provides: bundled(libgit2) = %{bundled_libgit2_version}
546 %endif
547 Requires: %{name}-analysis
548 # /usr/bin/rls is dynamically linked against internal rustc libs
549 Requires: %{name}%{?_isa} = %{version}-%{release}
550
551 # The component/package was rls-preview until Rust 1.31.
552 Obsoletes: rls-preview < 1.31.6
553 Provides: rls-preview = %{version}-%{release}
554
555 %description -n rls
556 The Rust Language Server provides a server that runs in the background,
557 providing IDEs, editors, and other tools with information about Rust programs.
558 RLS is being deprecated in favor of rust-analyzer, and may be removed in the future.
559 https://blog.rust-lang.org/2022/07/01/RLS-deprecation.html
560
561
562 %package analyzer
563 Summary: Rust implementation of the Language Server Protocol
564
565 %description analyzer
566 rust-analyzer is an implementation of Language Server Protocol for the Rust
567 programming language. It provides features like completion and goto definition
568 for many code editors, including VS Code, Emacs and Vim.
569
570
571 %package -n clippy
572 Summary: Lints to catch common mistakes and improve your Rust code
573 Requires: cargo
574 # /usr/bin/clippy-driver is dynamically linked against internal rustc libs
575 Requires: %{name}%{?_isa} = %{version}-%{release}
576
577 # The component/package was clippy-preview until Rust 1.31.
578 Obsoletes: clippy-preview <= 0.0.212
579 Provides: clippy-preview = %{version}-%{release}
580
581 %description -n clippy
582 A collection of lints to catch common mistakes and improve your Rust code.
583
584
585 %package src
586 Summary: Sources for the Rust standard library
587 BuildArch: noarch
588
589 %description src
590 This package includes source files for the Rust standard library. It may be
591 useful as a reference for code completion tools in various editors.
592
593
594 %package analysis
595 Summary: Compiler analysis data for the Rust standard library
596 Requires: %{name}-std-static%{?_isa} = %{version}-%{release}
597
598 %description analysis
599 This package contains analysis data files produced with rustc's -Zsave-analysis
600 feature for the Rust standard library. The RLS (Rust Language Server) uses this
601 data to provide information about the Rust standard library.
602
603
604 %if 0%{?rhel} && 0%{?rhel} >= 8
605
606 %package toolset
607 Summary: Rust Toolset
608 Requires: rust%{?_isa} = %{version}-%{release}
609 Requires: cargo%{?_isa} = %{version}-%{release}
610
611 %description toolset
612 This is the metapackage for Rust Toolset, bringing in the Rust compiler,
613 the Cargo package manager, and a few convenience macros for rpm builds.
614
615 %endif
616
617
618 %prep
619
620 %ifarch %{bootstrap_arches}
621 rm -rf %{local_rust_root}
622 %setup -q -n cargo-%{bootstrap_suffix} -T -b %{bootstrap_source_cargo}
623 ./install.sh --prefix=%{local_rust_root} --disable-ldconfig
624 %setup -q -n rustc-%{bootstrap_suffix} -T -b %{bootstrap_source_rustc}
625 ./install.sh --prefix=%{local_rust_root} --disable-ldconfig
626 %setup -q -n rust-std-%{bootstrap_suffix} -T -b %{bootstrap_source_std}
627 ./install.sh --prefix=%{local_rust_root} --disable-ldconfig
628 test -f '%{local_rust_root}/bin/cargo'
629 test -f '%{local_rust_root}/bin/rustc'
630 %endif
631
632 %if %defined wasm_targets
633 %setup -q -n %{wasi_libc_name} -T -b 1
634 %endif
635
636 %setup -q -n %{rustc_package}
637
638 %patch1 -p1
639 %patch2 -p1
640 %patch3 -p1
641
642 %patch11 -p1
643
644 %if %with disabled_libssh2
645 %patch100 -p1
646 %endif
647
648 %if %without curl_http2
649 %patch101 -p1
650 rm -rf vendor/libnghttp2-sys/
651 %endif
652
653 %if 0%{?rhel} && 0%{?rhel} < 8
654 %patch102 -p1
655 %endif
656
657 # Use our explicit python3 first
658 sed -i.try-python -e '/^try python3 /i try "%{__python3}" "$@"' ./configure
659
660 # Set a substitute-path in rust-gdb for standard library sources.
661 sed -i.rust-src -e "s#@BUILDDIR@#$PWD#" ./src/etc/rust-gdb
662
663 %if %without bundled_llvm
664 rm -rf src/llvm-project/
665 mkdir -p src/llvm-project/libunwind/
666 %endif
667
668 # Remove other unused vendored libraries
669 rm -rf vendor/curl-sys/curl/
670 rm -rf vendor/*jemalloc-sys*/jemalloc/
671 rm -rf vendor/libmimalloc-sys/c_src/mimalloc/
672 rm -rf vendor/libssh2-sys/libssh2/
673 rm -rf vendor/libz-sys/src/zlib/
674 rm -rf vendor/libz-sys/src/zlib-ng/
675 rm -rf vendor/lzma-sys/xz-*/
676 rm -rf vendor/openssl-src/openssl/
677
678 %if %without bundled_libgit2
679 rm -rf vendor/libgit2-sys/libgit2/
680 %endif
681
682 %if %with disabled_libssh2
683 rm -rf vendor/libssh2-sys/
684 %endif
685
686 # This only affects the transient rust-installer, but let it use our dynamic xz-libs
687 sed -i.lzma -e '/LZMA_API_STATIC/d' src/bootstrap/tool.rs
688
689 %if %{with bundled_llvm} && 0%{?epel} == 7
690 mkdir -p cmake-bin
691 ln -s /usr/bin/cmake3 cmake-bin/cmake
692 %global cmake_path $PWD/cmake-bin
693 %endif
694
695 %if %{without bundled_llvm} && %{with llvm_static}
696 # Static linking to distro LLVM needs to add -lffi
697 # https://github.com/rust-lang/rust/issues/34486
698 sed -i.ffi -e '$a #[link(name = "ffi")] extern {}' \
699 compiler/rustc_llvm/src/lib.rs
700 %endif
701
702 # The configure macro will modify some autoconf-related files, which upsets
703 # cargo when it tries to verify checksums in those files. If we just truncate
704 # that file list, cargo won't have anything to complain about.
705 find vendor -name .cargo-checksum.json \
706 -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
707
708 # Sometimes Rust sources start with #![...] attributes, and "smart" editors think
709 # it's a shebang and make them executable. Then brp-mangle-shebangs gets upset...
710 find -name '*.rs' -type f -perm /111 -exec chmod -v -x '{}' '+'
711
712 # Set up shared environment variables for build/install/check
713 %global rust_env %{?rustflags:RUSTFLAGS="%{rustflags}"}
714 %if 0%{?cmake_path:1}
715 %global rust_env %{?rust_env} PATH="%{cmake_path}:$PATH"
716 %endif
717 %if %without disabled_libssh2
718 # convince libssh2-sys to use the distro libssh2
719 %global rust_env %{?rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1
720 %endif
721 %global export_rust_env %{?rust_env:export %{rust_env}}
722
723
724 %build
725 %{export_rust_env}
726
727 %ifarch aarch64 %{arm} %{ix86} s390x
728 # full debuginfo is exhausting memory; just do libstd for now
729 # https://github.com/rust-lang/rust/issues/45854
730 %if 0%{?rhel} && 0%{?rhel} < 8
731 # Older rpmbuild didn't work with partial debuginfo coverage.
732 %global debug_package %{nil}
733 %define enable_debuginfo --debuginfo-level=0
734 %else
735 %define enable_debuginfo --debuginfo-level=0 --debuginfo-level-std=2
736 %endif
737 %else
738 %define enable_debuginfo --debuginfo-level=2
739 %endif
740
741 # Some builders have relatively little memory for their CPU count.
742 # At least 2GB per CPU is a good rule of thumb for building rustc.
743 ncpus=$(/usr/bin/getconf _NPROCESSORS_ONLN)
744 max_cpus=$(( ($(free -g | awk '/^Mem:/{print $2}') + 1) / 2 ))
745 if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then
746 ncpus="$max_cpus"
747 fi
748
749 %if %defined mingw_targets
750 %{lua: do
751 local cfg = ""
752 for triple in string.gmatch(rpm.expand("%{mingw_targets}"), "%S+") do
753 local subs = {
754 triple = triple,
755 mingw = string.find(rpm.expand("%{ix86}"), string.sub(triple, 1, 4)) and "mingw32" or "mingw64",
756 }
757 local s = string.gsub([[
758 --set target.{{triple}}.linker=%{{{mingw}}_cc}
759 --set target.{{triple}}.cc=%{{{mingw}}_cc}
760 --set target.{{triple}}.ar=%{{{mingw}}_ar}
761 --set target.{{triple}}.ranlib=%{{{mingw}}_ranlib}
762 ]], "{{(%w+)}}", subs)
763 cfg = cfg .. " " .. s
764 end
765 cfg = string.gsub(cfg, "%s+", " ")
766 rpm.define("mingw_target_config " .. cfg)
767 end}
768 %endif
769
770 %if %defined wasm_targets
771 %make_build --quiet -C %{wasi_libc_dir} CC=clang AR=llvm-ar NM=llvm-nm
772 %{lua: do
773 local wasi_root = rpm.expand("%{wasi_libc_dir}") .. "/sysroot"
774 local cfg = ""
775 for triple in string.gmatch(rpm.expand("%{wasm_targets}"), "%S+") do
776 if string.find(triple, "-wasi") then
777 cfg = cfg .. " --set target." .. triple .. ".wasi-root=" .. wasi_root
778 end
779 end
780 rpm.define("wasm_target_config "..cfg)
781 end}
782 %endif
783
784 %configure --disable-option-checking \
785 --libdir=%{common_libdir} \
786 --build=%{rust_triple} --host=%{rust_triple} --target=%{target_triple} \
787 --set target.%{target_triple}.linker=%{__cc} \
788 --set target.%{target_triple}.cc=%{__cc} \
789 --set target.%{target_triple}.cxx=%{__cxx} \
790 --set target.%{target_triple}.ar=%{__ar} \
791 --set target.%{target_triple}.ranlib=%{__ranlib} \
792 %{?mingw_target_config} \
793 %{?wasm_target_config} \
794 --python=%{__python3} \
795 --local-rust-root=%{local_rust_root} \
796 --set build.rustfmt=/bin/true \
797 %{!?with_bundled_llvm: --llvm-root=%{llvm_root} \
798 %{!?llvm_has_filecheck: --disable-codegen-tests} \
799 %{!?with_llvm_static: --enable-llvm-link-shared } } \
800 --disable-llvm-static-stdcpp \
801 --disable-rpath \
802 %{enable_debuginfo} \
803 --set rust.codegen-units-std=1 \
804 --enable-extended \
805 --tools=analysis,cargo,clippy,rls,rust-analyzer,rustfmt,src \
806 --enable-vendor \
807 --enable-verbose-tests \
808 --dist-compression-formats=gz \
809 --release-channel=%{channel} \
810 --release-description="%{?mageia:Mageia }%{?fedora:Fedora }%{?rhel:Red Hat }%{version}-%{release}"
811
812 %{__python3} ./x.py build -j "$ncpus" --stage 2
813 %{__python3} ./x.py doc --stage 2
814
815 for triple in %{?mingw_targets} %{?wasm_targets}; do
816 %{__python3} ./x.py build --stage 2 --target=$triple std
817 done
818
819 %install
820 %{export_rust_env}
821
822 DESTDIR=%{buildroot} %{__python3} ./x.py install
823
824 for triple in %{?mingw_targets} %{?wasm_targets}; do
825 DESTDIR=%{buildroot} %{__python3} ./x.py install --target=$triple std
826 done
827
828 # These are transient files used by x.py dist and install
829 rm -rf ./build/dist/ ./build/tmp/
830
831 # Make sure the shared libraries are in the proper libdir
832 %if "%{_libdir}" != "%{common_libdir}"
833 mkdir -p %{buildroot}%{_libdir}
834 find %{buildroot}%{common_libdir} -maxdepth 1 -type f -name '*.so' \
835 -exec mv -v -t %{buildroot}%{_libdir} '{}' '+'
836 %endif
837
838 # The shared libraries should be executable for debuginfo extraction.
839 find %{buildroot}%{_libdir} -maxdepth 1 -type f -name '*.so' \
840 -exec chmod -v +x '{}' '+'
841
842 # The libdir libraries are identical to those under rustlib/. It's easier on
843 # library loading if we keep them in libdir, but we do need them in rustlib/
844 # to support dynamic linking for compiler plugins, so we'll symlink.
845 find %{buildroot}%{rustlibdir}/%{rust_triple}/lib/ -maxdepth 1 -type f -name '*.so' |
846 while read lib; do
847 lib2="%{buildroot}%{_libdir}/${lib##*/}"
848 if [ -f "$lib2" ]; then
849 # make sure they're actually identical!
850 cmp "$lib" "$lib2"
851 ln -v -f -r -s -T "$lib2" "$lib"
852 fi
853 done
854
855 # Remove installer artifacts (manifests, uninstall scripts, etc.)
856 find %{buildroot}%{rustlibdir} -maxdepth 1 -type f -exec rm -v '{}' '+'
857
858 # Remove backup files from %%configure munging
859 find %{buildroot}%{rustlibdir} -type f -name '*.orig' -exec rm -v '{}' '+'
860
861 # https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error
862 # We don't actually need to ship any of those python scripts in rust-src anyway.
863 find %{buildroot}%{rustlibdir}/src -type f -name '*.py' -exec rm -v '{}' '+'
864
865 # FIXME: __os_install_post will strip the rlibs
866 # -- should we find a way to preserve debuginfo?
867
868 # Remove unwanted documentation files (we already package them)
869 rm -f %{buildroot}%{_docdir}/%{name}/README.md
870 rm -f %{buildroot}%{_docdir}/%{name}/COPYRIGHT
871 rm -f %{buildroot}%{_docdir}/%{name}/LICENSE
872 rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-APACHE
873 rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-MIT
874 rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-THIRD-PARTY
875 rm -f %{buildroot}%{_docdir}/%{name}/*.old
876
877 # Sanitize the HTML documentation
878 find %{buildroot}%{_docdir}/%{name}/html -empty -delete
879 find %{buildroot}%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
880
881 # Create the path for crate-devel packages
882 mkdir -p %{buildroot}%{_datadir}/cargo/registry
883
884 # Cargo no longer builds its own documentation
885 # https://github.com/rust-lang/cargo/pull/4904
886 mkdir -p %{buildroot}%{_docdir}/cargo
887 ln -sT ../rust/html/cargo/ %{buildroot}%{_docdir}/cargo/html
888
889 %if %without lldb
890 rm -f %{buildroot}%{_bindir}/rust-lldb
891 rm -f %{buildroot}%{rustlibdir}/etc/lldb_*
892 %endif
893
894 # We don't want Rust copies of LLVM tools (rust-lld, rust-llvm-dwp)
895 rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll*
896
897 %if 0%{?rhel} && 0%{?rhel} >= 8
898 # This allows users to build packages using Rust Toolset.
899 %{__install} -D -m 644 %{S:100} %{buildroot}%{rpmmacrodir}/macros.rust-toolset
900 %endif
901
902
903 %check
904 %{export_rust_env}
905
906 # Sanity-check the installed binaries, debuginfo-stripped and all.
907 %{buildroot}%{_bindir}/cargo new build/hello-world
908 env RUSTC=%{buildroot}%{_bindir}/rustc \
909 LD_LIBRARY_PATH="%{buildroot}%{_libdir}:$LD_LIBRARY_PATH" \
910 %{buildroot}%{_bindir}/cargo run --manifest-path build/hello-world/Cargo.toml
911
912 # Try a build sanity-check for other targets
913 for triple in %{?mingw_targets} %{?wasm_targets}; do
914 env RUSTC=%{buildroot}%{_bindir}/rustc \
915 LD_LIBRARY_PATH="%{buildroot}%{_libdir}:$LD_LIBRARY_PATH" \
916 %{buildroot}%{_bindir}/cargo build --manifest-path build/hello-world/Cargo.toml --target=$triple
917 done
918
919 # The results are not stable on koji, so mask errors and just log it.
920 # Some of the larger test artifacts are manually cleaned to save space.
921 %{__python3} ./x.py test --no-fail-fast --stage 2 || :
922 rm -rf "./build/%{rust_triple}/test/"
923
924 %{__python3} ./x.py test --no-fail-fast --stage 2 cargo || :
925 rm -rf "./build/%{rust_triple}/stage2-tools/%{rust_triple}/cit/"
926
927 %{__python3} ./x.py test --no-fail-fast --stage 2 clippy || :
928
929 env RLS_TEST_WAIT_FOR_AGES=1 \
930 %{__python3} ./x.py test --no-fail-fast --stage 2 rls || :
931
932 %{__python3} ./x.py test --no-fail-fast --stage 2 rust-analyzer || :
933
934 %{__python3} ./x.py test --no-fail-fast --stage 2 rustfmt || :
935
936
937 %{?ldconfig_scriptlets}
938
939
940 %files
941 %license COPYRIGHT LICENSE-APACHE LICENSE-MIT
942 %doc README.md
943 %{_bindir}/rustc
944 %{_bindir}/rustdoc
945 %{_libdir}/*.so
946 %{_libexecdir}/rust-analyzer-proc-macro-srv
947 %{_mandir}/man1/rustc.1*
948 %{_mandir}/man1/rustdoc.1*
949 %dir %{rustlibdir}
950 %dir %{rustlibdir}/%{rust_triple}
951 %dir %{rustlibdir}/%{rust_triple}/lib
952 %{rustlibdir}/%{rust_triple}/lib/*.so
953 %if %defined bootstrap_build_arch
954 %dir %{rustlibdir}/%{target_triple}
955 %dir %{rustlibdir}/%{target_triple}/lib
956 %{rustlibdir}/%{target_triple}/lib/*.so
957 %endif
958
959
960 %files std-static
961 %dir %{rustlibdir}
962 %dir %{rustlibdir}/%{rust_triple}
963 %dir %{rustlibdir}/%{rust_triple}/lib
964 %{rustlibdir}/%{rust_triple}/lib/*.rlib
965 %if %defined bootstrap_build_arch
966 %dir %{rustlibdir}/%{target_triple}
967 %dir %{rustlibdir}/%{target_triple}/lib
968 %{rustlibdir}/%{target_triple}/lib/*.rlib
969 %endif
970
971
972 %if %defined mingw_targets
973 %{lua: do
974 for triple in string.gmatch(rpm.expand("%{mingw_targets}"), "%S+") do
975 local subs = {
976 triple = triple,
977 rustlibdir = rpm.expand("%{rustlibdir}"),
978 }
979 local s = string.gsub([[
980
981 %files std-static-{{triple}}
982 %dir {{rustlibdir}}
983 %dir {{rustlibdir}}/{{triple}}
984 %dir {{rustlibdir}}/{{triple}}/lib
985 {{rustlibdir}}/{{triple}}/lib/*.rlib
986 {{rustlibdir}}/{{triple}}/lib/rs*.o
987 %exclude {{rustlibdir}}/{{triple}}/lib/*.dll
988 %exclude {{rustlibdir}}/{{triple}}/lib/*.dll.a
989 %exclude {{rustlibdir}}/{{triple}}/lib/self-contained
990
991 ]], "{{(%w+)}}", subs)
992 print(s)
993 end
994 end}
995 %endif
996
997
998 %if %defined wasm_targets
999 %{lua: do
1000 for triple in string.gmatch(rpm.expand("%{wasm_targets}"), "%S+") do
1001 local subs = {
1002 triple = triple,
1003 rustlibdir = rpm.expand("%{rustlibdir}"),
1004 wasi = string.find(triple, "-wasi") and 1 or 0,
1005 }
1006 local s = string.gsub([[
1007
1008 %files std-static-{{triple}}
1009 %dir {{rustlibdir}}
1010 %dir {{rustlibdir}}/{{triple}}
1011 %dir {{rustlibdir}}/{{triple}}/lib
1012 {{rustlibdir}}/{{triple}}/lib/*.rlib
1013 %if {{wasi}}
1014 %dir {{rustlibdir}}/{{triple}}/lib/self-contained
1015 {{rustlibdir}}/{{triple}}/lib/self-contained/crt*.o
1016 {{rustlibdir}}/{{triple}}/lib/self-contained/libc.a
1017 %endif
1018
1019 ]], "{{(%w+)}}", subs)
1020 print(s)
1021 end
1022 end}
1023 %endif
1024
1025
1026 %files debugger-common
1027 %dir %{rustlibdir}
1028 %dir %{rustlibdir}/etc
1029 %{rustlibdir}/etc/rust_*.py*
1030
1031
1032 %files gdb
1033 %{_bindir}/rust-gdb
1034 %{rustlibdir}/etc/gdb_*
1035 %exclude %{_bindir}/rust-gdbgui
1036
1037
1038 %if %with lldb
1039 %files lldb
1040 %{_bindir}/rust-lldb
1041 %{rustlibdir}/etc/lldb_*
1042 %endif
1043
1044
1045 %files doc
1046 %docdir %{_docdir}/%{name}
1047 %dir %{_docdir}/%{name}
1048 %dir %{_docdir}/%{name}/html
1049 %{_docdir}/%{name}/html/*/
1050 %{_docdir}/%{name}/html/*.html
1051 %{_docdir}/%{name}/html/*.css
1052 %{_docdir}/%{name}/html/*.js
1053 %{_docdir}/%{name}/html/*.png
1054 %{_docdir}/%{name}/html/*.svg
1055 %{_docdir}/%{name}/html/*.woff2
1056 %license %{_docdir}/%{name}/html/*.txt
1057 %license %{_docdir}/%{name}/html/*.md
1058
1059
1060 %files -n cargo
1061 %license src/tools/cargo/LICENSE-APACHE src/tools/cargo/LICENSE-MIT src/tools/cargo/LICENSE-THIRD-PARTY
1062 %doc src/tools/cargo/README.md
1063 %{_bindir}/cargo
1064 %{_libexecdir}/cargo*
1065 %{_mandir}/man1/cargo*.1*
1066 %{_sysconfdir}/bash_completion.d/cargo
1067 %{_datadir}/zsh/site-functions/_cargo
1068 %dir %{_datadir}/cargo
1069 %dir %{_datadir}/cargo/registry
1070
1071
1072 %files -n cargo-doc
1073 %docdir %{_docdir}/cargo
1074 %dir %{_docdir}/cargo
1075 %{_docdir}/cargo/html
1076
1077
1078 %files -n rustfmt
1079 %{_bindir}/rustfmt
1080 %{_bindir}/cargo-fmt
1081 %doc src/tools/rustfmt/{README,CHANGELOG,Configurations}.md
1082 %license src/tools/rustfmt/LICENSE-{APACHE,MIT}
1083
1084
1085 %files -n rls
1086 %{_bindir}/rls
1087 %doc src/tools/rls/{README.md,COPYRIGHT,debugging.md}
1088 %license src/tools/rls/LICENSE-{APACHE,MIT}
1089
1090
1091 %files analyzer
1092 %{_bindir}/rust-analyzer
1093 %doc src/tools/rust-analyzer/README.md
1094 %license src/tools/rust-analyzer/LICENSE-{APACHE,MIT}
1095
1096
1097 %files -n clippy
1098 %{_bindir}/cargo-clippy
1099 %{_bindir}/clippy-driver
1100 %doc src/tools/clippy/{README.md,CHANGELOG.md}
1101 %license src/tools/clippy/LICENSE-{APACHE,MIT}
1102
1103
1104 %files src
1105 %dir %{rustlibdir}
1106 %{rustlibdir}/src
1107
1108
1109 %files analysis
1110 %{rustlibdir}/%{rust_triple}/analysis/
1111 %if %defined bootstrap_build_arch
1112 %{rustlibdir}/%{target_triple}/analysis/
1113 %endif
1114
1115
1116 %if 0%{?rhel} && 0%{?rhel} >= 8
1117 %files toolset
1118 %{rpmmacrodir}/macros.rust-toolset
1119 %endif

  ViewVC Help
Powered by ViewVC 1.1.30