File rustc.spec of Package rustc
%define realname rustc
%define realver 1.68.0
%define srcext tar.xz
# Use downloaded Rust snapshot or previously built version from repository
%bcond_without stage0
# See src/stage0.txt
# or
# https://github.com/rust-lang/rust/blob/%{realver}/src/stage0.json
%define stage0_date 2023-02-09
%define stage0_version 1.67.1
%define stage0_cargo_ver %{stage0_version}
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
# Common info
Name: %{realname}
Version: %{realver}
Release: %{?extraver:0.}1%{?dist}
License: Apache-2.0 and MIT
Group: Programming/Languages/Rust
URL: http://www.rust-lang.org/
Summary: Compiler for the Rust Programming Language
# Install-time parameters
Provides: rust = %{version}-%{release}
Provides: librust = %{version}-%{release}
Provides: rust-libs = %{version}-%{release}
Obsoletes: rust < %{version}-%{release}
# Build-time parameters
BuildRequires: gcc-c++
BuildRequires: python3
BuildRequires: pkg-config
BuildRequires: pkgconfig(libsecret-1)
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(liblzma)
BuildRequires: pkgconfig(libssh2)
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(libgit2)
%if %{without stage0}
BuildRequires: %{realname}
%endif
BuildRequires: libc++-devel
BuildRequires: llvm-devel
# Next requirements needed for llvm-devel
BuildRequires: ncurses-devel zlib-devel
Source0: https://static.rust-lang.org/dist/%{realname}-%{realver}%{?extraver}-src.%{srcext}
%if %{with stage0}
Source11: https://static.rust-lang.org/dist/%{stage0_date}/rust-std-%{stage0_version}-x86_64-unknown-linux-gnu.tar.xz
Source12: https://static.rust-lang.org/dist/%{stage0_date}/rustc-%{stage0_version}-x86_64-unknown-linux-gnu.tar.xz
Source21: https://static.rust-lang.org/dist/%{stage0_date}/cargo-%{stage0_cargo_ver}-x86_64-unknown-linux-gnu.tar.xz
%endif
%description
Rust is a fast systems programming language that guarantees memory safety and
offers painless concurrency (no data races). It does not employ a garbage
collector and has minimal runtime overhead.
This package contains the compiler (rustc), as well as standard libraries, tools
and documentation for Rust.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}-src
%{__rm} -rf src/llvm
%{__install} -d -m755 build/cache/%{stage0_date}
mv .cargo build/
%if %{with stage0}
%{__install} -m644 %{S:11} build/cache/%{stage0_date}
%{__install} -m644 %{S:12} build/cache/%{stage0_date}
%{__install} -m644 %{S:21} build/cache/%{stage0_date}
%endif
%build
export CARGO_HOME=$(pwd -P)/.cargo-cache
export CARGO_NET_OFFLINE=true
export RUSTFLAGS='-C opt-level=2 -C strip=symbols'
./configure \
%if %{without stage0}
--enable-local-rust \
%endif
--enable-llvm-link-shared \
--enable-vendor \
--prefix=%{_prefix} \
--libdir=%{_libdir} \
--llvm-root=%{_prefix} \
--release-channel=stable
%{__ln_s} build/.cargo
python3 ./x.py build -v %{?_smp_mflags}
%install
python3 ./x.py install -v --root %{buildroot}
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%licanse LICENSE-* COPYRIGHT
%doc README.md RELEASES.md
%{_bindir}/*
%{_libdir}/*.so
%dir %{_prefix}/lib/rustlib/etc
%dir %{_prefix}/lib/rustlib/*-unknown-linux-gnu/lib
%dir %{_prefix}/lib/rustlib/*-unknown-linux-gnu
%dir %{_prefix}/lib/rustlib
%{_prefix}/lib/rustlib/etc/*.py
%{_prefix}/lib/rustlib/*-unknown-linux-gnu/lib/*
%exclude %{_prefix}/lib/rustlib/components
%exclude %{_prefix}/lib/rustlib/install.log
%exclude %{_prefix}/lib/rustlib/manifest-*
%exclude %{_prefix}/lib/rustlib/rust-installer-version
%exclude %{_prefix}/lib/rustlib/uninstall.sh
%doc %{_mandir}/man1/*
%changelog