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

  ViewVC Help
Powered by ViewVC 1.1.30