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
Pablo Greco 851ab9
%global rust_arches x86_64 i686 armv7hl 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.
c3f84f
%global bootstrap_rust 1.30.0
c3f84f
%global bootstrap_cargo 1.30.0
c3f84f
%global bootstrap_channel %{bootstrap_rust}
c3f84f
%global bootstrap_date 2018-10-25
c3f84f
c3f84f
# Only the specified arches will use bootstrap binaries.
c3f84f
#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
c3f84f
# is insufficient.  Rust currently requires LLVM 5.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}
c3f84f
%bcond_without bundled_libssh2
c3f84f
%else
c3f84f
%bcond_with bundled_libssh2
c3f84f
%endif
c3f84f
c3f84f
# LLDB only works on some architectures
c3f84f
%ifarch %{arm} aarch64 %{ix86} x86_64
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
%else
c3f84f
%bcond_with lldb
c3f84f
%endif
c3f84f
c3f84f
# Some sub-packages are versioned independently of the rust compiler and runtime itself.
c3f84f
# Also beware that if any of these are not changed in a version bump, then the release
c3f84f
# number should still increase, not be reset to 1!
c3f84f
%global rustc_version 1.31.0
c3f84f
%global cargo_version 1.31.0
c3f84f
%global rustfmt_version 1.0.0
c3f84f
%global rls_version 1.31.6
c3f84f
%global clippy_version 0.0.212
c3f84f
c3f84f
Name:           rust
c3f84f
Version:        %{rustc_version}
c3f84f
Release:        5%{?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"
c3f84f
%global rustc_package rustc-%{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
c3f84f
# https://github.com/rust-lang/rust/pull/56394
c3f84f
Patch1:         0001-Deal-with-EINTR-in-net-timeout-tests.patch
c3f84f
c3f84f
# https://github.com/rust-lang/rust/pull/55575
c3f84f
Patch2:         0001-Fix-invalid_const_promotion-test-on-some-archs.patch
c3f84f
c3f84f
# https://github.com/rust-lang/rls/issues/1171#issuecomment-445813148
c3f84f
# https://github.com/rust-dev-tools/rls-analysis/commit/23359b93e6accbe5f45e2fe2089db31955e4008e
c3f84f
# Only revert for Rust 1.31 -- the change was meant to go with 1.32 and later.
c3f84f
Patch3:         0001-Revert-Do-not-add-src-to-sysroot-crates-paths-they-a.patch
c3f84f
c3f84f
# https://github.com/rust-dev-tools/rls-analysis/pull/160
c3f84f
Patch4:         0001-Try-to-get-the-target-triple-from-rustc-itself.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
c3f84f
BuildRequires:  (%{name} >= %{bootstrap_rust} with %{name} <= %{rustc_version})
c3f84f
%else
c3f84f
BuildRequires:  %{name} >= %{bootstrap_rust}
c3f84f
BuildConflicts: %{name} > %{rustc_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
c3f84f
BuildRequires:  pkgconfig(libgit2) >= 0.27
c3f84f
%endif
c3f84f
c3f84f
%if %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
c3f84f
Provides:       bundled(llvm) = 8.0.0~svn
c3f84f
%else
c3f84f
BuildRequires:  cmake >= 2.8.11
c3f84f
%if 0%{?epel}
c3f84f
%global llvm llvm5.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
c3f84f
BuildRequires:  %{llvm}-devel >= 5.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!
c3f84f
Provides:       bundled(libbacktrace) = 8.1.0
c3f84f
Provides:       bundled(miniz) = 1.16~beta+r1
c3f84f
c3f84f
# Virtual provides for folks who attempt "dnf install rustc"
c3f84f
Provides:       rustc = %{rustc_version}-%{release}
c3f84f
Provides:       rustc%{?_isa} = %{rustc_version}-%{release}
c3f84f
c3f84f
# Always require our exact standard library
c3f84f
Requires:       %{name}-std-static%{?_isa} = %{rustc_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}
c3f84f
%if 0%{?fedora} || 0%{?rhel} > 7 || 0%{?scl:1}
c3f84f
%global llvm_has_filecheck 1
c3f84f
%endif
c3f84f
%if "%{llvm_root}" != "%{_prefix}"
c3f84f
# https://github.com/rust-lang/rust/issues/40717
c3f84f
%global library_path $(%{llvm_root}/bin/llvm-config --libdir)
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
c3f84f
Requires:       %{name}-debugger-common = %{rustc_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
c3f84f
c3f84f
# It could be noarch, but lldb has limited availability
c3f84f
#BuildArch:      noarch
c3f84f
c3f84f
Requires:       lldb
c3f84f
Requires:       python3-lldb
c3f84f
Requires:       %{name}-debugger-common = %{rustc_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
Version:        %{cargo_version}
c3f84f
%if %with bundled_libgit2
c3f84f
Provides:       bundled(libgit2) = 0.27
c3f84f
%endif
c3f84f
%if %with bundled_libssh2
c3f84f
Provides:       bundled(libssh2) = 1.8.1~dev
c3f84f
%endif
c3f84f
# For tests:
c3f84f
BuildRequires:  git
c3f84f
# Cargo is not much use without Rust
c3f84f
Requires:       rust
c3f84f
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
Version:        %{cargo_version}
c3f84f
BuildArch:      noarch
c3f84f
# Cargo no longer builds its own documentation
c3f84f
# https://github.com/rust-lang/cargo/pull/4904
c3f84f
Requires:       rust-doc = %{rustc_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
Version:        %{rustfmt_version}
c3f84f
Requires:       cargo
c3f84f
c3f84f
# The component/package was rustfmt-preview until Rust 1.31.
c3f84f
Obsoletes:      rustfmt-preview < 1.0.0
c3f84f
Provides:       rustfmt-preview = %{rustfmt_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
Version:        %{rls_version}
c3f84f
Provides:       rls = %{rls_version}
c3f84f
%if %with bundled_libgit2
c3f84f
Provides:       bundled(libgit2) = 0.27
c3f84f
%endif
c3f84f
%if %with bundled_libssh2
c3f84f
Provides:       bundled(libssh2) = 1.8.1~dev
c3f84f
%endif
c3f84f
Requires:       rust-analysis
c3f84f
# /usr/bin/rls is dynamically linked against internal rustc libs
c3f84f
Requires:       %{name}%{?_isa} = %{rustc_version}-%{release}
c3f84f
c3f84f
# The component/package was rls-preview until Rust 1.31.
c3f84f
Obsoletes:      rls-preview < 1.31.6
c3f84f
Provides:       rls-preview = %{rls_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
Version:        %{clippy_version}
c3f84f
Provides:       clippy = %{clippy_version}
c3f84f
Requires:       cargo
c3f84f
# /usr/bin/clippy-driver is dynamically linked against internal rustc libs
c3f84f
Requires:       %{name}%{?_isa} = %{rustc_version}-%{release}
c3f84f
c3f84f
# The component/package was clippy-preview until Rust 1.31.
c3f84f
Obsoletes:      clippy-preview <= 0.0.212
c3f84f
Provides:       clippy-preview = %{clippy_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
c3f84f
Requires:       rust-std-static%{?_isa} = %{rustc_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
c3f84f
%patch1 -p1
c3f84f
%patch2 -p1
c3f84f
c3f84f
pushd src/vendor/rls-analysis
c3f84f
%patch3 -p1
c3f84f
%patch4 -p1
c3f84f
popd
c3f84f
c3f84f
%if "%{python}" != "python2"
c3f84f
sed -i.try-py3 -e '/try python2.7/i try %{python} "$@"' ./configure
c3f84f
%endif
c3f84f
c3f84f
# We're disabling jemalloc, but rust-src still wants it.
c3f84f
# rm -rf src/jemalloc/
c3f84f
c3f84f
%if %without bundled_llvm
c3f84f
rm -rf src/llvm/
c3f84f
%endif
c3f84f
c3f84f
# We never enable emscripten.
c3f84f
rm -rf src/llvm-emscripten/
c3f84f
c3f84f
# We never enable other LLVM tools.
c3f84f
rm -rf src/tools/clang
c3f84f
rm -rf src/tools/lld
c3f84f
rm -rf src/tools/lldb
c3f84f
c3f84f
# extract bundled licenses for packaging
c3f84f
sed -e '/*\//q' src/libbacktrace/backtrace.h \
c3f84f
  >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.
c3f84f
find src/vendor -name .cargo-checksum.json \
c3f84f
  -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
c3f84f
c3f84f
c3f84f
%build
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
%{?library_path:export LIBRARY_PATH="%{library_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
c3f84f
%ifarch %{arm} %{ix86}
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}
c3f84f
%define enable_debuginfo --disable-debuginfo --disable-debuginfo-only-std --disable-debuginfo-tools --disable-debuginfo-lines
c3f84f
%else
c3f84f
%define enable_debuginfo --enable-debuginfo --enable-debuginfo-only-std --disable-debuginfo-tools --disable-debuginfo-lines
c3f84f
%endif
c3f84f
%else
c3f84f
%define enable_debuginfo --enable-debuginfo --disable-debuginfo-only-std --enable-debuginfo-tools --disable-debuginfo-lines
c3f84f
%endif
c3f84f
c3f84f
%configure --disable-option-checking \
c3f84f
  --libdir=%{common_libdir} \
c3f84f
  --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
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-jemalloc \
c3f84f
  --disable-rpath \
c3f84f
  %{enable_debuginfo} \
c3f84f
  --enable-extended \
c3f84f
  --enable-vendor \
c3f84f
  --enable-verbose-tests \
c3f84f
  --release-channel=%{channel}
c3f84f
c3f84f
%{python} ./x.py build
c3f84f
%{python} ./x.py doc
c3f84f
c3f84f
c3f84f
%install
c3f84f
%{?cmake_path:export PATH=%{cmake_path}:$PATH}
c3f84f
%{?library_path:export LIBRARY_PATH="%{library_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
c3f84f
   # make sure they're actually identical!
c3f84f
   cmp "$lib" "${lib##*/}"
c3f84f
   ln -v -f -s -t . "$lib"
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
%{?library_path:export LIBRARY_PATH="%{library_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
c3f84f
%license 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
%{rustlibdir}/%{rust_triple}/codegen-backends/
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*
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
c3f84f
%{_docdir}/%{name}/html/*.js
c3f84f
%{_docdir}/%{name}/html/*.svg
c3f84f
%{_docdir}/%{name}/html/*.woff
c3f84f
%license %{_docdir}/%{name}/html/*.txt
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
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.