/[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 1769757 - (show annotations) (download)
Tue Jan 25 15:13:17 2022 UTC (2 years, 2 months ago) by akien
File size: 31524 byte(s)
- Sync with Fedora: Thu Jan 20 2022 Josh Stone <jistone@redhat.com> - 1.58.1-1
  o Update to 1.58.1.
  o Add rust-std-static-i686-pc-windows-gnu
  o Add rust-std-static-x86_64-pc-windows-gnu

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

  ViewVC Help
Powered by ViewVC 1.1.30