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

  ViewVC Help
Powered by ViewVC 1.1.30