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

  ViewVC Help
Powered by ViewVC 1.1.30