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

  ViewVC Help
Powered by ViewVC 1.1.30