c3f84f
# Only x86_64 and i686 are Tier 1 platforms at this time.
c3f84f
# https://forge.rust-lang.org/platform-support.html
Pablo Greco 4e2d68
%global rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x
Pablo Greco 4e2d68
#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.
Pablo Greco a46c97
%global bootstrap_rust 1.44.0
Pablo Greco a46c97
%global bootstrap_cargo 1.44.0
Pablo Greco a46c97
%global bootstrap_channel 1.44.0
Pablo Greco a46c97
%global bootstrap_date 2020-06-04
c3f84f
c3f84f
# Only the specified arches will use bootstrap binaries.
Pablo Greco 4e2d68
%global bootstrap_arches armv7hl
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
Pablo Greco a46c97
# is insufficient.  Rust currently requires LLVM 8.0+.
c3f84f
%if 0%{?rhel} && 0%{?rhel} <= 6 && !0%{?epel}
c3f84f
%bcond_without bundled_llvm
c3f84f
%else
c3f84f
%bcond_with bundled_llvm
c3f84f
%endif
c3f84f
c3f84f
# libgit2-sys expects to use its bundled library, which is sometimes just a
c3f84f
# snapshot of libgit2's master branch.  This can mean the FFI declarations
c3f84f
# won't match our released libgit2.so, e.g. having changed struct fields.
c3f84f
# So, tread carefully if you toggle this...
c3f84f
%bcond_without bundled_libgit2
c3f84f
c3f84f
%if 0%{?rhel}
Pablo Greco a46c97
%bcond_without disabled_libssh2
c3f84f
%else
c3f84f
%bcond_with bundled_libssh2
c3f84f
%endif
c3f84f
c3f84f
# LLDB isn't available everywhere...
c3f84f
%if !0%{?rhel} || 0%{?rhel} > 7
c3f84f
%bcond_without lldb
c3f84f
%else
c3f84f
%bcond_with lldb
c3f84f
%endif
c3f84f
c3f84f
Name:           rust
Pablo Greco a46c97
Version:        1.45.0
Pablo Greco a46c97
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"
Pablo Greco 3f2336
%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
Pablo Greco a46c97
# Disable cargo->libgit2->libssh2, as it's not approved for FIPS (rhbz1732949)
Pablo Greco a46c97
Patch10:        rustc-1.42.0-disable-libssh2.patch
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"
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}
c3f84f
%if 0%{?fedora} >= 27 || 0%{?rhel} > 7
Pablo Greco 3f2336
BuildRequires:  (%{name} >= %{bootstrap_rust} with %{name} <= %{version})
c3f84f
%else
c3f84f
BuildRequires:  %{name} >= %{bootstrap_rust}
Pablo Greco 3f2336
BuildConflicts: %{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
c3f84f
BuildRequires:  pkgconfig(libcurl)
c3f84f
BuildRequires:  pkgconfig(liblzma)
c3f84f
BuildRequires:  pkgconfig(openssl)
c3f84f
BuildRequires:  pkgconfig(zlib)
c3f84f
c3f84f
%if %without bundled_libgit2
Pablo Greco a46c97
BuildRequires:  pkgconfig(libgit2) >= 1.0.0
c3f84f
%endif
c3f84f
Pablo Greco a46c97
%if %{without disabled_libssh2} && %{without bundled_libssh2}
c3f84f
# needs libssh2_userauth_publickey_frommemory
c3f84f
BuildRequires:  pkgconfig(libssh2) >= 1.6.0
c3f84f
%endif
c3f84f
c3f84f
%if 0%{?rhel}
c3f84f
%if 0%{?rhel} <= 7
c3f84f
%global python python2
c3f84f
%else
c3f84f
%global python /usr/libexec/platform-python
c3f84f
%endif
c3f84f
%else
c3f84f
%global python python3
c3f84f
%endif
c3f84f
BuildRequires:  %{python}
c3f84f
c3f84f
%if %with bundled_llvm
c3f84f
BuildRequires:  cmake3 >= 3.4.3
Pablo Greco a46c97
Provides:       bundled(llvm) = 10.0.1
c3f84f
%else
c3f84f
BuildRequires:  cmake >= 2.8.11
c3f84f
%if 0%{?epel}
Pablo Greco a46c97
%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
Pablo Greco a46c97
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
# TODO: work on unbundling these!
Pablo Greco a46c97
Provides:       bundled(libbacktrace) = 1.0.20200219
c3f84f
c3f84f
# Virtual provides for folks who attempt "dnf install rustc"
Pablo Greco 3f2336
Provides:       rustc = %{version}-%{release}
Pablo Greco 3f2336
Provides:       rustc%{?_isa} = %{version}-%{release}
c3f84f
c3f84f
# Always require our exact standard library
Pablo Greco 3f2336
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
c3f84f
# support custom-derive plugins like #[proc_macro_derive(Foo)].  But eu-strip is
c3f84f
# very eager by default, so we have to limit it to -g, only debugging symbols.
c3f84f
%if 0%{?fedora} >= 27 || 0%{?rhel} > 7
c3f84f
# Newer find-debuginfo.sh supports --keep-section, which is preferable. rhbz1465997
c3f84f
%global _find_debuginfo_opts --keep-section .rustc
c3f84f
%else
c3f84f
%global _find_debuginfo_opts -g
c3f84f
%undefine _include_minidebuginfo
c3f84f
%endif
c3f84f
c3f84f
# Use hardening ldflags.
c3f84f
%global rustflags -Clink-arg=-Wl,-z,relro,-z,now
c3f84f
c3f84f
%if %{without bundled_llvm}
Pablo Greco 3f2336
%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
Pablo Greco 3f2336
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
Pablo Greco a46c97
BuildArch:      noarch
c3f84f
Requires:       lldb
Pablo Greco a46c97
%if 0%{?fedora} >= 31 || 0%{?rhel} > 7
c3f84f
Requires:       python3-lldb
Pablo Greco a46c97
%else
Pablo Greco a46c97
Requires:       python2-lldb
Pablo Greco a46c97
%endif
Pablo Greco 3f2336
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
Pablo Greco a46c97
Provides:       bundled(libgit2) = 1.0.0
c3f84f
%endif
c3f84f
%if %with bundled_libssh2
Pablo Greco a46c97
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
Pablo Greco a46c97
# "cargo vendor" is a builtin command starting with 1.37.  The Obsoletes and
Pablo Greco a46c97
# Provides are mostly relevant to RHEL, but harmless to have on Fedora/etc. too
Pablo Greco a46c97
Obsoletes:      cargo-vendor <= 0.1.23
Pablo Greco a46c97
Provides:       cargo-vendor = %{version}-%{release}
Pablo Greco a46c97
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
Pablo Greco 3f2336
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
Pablo Greco 3f2336
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
Pablo Greco a46c97
Provides:       bundled(libgit2) = 1.0.0
c3f84f
%endif
c3f84f
%if %with bundled_libssh2
Pablo Greco a46c97
Provides:       bundled(libssh2) = 1.9.0~dev
c3f84f
%endif
c3f84f
Requires:       rust-analysis
c3f84f
# /usr/bin/rls is dynamically linked against internal rustc libs
Pablo Greco 3f2336
Requires:       %{name}%{?_isa} = %{version}-%{release}
c3f84f
c3f84f
# The component/package was rls-preview until Rust 1.31.
c3f84f
Obsoletes:      rls-preview < 1.31.6
Pablo Greco 3f2336
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
Pablo Greco 3f2336
Requires:       %{name}%{?_isa} = %{version}-%{release}
c3f84f
c3f84f
# The component/package was clippy-preview until Rust 1.31.
c3f84f
Obsoletes:      clippy-preview <= 0.0.212
Pablo Greco 3f2336
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
Pablo Greco 3f2336
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
Pablo Greco a46c97
%if %with disabled_libssh2
Pablo Greco a46c97
%patch10 -p1
Pablo Greco a46c97
%endif
c3f84f
c3f84f
%if "%{python}" != "python2"
c3f84f
sed -i.try-py3 -e '/try python2.7/i try %{python} "$@"' ./configure
c3f84f
%endif
c3f84f
c3f84f
%if %without bundled_llvm
Pablo Greco 3f2336
rm -rf src/llvm-project/
c3f84f
%endif
c3f84f
Pablo Greco a46c97
# Remove other unused vendored libraries
Pablo Greco a46c97
rm -rf vendor/curl-sys/curl/
Pablo Greco a46c97
rm -rf vendor/jemalloc-sys/jemalloc/
Pablo Greco a46c97
rm -rf vendor/libz-sys/src/zlib/
Pablo Greco a46c97
rm -rf vendor/lzma-sys/xz-*/
Pablo Greco a46c97
rm -rf vendor/openssl-src/openssl/
Pablo Greco a46c97
Pablo Greco a46c97
%if %without bundled_libgit2
Pablo Greco a46c97
rm -rf vendor/libgit2-sys/libgit2/
Pablo Greco a46c97
%endif
Pablo Greco a46c97
Pablo Greco a46c97
%if %without bundled_libssh2
Pablo Greco a46c97
rm -rf vendor/libssh2-sys/libssh2/
Pablo Greco a46c97
%endif
Pablo Greco a46c97
%if %with disabled_libssh2
Pablo Greco a46c97
rm -rf vendor/libssh2-sys/
Pablo Greco a46c97
%endif
Pablo Greco a46c97
Pablo Greco a46c97
# This only affects the transient rust-installer, but let it use our dynamic xz-libs
Pablo Greco a46c97
sed -i.lzma -e '/LZMA_API_STATIC/d' src/bootstrap/tool.rs
c3f84f
Pablo Greco 3f2336
# rename bundled license for packaging
Pablo Greco 3f2336
cp -a vendor/backtrace-sys/src/libbacktrace/LICENSE{,-libbacktrace}
c3f84f
c3f84f
%if %{with bundled_llvm} && 0%{?epel}
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.
Pablo Greco 3f2336
find vendor -name .cargo-checksum.json \
c3f84f
  -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
c3f84f
Pablo Greco a46c97
# Sometimes Rust sources start with #![...] attributes, and "smart" editors think
Pablo Greco a46c97
# it's a shebang and make them executable. Then brp-mangle-shebangs gets upset...
Pablo Greco a46c97
find -name '*.rs' -type f -perm /111 -exec chmod -v -x '{}' '+'
Pablo Greco a46c97
c3f84f
c3f84f
%build
Pablo Greco a46c97
# This package fails to build with LTO due to undefined symbols.  LTO
Pablo Greco a46c97
# was disabled in OpenSuSE as well, but with no real explanation why
Pablo Greco a46c97
# beyond the undefined symbols.  It really should be investigated further.
Pablo Greco a46c97
# Disable LTO
Pablo Greco a46c97
%define _lto_cflags %{nil}
c3f84f
c3f84f
%if %without bundled_libgit2
c3f84f
# convince libgit2-sys to use the distro libgit2
c3f84f
export LIBGIT2_SYS_USE_PKG_CONFIG=1
c3f84f
%endif
c3f84f
c3f84f
%if %without bundled_libssh2
c3f84f
# convince libssh2-sys to use the distro libssh2
c3f84f
export LIBSSH2_SYS_USE_PKG_CONFIG=1
c3f84f
%endif
c3f84f
c3f84f
%{?cmake_path:export PATH=%{cmake_path}:$PATH}
c3f84f
%{?rustflags:export RUSTFLAGS="%{rustflags}"}
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
Pablo Greco 3f2336
%ifarch %{arm} %{ix86} s390x
c3f84f
# full debuginfo is exhausting memory; just do libstd for now
c3f84f
# https://github.com/rust-lang/rust/issues/45854
c3f84f
%if (0%{?fedora} && 0%{?fedora} < 27) || (0%{?rhel} && 0%{?rhel} <= 7)
c3f84f
# Older rpmbuild didn't work with partial debuginfo coverage.
c3f84f
%global debug_package %{nil}
Pablo Greco a46c97
%define enable_debuginfo --debuginfo-level=0
c3f84f
%else
Pablo Greco a46c97
%define enable_debuginfo --debuginfo-level=0 --debuginfo-level-std=2
c3f84f
%endif
c3f84f
%else
Pablo Greco a46c97
%define enable_debuginfo --debuginfo-level=2
c3f84f
%endif
c3f84f
Pablo Greco 3f2336
# We want the best optimization for std, but it caused problems for rpm-ostree
Pablo Greco 3f2336
# on ppc64le to have all of the compiler_builtins in a single object:
Pablo Greco 3f2336
# https://bugzilla.redhat.com/show_bug.cgi?id=1713090
Pablo Greco 3f2336
%ifnarch %{power64}
Pablo Greco 3f2336
%define codegen_units_std --set rust.codegen-units-std=1
Pablo Greco 3f2336
%endif
Pablo Greco 3f2336
Pablo Greco a46c97
# Some builders have relatively little memory for their CPU count.
Pablo Greco a46c97
# At least 2GB per CPU is a good rule of thumb for building rustc.
Pablo Greco a46c97
ncpus=$(/usr/bin/getconf _NPROCESSORS_ONLN)
Pablo Greco a46c97
max_cpus=$(( ($(free -g | awk '/^Mem:/{print $2}') + 1) / 2 ))
Pablo Greco a46c97
if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then
Pablo Greco a46c97
  ncpus="$max_cpus"
Pablo Greco a46c97
fi
Pablo Greco a46c97
c3f84f
%configure --disable-option-checking \
c3f84f
  --libdir=%{common_libdir} \
c3f84f
  --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
Pablo Greco a46c97
  --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 \
Pablo Greco a46c97
  --tools=analysis,cargo,clippy,rls,rustfmt,src \
c3f84f
  --enable-vendor \
c3f84f
  --enable-verbose-tests \
Pablo Greco 3f2336
  %{?codegen_units_std} \
c3f84f
  --release-channel=%{channel}
c3f84f
Pablo Greco a46c97
%{python} ./x.py build -j "$ncpus"
c3f84f
%{python} ./x.py doc
c3f84f
c3f84f
c3f84f
%install
c3f84f
%{?cmake_path:export PATH=%{cmake_path}:$PATH}
c3f84f
%{?rustflags:export RUSTFLAGS="%{rustflags}"}
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
Pablo Greco a46c97
   if [ -f "${lib##*/}" ]; then
Pablo Greco a46c97
     # make sure they're actually identical!
Pablo Greco a46c97
     cmp "$lib" "${lib##*/}"
Pablo Greco a46c97
     ln -v -f -s -t . "$lib"
Pablo Greco a46c97
   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
c3f84f
rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
c3f84f
%endif
c3f84f
c3f84f
c3f84f
%check
c3f84f
%{?cmake_path:export PATH=%{cmake_path}:$PATH}
c3f84f
%{?rustflags:export RUSTFLAGS="%{rustflags}"}
c3f84f
c3f84f
# The results are not stable on koji, so mask errors and just log it.
c3f84f
%{python} ./x.py test --no-fail-fast || :
c3f84f
%{python} ./x.py test --no-fail-fast cargo || :
c3f84f
%{python} ./x.py test --no-fail-fast clippy || :
c3f84f
%{python} ./x.py test --no-fail-fast rls || :
c3f84f
%{python} ./x.py test --no-fail-fast rustfmt || :
c3f84f
c3f84f
c3f84f
%ldconfig_scriptlets
c3f84f
c3f84f
c3f84f
%files
c3f84f
%license COPYRIGHT LICENSE-APACHE LICENSE-MIT
Pablo Greco 3f2336
%license vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
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
c3f84f
%{rustlibdir}/etc/debugger_*.py*
c3f84f
c3f84f
c3f84f
%files gdb
c3f84f
%{_bindir}/rust-gdb
c3f84f
%{rustlibdir}/etc/gdb_*.py*
Pablo Greco 3f2336
%exclude %{_bindir}/rust-gdbgui
c3f84f
c3f84f
c3f84f
%if %with lldb
c3f84f
%files lldb
c3f84f
%{_bindir}/rust-lldb
c3f84f
%{rustlibdir}/etc/lldb_*.py*
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
Pablo Greco 3f2336
%{_docdir}/%{name}/html/*.ico
c3f84f
%{_docdir}/%{name}/html/*.js
Pablo Greco 3f2336
%{_docdir}/%{name}/html/*.png
c3f84f
%{_docdir}/%{name}/html/*.svg
c3f84f
%{_docdir}/%{name}/html/*.woff
c3f84f
%license %{_docdir}/%{name}/html/*.txt
Pablo Greco a46c97
%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
Pablo Greco a46c97
* Thu Jul 16 2020 Josh Stone <jistone@redhat.com> - 1.45.0-1
Pablo Greco a46c97
- Update to 1.45.0.
Pablo Greco a46c97
Pablo Greco a46c97
* Tue Jul 14 2020 Josh Stone <jistone@redhat.com> - 1.44.1-1
Pablo Greco a46c97
- Update to 1.44.1.
Pablo Greco a46c97
Pablo Greco a46c97
* Thu May 07 2020 Josh Stone <jistone@redhat.com> - 1.43.1-1
Pablo Greco a46c97
- Update to 1.43.1.
Pablo Greco a46c97
Pablo Greco a46c97
* Thu Apr 23 2020 Josh Stone <jistone@redhat.com> - 1.43.0-1
Pablo Greco a46c97
- Update to 1.43.0.
Pablo Greco a46c97
Pablo Greco a46c97
* Thu Mar 12 2020 Josh Stone <jistone@redhat.com> - 1.42.0-1
Pablo Greco a46c97
- Update to 1.42.0.
Pablo Greco a46c97
Pablo Greco a46c97
* Thu Feb 27 2020 Josh Stone <jistone@redhat.com> - 1.41.1-1
Pablo Greco a46c97
- Update to 1.41.1.
Pablo Greco a46c97
Pablo Greco a46c97
* Thu Jan 30 2020 Josh Stone <jistone@redhat.com> - 1.41.0-1
Pablo Greco a46c97
- Update to 1.41.0.
Pablo Greco a46c97
Pablo Greco a46c97
* Thu Jan 16 2020 Josh Stone <jistone@redhat.com> - 1.40.0-1
Pablo Greco a46c97
- Update to 1.40.0.
Pablo Greco a46c97
- Fix compiletest with newer (local-rebuild) libtest
Pablo Greco a46c97
- Build compiletest with in-tree libtest
Pablo Greco a46c97
- Fix ARM EHABI unwinding
Pablo Greco a46c97
Pablo Greco a46c97
* Tue Nov 12 2019 Josh Stone <jistone@redhat.com> - 1.39.0-2
Pablo Greco a46c97
- Fix a couple build and test issues with rustdoc.
Pablo Greco a46c97
Pablo Greco a46c97
* Thu Nov 07 2019 Josh Stone <jistone@redhat.com> - 1.39.0-1
Pablo Greco a46c97
- Update to 1.39.0.
Pablo Greco a46c97
Pablo Greco a46c97
* Thu Sep 26 2019 Josh Stone <jistone@redhat.com> - 1.38.0-1
Pablo Greco a46c97
- Update to 1.38.0.
Pablo Greco a46c97
Pablo Greco a46c97
* Thu Aug 15 2019 Josh Stone <jistone@redhat.com> - 1.37.0-1
Pablo Greco a46c97
- Update to 1.37.0.
Pablo Greco a46c97
- Disable libssh2 (git+ssh support).
Pablo Greco a46c97
Pablo Greco a46c97
* Thu Jul 04 2019 Josh Stone <jistone@redhat.com> - 1.36.0-1
Pablo Greco a46c97
- Update to 1.36.0.
Pablo Greco a46c97
Pablo Greco 3f2336
* Wed May 29 2019 Josh Stone <jistone@redhat.com> - 1.35.0-2
Pablo Greco 3f2336
- Fix compiletest for rebuild testing.
Pablo Greco 3f2336
Pablo Greco 3f2336
* Thu May 23 2019 Josh Stone <jistone@redhat.com> - 1.35.0-1
Pablo Greco 3f2336
- Update to 1.35.0.
Pablo Greco 3f2336
Pablo Greco 3f2336
* Tue May 14 2019 Josh Stone <jistone@redhat.com> - 1.34.2-1
Pablo Greco 3f2336
- Update to 1.34.2 -- fixes CVE-2019-12083.
Pablo Greco 3f2336
Pablo Greco 3f2336
* Thu May 09 2019 Josh Stone <jistone@redhat.com> - 1.34.1-1
Pablo Greco 3f2336
- Update to 1.34.1.
Pablo Greco 3f2336
Pablo Greco 3f2336
* Thu Apr 11 2019 Josh Stone <jistone@redhat.com> - 1.34.0-1
Pablo Greco 3f2336
- Update to 1.34.0.
Pablo Greco 3f2336
Pablo Greco 3f2336
* Wed Apr 10 2019 Josh Stone <jistone@redhat.com> - 1.33.0-1
Pablo Greco 3f2336
- Update to 1.33.0.
Pablo Greco 3f2336
Pablo Greco 3f2336
* Tue Apr 09 2019 Josh Stone <jistone@redhat.com> - 1.32.0-1
Pablo Greco 3f2336
- Update to 1.32.0.
Pablo Greco 3f2336
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.