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