/[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 1753622 - (show annotations) (download)
Mon Nov 1 21:46:26 2021 UTC (2 years, 5 months ago) by akien
File size: 27087 byte(s)
- Sync with Fedora: Mon Nov 01 2021 Josh Stone <jistone@redhat.com> - 1.56.1-1
  o Update to 1.56.1.

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

  ViewVC Help
Powered by ViewVC 1.1.30