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

  ViewVC Help
Powered by ViewVC 1.1.28