8931a1
# Only x86_64 and i686 are Tier 1 platforms at this time.
79456f
# https://doc.rust-lang.org/nightly/rustc/platform-support.html
8931a1
#global rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x
8931a1
%global rust_arches x86_64 i686 aarch64 ppc64le s390x
8931a1
8931a1
# The channel can be stable, beta, or nightly
8931a1
%{!?channel: %global channel stable}
8931a1
8931a1
# To bootstrap from scratch, set the channel and date from src/stage0.txt
8931a1
# e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
8931a1
# or nightly wants some beta-YYYY-MM-DD
8931a1
# Note that cargo matches the program version here, not its crate version.
c74a88
%global bootstrap_rust 1.51.0
c74a88
%global bootstrap_cargo 1.51.0
c74a88
%global bootstrap_channel 1.51.0
c74a88
%global bootstrap_date 2021-03-25
8931a1
8931a1
# Only the specified arches will use bootstrap binaries.
8931a1
#global bootstrap_arches %%{rust_arches}
8931a1
8931a1
# Using llvm-static may be helpful as an opt-in, e.g. to aid LLVM rebases.
8931a1
%bcond_with llvm_static
8931a1
8931a1
# We can also choose to just use Rust's bundled LLVM, in case the system LLVM
c74a88
# is insufficient.  Rust currently requires LLVM 9.0+.
8931a1
%bcond_with bundled_llvm
8931a1
c74a88
# Requires stable libgit2 1.1
c74a88
%if 0%{?fedora} >= 34
c3bb10
%bcond_with bundled_libgit2
c3bb10
%else
8931a1
%bcond_without bundled_libgit2
c3bb10
%endif
8931a1
8931a1
%if 0%{?rhel}
c3bb10
# Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949)
8931a1
%bcond_without disabled_libssh2
8931a1
%else
c3bb10
%bcond_with disabled_libssh2
8931a1
%endif
8931a1
c3bb10
%if 0%{?rhel} && 0%{?rhel} < 8
c3bb10
%bcond_with curl_http2
8931a1
%else
c3bb10
%bcond_without curl_http2
c3bb10
%endif
c3bb10
c3bb10
# LLDB isn't available everywhere...
c3bb10
%if 0%{?rhel} && 0%{?rhel} < 8
8931a1
%bcond_with lldb
c3bb10
%else
c3bb10
%bcond_without lldb
8931a1
%endif
8931a1
8931a1
Name:           rust
c74a88
Version:        1.52.1
8931a1
Release:        1%{?dist}
8931a1
Summary:        The Rust Programming Language
8931a1
License:        (ASL 2.0 or MIT) and (BSD and MIT)
8931a1
# ^ written as: (rust itself) and (bundled libraries)
8931a1
URL:            https://www.rust-lang.org
8931a1
ExclusiveArch:  %{rust_arches}
8931a1
8931a1
%if "%{channel}" == "stable"
8931a1
%global rustc_package rustc-%{version}-src
8931a1
%else
8931a1
%global rustc_package rustc-%{channel}-src
8931a1
%endif
8931a1
Source0:        https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
8931a1
c74a88
# This internal rust-abi change broke s390x -- revert for now.
c74a88
# https://github.com/rust-lang/rust/issues/80810#issuecomment-781784032
c74a88
Patch1:         0001-Revert-Auto-merge-of-79547.patch
c74a88
c3bb10
### RHEL-specific patches below ###
c3bb10
c3bb10
# Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949)
79456f
Patch100:       rustc-1.48.0-disable-libssh2.patch
c3bb10
c3bb10
# libcurl on RHEL7 doesn't have http2, but since cargo requests it, curl-sys
c3bb10
# will try to build it statically -- instead we turn off the feature.
c74a88
Patch101:       rustc-1.51.0-disable-http2.patch
c3bb10
c3bb10
# kernel rh1410097 causes too-small stacks for PIE.
c3bb10
# (affects RHEL6 kernels when building for RHEL7)
c74a88
Patch102:       rustc-1.51.0-no-default-pie.patch
9beef6
8931a1
8931a1
# Get the Rust triple for any arch.
8931a1
%{lua: function rust_triple(arch)
8931a1
  local abi = "gnu"
8931a1
  if arch == "armv7hl" then
8931a1
    arch = "armv7"
8931a1
    abi = "gnueabihf"
8931a1
  elseif arch == "ppc64" then
8931a1
    arch = "powerpc64"
8931a1
  elseif arch == "ppc64le" then
8931a1
    arch = "powerpc64le"
c3bb10
  elseif arch == "riscv64" then
c3bb10
    arch = "riscv64gc"
8931a1
  end
8931a1
  return arch.."-unknown-linux-"..abi
8931a1
end}
8931a1
8931a1
%global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))}
8931a1
8931a1
%if %defined bootstrap_arches
8931a1
# For each bootstrap arch, add an additional binary Source.
8931a1
# Also define bootstrap_source just for the current target.
8931a1
%{lua: do
8931a1
  local bootstrap_arches = {}
8931a1
  for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do
8931a1
    table.insert(bootstrap_arches, arch)
8931a1
  end
8931a1
  local base = rpm.expand("https://static.rust-lang.org/dist/%{bootstrap_date}"
8931a1
                          .."/rust-%{bootstrap_channel}")
8931a1
  local target_arch = rpm.expand("%{_target_cpu}")
8931a1
  for i, arch in ipairs(bootstrap_arches) do
8931a1
    print(string.format("Source%d: %s-%s.tar.xz\n",
8931a1
                        i, base, rust_triple(arch)))
8931a1
    if arch == target_arch then
8931a1
      rpm.define("bootstrap_source "..i)
8931a1
    end
8931a1
  end
8931a1
end}
8931a1
%endif
8931a1
8931a1
%ifarch %{bootstrap_arches}
8931a1
%global bootstrap_root rust-%{bootstrap_channel}-%{rust_triple}
8931a1
%global local_rust_root %{_builddir}/%{bootstrap_root}/usr
8931a1
Provides:       bundled(%{name}-bootstrap) = %{bootstrap_rust}
8931a1
%else
8931a1
BuildRequires:  cargo >= %{bootstrap_cargo}
c3bb10
%if 0%{?rhel} && 0%{?rhel} < 8
8931a1
BuildRequires:  %{name} >= %{bootstrap_rust}
8931a1
BuildConflicts: %{name} > %{version}
c3bb10
%else
c3bb10
BuildRequires:  (%{name} >= %{bootstrap_rust} with %{name} <= %{version})
8931a1
%endif
8931a1
%global local_rust_root %{_prefix}
8931a1
%endif
8931a1
8931a1
BuildRequires:  make
8931a1
BuildRequires:  gcc
8931a1
BuildRequires:  gcc-c++
8931a1
BuildRequires:  ncurses-devel
8931a1
BuildRequires:  curl
c3bb10
# explicit curl-devel to avoid httpd24-curl (rhbz1540167)
c3bb10
BuildRequires:  curl-devel
8931a1
BuildRequires:  pkgconfig(libcurl)
8931a1
BuildRequires:  pkgconfig(liblzma)
8931a1
BuildRequires:  pkgconfig(openssl)
8931a1
BuildRequires:  pkgconfig(zlib)
8931a1
8931a1
%if %without bundled_libgit2
c74a88
BuildRequires:  pkgconfig(libgit2) >= 1.1.0
8931a1
%endif
8931a1
79456f
%if %{without disabled_libssh2}
8931a1
# needs libssh2_userauth_publickey_frommemory
8931a1
BuildRequires:  pkgconfig(libssh2) >= 1.6.0
8931a1
%endif
8931a1
8931a1
%global python python3
8931a1
BuildRequires:  %{python}
8931a1
8931a1
%if %with bundled_llvm
c74a88
BuildRequires:  cmake3 >= 3.13.4
c74a88
Provides:       bundled(llvm) = 12.0.0
8931a1
%else
8931a1
BuildRequires:  cmake >= 2.8.11
c3bb10
%if 0%{?epel} == 7
75225e
%global llvm llvm9.0
8931a1
%endif
8931a1
%if %defined llvm
8931a1
%global llvm_root %{_libdir}/%{llvm}
8931a1
%else
8931a1
%global llvm llvm
8931a1
%global llvm_root %{_prefix}
8931a1
%endif
79456f
BuildRequires:  %{llvm}-devel >= 9.0
8931a1
%if %with llvm_static
8931a1
BuildRequires:  %{llvm}-static
8931a1
BuildRequires:  libffi-devel
8931a1
%endif
8931a1
%endif
8931a1
8931a1
# make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
8931a1
BuildRequires:  procps-ng
8931a1
8931a1
# debuginfo-gdb tests need gdb
8931a1
BuildRequires:  gdb
8931a1
8931a1
# Virtual provides for folks who attempt "dnf install rustc"
8931a1
Provides:       rustc = %{version}-%{release}
8931a1
Provides:       rustc%{?_isa} = %{version}-%{release}
8931a1
8931a1
# Always require our exact standard library
8931a1
Requires:       %{name}-std-static%{?_isa} = %{version}-%{release}
8931a1
8931a1
# The C compiler is needed at runtime just for linking.  Someday rustc might
8931a1
# invoke the linker directly, and then we'll only need binutils.
8931a1
# https://github.com/rust-lang/rust/issues/11937
8931a1
Requires:       /usr/bin/cc
8931a1
8931a1
# ALL Rust libraries are private, because they don't keep an ABI.
8931a1
%global _privatelibs lib(.*-[[:xdigit:]]{16}*|rustc.*)[.]so.*
8931a1
%global __provides_exclude ^(%{_privatelibs})$
8931a1
%global __requires_exclude ^(%{_privatelibs})$
8931a1
%global __provides_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$
8931a1
%global __requires_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$
8931a1
8931a1
# While we don't want to encourage dynamic linking to Rust shared libraries, as
8931a1
# there's no stable ABI, we still need the unallocated metadata (.rustc) to
c3bb10
# support custom-derive plugins like #[proc_macro_derive(Foo)].
c3bb10
%if 0%{?rhel} && 0%{?rhel} < 8
c3bb10
# eu-strip is very eager by default, so we have to limit it to -g, only debugging symbols.
8931a1
%global _find_debuginfo_opts -g
8931a1
%undefine _include_minidebuginfo
c3bb10
%else
c3bb10
# Newer find-debuginfo.sh supports --keep-section, which is preferable. rhbz1465997
c3bb10
%global _find_debuginfo_opts --keep-section .rustc
8931a1
%endif
8931a1
8931a1
# Use hardening ldflags.
8931a1
%global rustflags -Clink-arg=-Wl,-z,relro,-z,now
8931a1
8931a1
%if %{without bundled_llvm}
8931a1
%if "%{llvm_root}" == "%{_prefix}" || 0%{?scl:1}
8931a1
%global llvm_has_filecheck 1
8931a1
%endif
8931a1
%endif
8931a1
8931a1
%description
8931a1
Rust is a systems programming language that runs blazingly fast, prevents
8931a1
segfaults, and guarantees thread safety.
8931a1
8931a1
This package includes the Rust compiler and documentation generator.
8931a1
8931a1
8931a1
%package std-static
8931a1
Summary:        Standard library for Rust
8931a1
8931a1
%description std-static
8931a1
This package includes the standard libraries for building applications
8931a1
written in Rust.
8931a1
8931a1
8931a1
%package debugger-common
8931a1
Summary:        Common debugger pretty printers for Rust
8931a1
BuildArch:      noarch
8931a1
8931a1
%description debugger-common
8931a1
This package includes the common functionality for %{name}-gdb and %{name}-lldb.
8931a1
8931a1
8931a1
%package gdb
8931a1
Summary:        GDB pretty printers for Rust
8931a1
BuildArch:      noarch
8931a1
Requires:       gdb
8931a1
Requires:       %{name}-debugger-common = %{version}-%{release}
8931a1
8931a1
%description gdb
8931a1
This package includes the rust-gdb script, which allows easier debugging of Rust
8931a1
programs.
8931a1
8931a1
8931a1
%if %with lldb
8931a1
8931a1
%package lldb
8931a1
Summary:        LLDB pretty printers for Rust
8931a1
BuildArch:      noarch
8931a1
Requires:       lldb
c3bb10
Requires:       %{python}-lldb
8931a1
Requires:       %{name}-debugger-common = %{version}-%{release}
8931a1
8931a1
%description lldb
8931a1
This package includes the rust-lldb script, which allows easier debugging of Rust
8931a1
programs.
8931a1
8931a1
%endif
8931a1
8931a1
8931a1
%package doc
8931a1
Summary:        Documentation for Rust
8931a1
# NOT BuildArch:      noarch
8931a1
# Note, while docs are mostly noarch, some things do vary by target_arch.
8931a1
# Koji will fail the build in rpmdiff if two architectures build a noarch
8931a1
# subpackage differently, so instead we have to keep its arch.
8931a1
8931a1
%description doc
8931a1
This package includes HTML documentation for the Rust programming language and
8931a1
its standard library.
8931a1
8931a1
8931a1
%package -n cargo
8931a1
Summary:        Rust's package manager and build tool
8931a1
%if %with bundled_libgit2
79456f
Provides:       bundled(libgit2) = 1.1.0
8931a1
%endif
8931a1
# For tests:
8931a1
BuildRequires:  git
8931a1
# Cargo is not much use without Rust
8931a1
Requires:       rust
8931a1
8931a1
# "cargo vendor" is a builtin command starting with 1.37.  The Obsoletes and
8931a1
# Provides are mostly relevant to RHEL, but harmless to have on Fedora/etc. too
8931a1
Obsoletes:      cargo-vendor <= 0.1.23
8931a1
Provides:       cargo-vendor = %{version}-%{release}
8931a1
8931a1
%description -n cargo
8931a1
Cargo is a tool that allows Rust projects to declare their various dependencies
8931a1
and ensure that you'll always get a repeatable build.
8931a1
8931a1
8931a1
%package -n cargo-doc
8931a1
Summary:        Documentation for Cargo
8931a1
BuildArch:      noarch
8931a1
# Cargo no longer builds its own documentation
8931a1
# https://github.com/rust-lang/cargo/pull/4904
8931a1
Requires:       rust-doc = %{version}-%{release}
8931a1
8931a1
%description -n cargo-doc
8931a1
This package includes HTML documentation for Cargo.
8931a1
8931a1
8931a1
%package -n rustfmt
8931a1
Summary:        Tool to find and fix Rust formatting issues
8931a1
Requires:       cargo
8931a1
8931a1
# The component/package was rustfmt-preview until Rust 1.31.
8931a1
Obsoletes:      rustfmt-preview < 1.0.0
8931a1
Provides:       rustfmt-preview = %{version}-%{release}
8931a1
8931a1
%description -n rustfmt
8931a1
A tool for formatting Rust code according to style guidelines.
8931a1
8931a1
8931a1
%package -n rls
8931a1
Summary:        Rust Language Server for IDE integration
8931a1
%if %with bundled_libgit2
79456f
Provides:       bundled(libgit2) = 1.1.0
8931a1
%endif
8931a1
Requires:       rust-analysis
8931a1
# /usr/bin/rls is dynamically linked against internal rustc libs
8931a1
Requires:       %{name}%{?_isa} = %{version}-%{release}
8931a1
8931a1
# The component/package was rls-preview until Rust 1.31.
8931a1
Obsoletes:      rls-preview < 1.31.6
8931a1
Provides:       rls-preview = %{version}-%{release}
8931a1
8931a1
%description -n rls
8931a1
The Rust Language Server provides a server that runs in the background,
8931a1
providing IDEs, editors, and other tools with information about Rust programs.
8931a1
It supports functionality such as 'goto definition', symbol search,
8931a1
reformatting, and code completion, and enables renaming and refactorings.
8931a1
8931a1
8931a1
%package -n clippy
8931a1
Summary:        Lints to catch common mistakes and improve your Rust code
8931a1
Requires:       cargo
8931a1
# /usr/bin/clippy-driver is dynamically linked against internal rustc libs
8931a1
Requires:       %{name}%{?_isa} = %{version}-%{release}
8931a1
8931a1
# The component/package was clippy-preview until Rust 1.31.
8931a1
Obsoletes:      clippy-preview <= 0.0.212
8931a1
Provides:       clippy-preview = %{version}-%{release}
8931a1
8931a1
%description -n clippy
8931a1
A collection of lints to catch common mistakes and improve your Rust code.
8931a1
8931a1
8931a1
%package src
8931a1
Summary:        Sources for the Rust standard library
8931a1
BuildArch:      noarch
8931a1
8931a1
%description src
8931a1
This package includes source files for the Rust standard library.  It may be
8931a1
useful as a reference for code completion tools in various editors.
8931a1
8931a1
8931a1
%package analysis
8931a1
Summary:        Compiler analysis data for the Rust standard library
8931a1
Requires:       rust-std-static%{?_isa} = %{version}-%{release}
8931a1
8931a1
%description analysis
8931a1
This package contains analysis data files produced with rustc's -Zsave-analysis
8931a1
feature for the Rust standard library. The RLS (Rust Language Server) uses this
8931a1
data to provide information about the Rust standard library.
8931a1
8931a1
8931a1
%prep
8931a1
8931a1
%ifarch %{bootstrap_arches}
8931a1
%setup -q -n %{bootstrap_root} -T -b %{bootstrap_source}
8931a1
./install.sh --components=cargo,rustc,rust-std-%{rust_triple} \
8931a1
  --prefix=%{local_rust_root} --disable-ldconfig
8931a1
test -f '%{local_rust_root}/bin/cargo'
8931a1
test -f '%{local_rust_root}/bin/rustc'
8931a1
%endif
8931a1
8931a1
%setup -q -n %{rustc_package}
8931a1
c74a88
%patch1 -p1
c74a88
8931a1
%if %with disabled_libssh2
c3bb10
%patch100 -p1
c3bb10
%endif
c3bb10
c3bb10
%if %without curl_http2
c3bb10
%patch101 -p1
c3bb10
rm -rf vendor/libnghttp2-sys/
8931a1
%endif
8931a1
c3bb10
%if 0%{?rhel} && 0%{?rhel} < 8
79456f
%patch102 -p1
c3bb10
%endif
c3bb10
c3bb10
%if "%{python}" != "python3"
c3bb10
# Use our preferred python first
c3bb10
sed -i.try-python -e '/^try python3 /i try "%{python}" "$@"' ./configure
8931a1
%endif
8931a1
8931a1
%if %without bundled_llvm
8931a1
rm -rf src/llvm-project/
79456f
mkdir -p src/llvm-project/libunwind/
8931a1
%endif
8931a1
8931a1
# Remove other unused vendored libraries
8931a1
rm -rf vendor/curl-sys/curl/
8931a1
rm -rf vendor/jemalloc-sys/jemalloc/
79456f
rm -rf vendor/libssh2-sys/libssh2/
8931a1
rm -rf vendor/libz-sys/src/zlib/
79456f
rm -rf vendor/libz-sys/src/zlib-ng/
8931a1
rm -rf vendor/lzma-sys/xz-*/
8931a1
rm -rf vendor/openssl-src/openssl/
8931a1
8931a1
%if %without bundled_libgit2
8931a1
rm -rf vendor/libgit2-sys/libgit2/
8931a1
%endif
8931a1
8931a1
%if %with disabled_libssh2
8931a1
rm -rf vendor/libssh2-sys/
8931a1
%endif
8931a1
8931a1
# This only affects the transient rust-installer, but let it use our dynamic xz-libs
8931a1
sed -i.lzma -e '/LZMA_API_STATIC/d' src/bootstrap/tool.rs
8931a1
c3bb10
%if %{with bundled_llvm} && 0%{?epel} == 7
8931a1
mkdir -p cmake-bin
8931a1
ln -s /usr/bin/cmake3 cmake-bin/cmake
8931a1
%global cmake_path $PWD/cmake-bin
8931a1
%endif
8931a1
8931a1
%if %{without bundled_llvm} && %{with llvm_static}
8931a1
# Static linking to distro LLVM needs to add -lffi
8931a1
# https://github.com/rust-lang/rust/issues/34486
8931a1
sed -i.ffi -e '$a #[link(name = "ffi")] extern {}' \
8931a1
  src/librustc_llvm/lib.rs
8931a1
%endif
8931a1
8931a1
# The configure macro will modify some autoconf-related files, which upsets
8931a1
# cargo when it tries to verify checksums in those files.  If we just truncate
8931a1
# that file list, cargo won't have anything to complain about.
8931a1
find vendor -name .cargo-checksum.json \
8931a1
  -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
8931a1
8931a1
# Sometimes Rust sources start with #![...] attributes, and "smart" editors think
8931a1
# it's a shebang and make them executable. Then brp-mangle-shebangs gets upset...
8931a1
find -name '*.rs' -type f -perm /111 -exec chmod -v -x '{}' '+'
8931a1
c3bb10
# Set up shared environment variables for build/install/check
c3bb10
%global rust_env RUSTFLAGS="%{rustflags}"
c3bb10
%if 0%{?cmake_path:1}
c3bb10
%global rust_env %{rust_env} PATH="%{cmake_path}:$PATH"
c3bb10
%endif
8931a1
%if %without bundled_libgit2
8931a1
# convince libgit2-sys to use the distro libgit2
c3bb10
%global rust_env %{rust_env} LIBGIT2_SYS_USE_PKG_CONFIG=1
8931a1
%endif
79456f
%if %without disabled_libssh2
8931a1
# convince libssh2-sys to use the distro libssh2
c3bb10
%global rust_env %{rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1
8931a1
%endif
8931a1
c3bb10
c3bb10
%build
c3bb10
export %{rust_env}
8931a1
8931a1
# We're going to override --libdir when configuring to get rustlib into a
8931a1
# common path, but we'll fix the shared libraries during install.
8931a1
%global common_libdir %{_prefix}/lib
8931a1
%global rustlibdir %{common_libdir}/rustlib
8931a1
8931a1
%ifarch %{arm} %{ix86} s390x
8931a1
# full debuginfo is exhausting memory; just do libstd for now
8931a1
# https://github.com/rust-lang/rust/issues/45854
c3bb10
%if 0%{?rhel} && 0%{?rhel} < 8
8931a1
# Older rpmbuild didn't work with partial debuginfo coverage.
8931a1
%global debug_package %{nil}
8931a1
%define enable_debuginfo --debuginfo-level=0
8931a1
%else
8931a1
%define enable_debuginfo --debuginfo-level=0 --debuginfo-level-std=2
8931a1
%endif
8931a1
%else
8931a1
%define enable_debuginfo --debuginfo-level=2
8931a1
%endif
8931a1
8931a1
# We want the best optimization for std, but it caused problems for rpm-ostree
8931a1
# on ppc64le to have all of the compiler_builtins in a single object:
8931a1
# https://bugzilla.redhat.com/show_bug.cgi?id=1713090
8931a1
%ifnarch %{power64}
8931a1
%define codegen_units_std --set rust.codegen-units-std=1
8931a1
%endif
8931a1
75225e
# Some builders have relatively little memory for their CPU count.
75225e
# At least 2GB per CPU is a good rule of thumb for building rustc.
75225e
ncpus=$(/usr/bin/getconf _NPROCESSORS_ONLN)
75225e
max_cpus=$(( ($(free -g | awk '/^Mem:/{print $2}') + 1) / 2 ))
75225e
if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then
75225e
  ncpus="$max_cpus"
75225e
fi
75225e
8931a1
%configure --disable-option-checking \
8931a1
  --libdir=%{common_libdir} \
8931a1
  --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
8931a1
  --python=%{python} \
8931a1
  --local-rust-root=%{local_rust_root} \
8931a1
  %{!?with_bundled_llvm: --llvm-root=%{llvm_root} \
8931a1
    %{!?llvm_has_filecheck: --disable-codegen-tests} \
8931a1
    %{!?with_llvm_static: --enable-llvm-link-shared } } \
8931a1
  --disable-rpath \
8931a1
  %{enable_debuginfo} \
8931a1
  --enable-extended \
75225e
  --tools=analysis,cargo,clippy,rls,rustfmt,src \
8931a1
  --enable-vendor \
8931a1
  --enable-verbose-tests \
8931a1
  %{?codegen_units_std} \
c74a88
  --release-channel=%{channel} \
c74a88
  --release-description="%{?fedora:Fedora }%{?rhel:Red Hat }%{version}-%{release}"
8931a1
c3bb10
%{python} ./x.py build -j "$ncpus" --stage 2
c3bb10
%{python} ./x.py doc --stage 2
8931a1
8931a1
8931a1
%install
c3bb10
export %{rust_env}
8931a1
8931a1
DESTDIR=%{buildroot} %{python} ./x.py install
8931a1
8931a1
# Make sure the shared libraries are in the proper libdir
8931a1
%if "%{_libdir}" != "%{common_libdir}"
8931a1
mkdir -p %{buildroot}%{_libdir}
8931a1
find %{buildroot}%{common_libdir} -maxdepth 1 -type f -name '*.so' \
8931a1
  -exec mv -v -t %{buildroot}%{_libdir} '{}' '+'
8931a1
%endif
8931a1
8931a1
# The shared libraries should be executable for debuginfo extraction.
8931a1
find %{buildroot}%{_libdir} -maxdepth 1 -type f -name '*.so' \
8931a1
  -exec chmod -v +x '{}' '+'
8931a1
8931a1
# The libdir libraries are identical to those under rustlib/.  It's easier on
8931a1
# library loading if we keep them in libdir, but we do need them in rustlib/
8931a1
# to support dynamic linking for compiler plugins, so we'll symlink.
8931a1
(cd "%{buildroot}%{rustlibdir}/%{rust_triple}/lib" &&
8931a1
 find ../../../../%{_lib} -maxdepth 1 -name '*.so' |
8931a1
 while read lib; do
8931a1
   if [ -f "${lib##*/}" ]; then
8931a1
     # make sure they're actually identical!
8931a1
     cmp "$lib" "${lib##*/}"
8931a1
     ln -v -f -s -t . "$lib"
8931a1
   fi
8931a1
 done)
8931a1
8931a1
# Remove installer artifacts (manifests, uninstall scripts, etc.)
8931a1
find %{buildroot}%{rustlibdir} -maxdepth 1 -type f -exec rm -v '{}' '+'
8931a1
8931a1
# Remove backup files from %%configure munging
8931a1
find %{buildroot}%{rustlibdir} -type f -name '*.orig' -exec rm -v '{}' '+'
8931a1
8931a1
# https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error
8931a1
# We don't actually need to ship any of those python scripts in rust-src anyway.
8931a1
find %{buildroot}%{rustlibdir}/src -type f -name '*.py' -exec rm -v '{}' '+'
8931a1
8931a1
# FIXME: __os_install_post will strip the rlibs
8931a1
# -- should we find a way to preserve debuginfo?
8931a1
8931a1
# Remove unwanted documentation files (we already package them)
8931a1
rm -f %{buildroot}%{_docdir}/%{name}/README.md
8931a1
rm -f %{buildroot}%{_docdir}/%{name}/COPYRIGHT
8931a1
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE
8931a1
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-APACHE
8931a1
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-MIT
8931a1
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-THIRD-PARTY
8931a1
rm -f %{buildroot}%{_docdir}/%{name}/*.old
8931a1
8931a1
# Sanitize the HTML documentation
8931a1
find %{buildroot}%{_docdir}/%{name}/html -empty -delete
8931a1
find %{buildroot}%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
8931a1
8931a1
# Create the path for crate-devel packages
8931a1
mkdir -p %{buildroot}%{_datadir}/cargo/registry
8931a1
8931a1
# Cargo no longer builds its own documentation
8931a1
# https://github.com/rust-lang/cargo/pull/4904
8931a1
mkdir -p %{buildroot}%{_docdir}/cargo
8931a1
ln -sT ../rust/html/cargo/ %{buildroot}%{_docdir}/cargo/html
8931a1
8931a1
%if %without lldb
8931a1
rm -f %{buildroot}%{_bindir}/rust-lldb
c3bb10
rm -f %{buildroot}%{rustlibdir}/etc/lldb_*
8931a1
%endif
8931a1
c74a88
# We don't want Rust copies of LLVM tools (rust-lld, rust-llvm-dwp)
c74a88
rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll*
c74a88
8931a1
8931a1
%check
c3bb10
export %{rust_env}
8931a1
8931a1
# The results are not stable on koji, so mask errors and just log it.
c3bb10
%{python} ./x.py test --no-fail-fast --stage 2 || :
c3bb10
%{python} ./x.py test --no-fail-fast --stage 2 cargo || :
c3bb10
%{python} ./x.py test --no-fail-fast --stage 2 clippy || :
c3bb10
%{python} ./x.py test --no-fail-fast --stage 2 rls || :
c3bb10
%{python} ./x.py test --no-fail-fast --stage 2 rustfmt || :
8931a1
8931a1
8931a1
%ldconfig_scriptlets
8931a1
8931a1
8931a1
%files
8931a1
%license COPYRIGHT LICENSE-APACHE LICENSE-MIT
8931a1
%doc README.md
8931a1
%{_bindir}/rustc
8931a1
%{_bindir}/rustdoc
8931a1
%{_libdir}/*.so
8931a1
%{_mandir}/man1/rustc.1*
8931a1
%{_mandir}/man1/rustdoc.1*
8931a1
%dir %{rustlibdir}
8931a1
%dir %{rustlibdir}/%{rust_triple}
8931a1
%dir %{rustlibdir}/%{rust_triple}/lib
8931a1
%{rustlibdir}/%{rust_triple}/lib/*.so
8931a1
8931a1
8931a1
%files std-static
8931a1
%dir %{rustlibdir}
8931a1
%dir %{rustlibdir}/%{rust_triple}
8931a1
%dir %{rustlibdir}/%{rust_triple}/lib
8931a1
%{rustlibdir}/%{rust_triple}/lib/*.rlib
8931a1
8931a1
8931a1
%files debugger-common
8931a1
%dir %{rustlibdir}
8931a1
%dir %{rustlibdir}/etc
c3bb10
%{rustlibdir}/etc/rust_*.py*
8931a1
8931a1
8931a1
%files gdb
8931a1
%{_bindir}/rust-gdb
c3bb10
%{rustlibdir}/etc/gdb_*
8931a1
%exclude %{_bindir}/rust-gdbgui
8931a1
8931a1
8931a1
%if %with lldb
8931a1
%files lldb
8931a1
%{_bindir}/rust-lldb
c3bb10
%{rustlibdir}/etc/lldb_*
8931a1
%endif
8931a1
8931a1
8931a1
%files doc
8931a1
%docdir %{_docdir}/%{name}
8931a1
%dir %{_docdir}/%{name}
8931a1
%dir %{_docdir}/%{name}/html
8931a1
%{_docdir}/%{name}/html/*/
8931a1
%{_docdir}/%{name}/html/*.html
8931a1
%{_docdir}/%{name}/html/*.css
8931a1
%{_docdir}/%{name}/html/*.js
8931a1
%{_docdir}/%{name}/html/*.png
8931a1
%{_docdir}/%{name}/html/*.svg
8931a1
%{_docdir}/%{name}/html/*.woff
c74a88
%{_docdir}/%{name}/html/*.woff2
8931a1
%license %{_docdir}/%{name}/html/*.txt
8931a1
%license %{_docdir}/%{name}/html/*.md
8931a1
8931a1
8931a1
%files -n cargo
8931a1
%license src/tools/cargo/LICENSE-APACHE src/tools/cargo/LICENSE-MIT src/tools/cargo/LICENSE-THIRD-PARTY
8931a1
%doc src/tools/cargo/README.md
8931a1
%{_bindir}/cargo
c74a88
%{_libexecdir}/cargo*
8931a1
%{_mandir}/man1/cargo*.1*
8931a1
%{_sysconfdir}/bash_completion.d/cargo
8931a1
%{_datadir}/zsh/site-functions/_cargo
8931a1
%dir %{_datadir}/cargo
8931a1
%dir %{_datadir}/cargo/registry
8931a1
8931a1
8931a1
%files -n cargo-doc
8931a1
%docdir %{_docdir}/cargo
8931a1
%dir %{_docdir}/cargo
8931a1
%{_docdir}/cargo/html
8931a1
8931a1
8931a1
%files -n rustfmt
8931a1
%{_bindir}/rustfmt
8931a1
%{_bindir}/cargo-fmt
8931a1
%doc src/tools/rustfmt/{README,CHANGELOG,Configurations}.md
8931a1
%license src/tools/rustfmt/LICENSE-{APACHE,MIT}
8931a1
8931a1
8931a1
%files -n rls
8931a1
%{_bindir}/rls
8931a1
%doc src/tools/rls/{README.md,COPYRIGHT,debugging.md}
8931a1
%license src/tools/rls/LICENSE-{APACHE,MIT}
8931a1
8931a1
8931a1
%files -n clippy
8931a1
%{_bindir}/cargo-clippy
8931a1
%{_bindir}/clippy-driver
8931a1
%doc src/tools/clippy/{README.md,CHANGELOG.md}
8931a1
%license src/tools/clippy/LICENSE-{APACHE,MIT}
8931a1
8931a1
8931a1
%files src
8931a1
%dir %{rustlibdir}
8931a1
%{rustlibdir}/src
8931a1
8931a1
8931a1
%files analysis
8931a1
%{rustlibdir}/%{rust_triple}/analysis/
8931a1
8931a1
8931a1
%changelog
c74a88
* Tue May 25 2021 Josh Stone <jistone@redhat.com> - 1.52.1-1
c74a88
- Update to 1.52.1. Includes security fixes for CVE-2020-36323,
c74a88
  CVE-2021-28876, CVE-2021-28878, CVE-2021-28879, and CVE-2021-31162.
c74a88
c74a88
* Mon May 24 2021 Josh Stone <jistone@redhat.com> - 1.51.0-1
c74a88
- Update to 1.51.0. Update to 1.51.0. Includes security fixes for
c74a88
  CVE-2021-28875 and CVE-2021-28877.
c74a88
c74a88
* Mon May 24 2021 Josh Stone <jistone@redhat.com> - 1.50.0-1
c74a88
- Update to 1.50.0.
c74a88
79456f
* Wed Jan 13 2021 Josh Stone <jistone@redhat.com> - 1.49.0-1
79456f
- Update to 1.49.0.
79456f
79456f
* Tue Jan 12 2021 Josh Stone <jistone@redhat.com> - 1.48.0-1
79456f
- Update to 1.48.0.
79456f
c3bb10
* Thu Oct 22 2020 Josh Stone <jistone@redhat.com> - 1.47.0-1
c3bb10
- Update to 1.47.0.
c3bb10
c3bb10
* Wed Oct 14 2020 Josh Stone <jistone@redhat.com> - 1.46.0-1
c3bb10
- Update to 1.46.0.
c3bb10
9beef6
* Tue Aug 04 2020 Josh Stone <jistone@redhat.com> - 1.45.2-1
9beef6
- Update to 1.45.2.
9beef6
75225e
* Thu Jul 16 2020 Josh Stone <jistone@redhat.com> - 1.45.0-1
75225e
- Update to 1.45.0.
75225e
75225e
* Tue Jul 14 2020 Josh Stone <jistone@redhat.com> - 1.44.1-1
75225e
- Update to 1.44.1.
75225e
8931a1
* Thu May 07 2020 Josh Stone <jistone@redhat.com> - 1.43.1-1
8931a1
- Update to 1.43.1.
8931a1
8931a1
* Thu Apr 23 2020 Josh Stone <jistone@redhat.com> - 1.43.0-1
8931a1
- Update to 1.43.0.
8931a1
8931a1
* Thu Mar 12 2020 Josh Stone <jistone@redhat.com> - 1.42.0-1
8931a1
- Update to 1.42.0.
8931a1
8931a1
* Thu Feb 27 2020 Josh Stone <jistone@redhat.com> - 1.41.1-1
8931a1
- Update to 1.41.1.
8931a1
8931a1
* Thu Jan 30 2020 Josh Stone <jistone@redhat.com> - 1.41.0-1
8931a1
- Update to 1.41.0.
8931a1
8931a1
* Thu Jan 16 2020 Josh Stone <jistone@redhat.com> - 1.40.0-1
8931a1
- Update to 1.40.0.
8931a1
- Fix compiletest with newer (local-rebuild) libtest
8931a1
- Build compiletest with in-tree libtest
8931a1
- Fix ARM EHABI unwinding
8931a1
8931a1
* Tue Nov 12 2019 Josh Stone <jistone@redhat.com> - 1.39.0-2
8931a1
- Fix a couple build and test issues with rustdoc.
8931a1
8931a1
* Thu Nov 07 2019 Josh Stone <jistone@redhat.com> - 1.39.0-1
8931a1
- Update to 1.39.0.
8931a1
8931a1
* Thu Sep 26 2019 Josh Stone <jistone@redhat.com> - 1.38.0-1
8931a1
- Update to 1.38.0.
8931a1
8931a1
* Thu Aug 15 2019 Josh Stone <jistone@redhat.com> - 1.37.0-1
8931a1
- Update to 1.37.0.
8931a1
- Disable libssh2 (git+ssh support).
8931a1
8931a1
* Thu Jul 04 2019 Josh Stone <jistone@redhat.com> - 1.36.0-1
8931a1
- Update to 1.36.0.
8931a1
8931a1
* Wed May 29 2019 Josh Stone <jistone@redhat.com> - 1.35.0-2
8931a1
- Fix compiletest for rebuild testing.
8931a1
8931a1
* Thu May 23 2019 Josh Stone <jistone@redhat.com> - 1.35.0-1
8931a1
- Update to 1.35.0.
8931a1
8931a1
* Tue May 14 2019 Josh Stone <jistone@redhat.com> - 1.34.2-1
8931a1
- Update to 1.34.2 -- fixes CVE-2019-12083.
8931a1
8931a1
* Thu May 09 2019 Josh Stone <jistone@redhat.com> - 1.34.1-1
8931a1
- Update to 1.34.1.
8931a1
8931a1
* Thu Apr 11 2019 Josh Stone <jistone@redhat.com> - 1.34.0-1
8931a1
- Update to 1.34.0.
8931a1
8931a1
* Wed Apr 10 2019 Josh Stone <jistone@redhat.com> - 1.33.0-1
8931a1
- Update to 1.33.0.
8931a1
8931a1
* Tue Apr 09 2019 Josh Stone <jistone@redhat.com> - 1.32.0-1
8931a1
- Update to 1.32.0.
8931a1
8931a1
* Fri Dec 14 2018 Josh Stone <jistone@redhat.com> - 1.31.0-5
8931a1
- Restore rust-lldb.
8931a1
8931a1
* Thu Dec 13 2018 Josh Stone <jistone@redhat.com> - 1.31.0-4
8931a1
- Backport fixes for rls.
8931a1
8931a1
* Thu Dec 13 2018 Josh Stone <jistone@redhat.com> - 1.31.0-3
8931a1
- Update to 1.31.0 -- Rust 2018!
8931a1
- clippy/rls/rustfmt are no longer -preview
8931a1
8931a1
* Wed Dec 12 2018 Josh Stone <jistone@redhat.com> - 1.30.1-2
8931a1
- Update to 1.30.1.
8931a1
8931a1
* Tue Nov 06 2018 Josh Stone <jistone@redhat.com> - 1.29.2-1
8931a1
- Update to 1.29.2.
8931a1
8931a1
* Thu Nov 01 2018 Josh Stone <jistone@redhat.com> - 1.28.0-1
8931a1
- Update to 1.28.0.
8931a1
8931a1
* Thu Nov 01 2018 Josh Stone <jistone@redhat.com> - 1.27.2-1
8931a1
- Update to 1.27.2.
8931a1
8931a1
* Wed Oct 10 2018 Josh Stone <jistone@redhat.com> - 1.26.2-12
8931a1
- Fix "fp" target feature for AArch64 (#1632880)
8931a1
8931a1
* Mon Oct 08 2018 Josh Stone <jistone@redhat.com> - 1.26.2-11
8931a1
- Security fix for str::repeat (pending CVE).
8931a1
8931a1
* Fri Oct 05 2018 Josh Stone <jistone@redhat.com> - 1.26.2-10
8931a1
- Rebuild without bootstrap binaries.
8931a1
8931a1
* Thu Oct 04 2018 Josh Stone <jistone@redhat.com> - 1.26.2-9
8931a1
- Bootstrap without SCL packaging. (rhbz1635067)
8931a1
8931a1
* Tue Aug 28 2018 Tom Stellard <tstellar@redhat.com> - 1.26.2-8
8931a1
- Use python3 prefix for lldb Requires
8931a1
8931a1
* Mon Aug 13 2018 Josh Stone <jistone@redhat.com> - 1.26.2-7
8931a1
- Build with platform-python
8931a1
8931a1
* Tue Aug 07 2018 Josh Stone <jistone@redhat.com> - 1.26.2-6
8931a1
- Exclude rust-src from auto-requires
8931a1
8931a1
* Thu Aug 02 2018 Josh Stone <jistone@redhat.com> - 1.26.2-5
8931a1
- Rebuild without bootstrap binaries.
8931a1
8931a1
* Tue Jul 31 2018 Josh Stone <jistone@redhat.com> - 1.26.2-4
8931a1
- Bootstrap as a module.
8931a1
8931a1
* Mon Jun 04 2018 Josh Stone <jistone@redhat.com> - 1.26.2-3
8931a1
- Update to 1.26.2.
8931a1
8931a1
* Wed May 30 2018 Josh Stone <jistone@redhat.com> - 1.26.1-2
8931a1
- Update to 1.26.1.
8931a1
8931a1
* Fri May 18 2018 Josh Stone <jistone@redhat.com> - 1.26.0-1
8931a1
- Update to 1.26.0.
8931a1
8931a1
* Tue Apr 10 2018 Josh Stone <jistone@redhat.com> - 1.25.0-2
8931a1
- Filter codegen-backends from Provides too.
8931a1
8931a1
* Tue Apr 03 2018 Josh Stone <jistone@redhat.com> - 1.25.0-1
8931a1
- Update to 1.25.0.
8931a1
- Add rustfmt-preview as a subpackage.
8931a1
8931a1
* Thu Feb 22 2018 Josh Stone <jistone@redhat.com> - 1.24.0-1
8931a1
- Update to 1.24.0.
8931a1
8931a1
* Tue Jan 16 2018 Josh Stone <jistone@redhat.com> - 1.23.0-2
8931a1
- Rebuild without bootstrap binaries.
8931a1
8931a1
* Mon Jan 15 2018 Josh Stone <jistone@redhat.com> - 1.23.0-1
8931a1
- Bootstrap 1.23 on el8.