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