rustc/PKGBUILD
2024-08-13 16:25:01 +08:00

116 lines
3.5 KiB
Bash

# This is an example PKGBUILD file. Use this as a start to creating your own,
# and remove these comments. For more information, see 'man PKGBUILD'.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.
# Maintainer: Future Linux Team <future_linux@163.com>
pkgname=rustc
pkgver=1.80.0
pkgrel=1
pkgdesc="Systems programming language focused on safety, speed and concurrency"
arch=('x86_64')
url="https://blog.rust-lang.org/"
license=('Apache-2.0 OR MIT')
depends=('gcc' 'gcc-libs' 'bash' 'curl' 'libssh2' 'zlib' 'llvm-libs')
makedepends=('cmake' 'libffi' 'perl' 'python' 'ninja' 'llvm' 'clang' 'lld')
options=('!emptydirs' '!lto')
source=(https://static.rust-lang.org/dist/${pkgname}-${pkgver}-src.tar.xz)
sha256sums=(0b9ca1e2e45b8a5f0b58db140af0dc92f8311faeb0ad883c5b71a72c02dc6e80)
prepare() {
cd ${pkgname}-${pkgver}-src
cat << EOF > config.toml
# see config.toml.example for more possible options
# See the 8.4 book for an old example using shipped LLVM
# e.g. if not installing clang, or using a version before 13.0
# Tell x.py the editors have reviewed the content of this file
# and updated it to follow the major changes of the building system,
# so x.py will not warn us to do such a review.
change-id = 102579
[llvm]
# by default, rust will build for a myriad of architectures
targets = "X86"
# When using system llvm prefer shared libraries
link-shared = true
[build]
# omit docs to save time and space (default is to build them)
docs = false
python = "python3"
# install extended tools: cargo, clippy, etc
extended = true
# Do not query new versions of dependencies online.
locked-deps = true
# Specify which extended tools (those from the default install).
tools = ["cargo", "clippy", "rustdoc", "rustfmt"]
# Use the source code shipped in the tarball for the dependencies.
# The combination of this and the "locked-deps" entry avoids downloading
# many crates from Internet, and makes the Rustc build more stable.
vendor = true
[install]
prefix = "/usr"
libdir = "/usr/lib64"
docdir = "share/doc/rustc-${pkgver}"
[rust]
channel = "stable"
description = "Future Linux ${pkgname} ${pkgver}-${pkgrel}"
# BLFS used to not install the FileCheck executable from llvm,
# so disabled codegen tests. The assembly tests rely on FileCheck
# and cannot easily be disabled, so those will anyway fail if
# FileCheck has not been installed.
#codegen-tests = false
# Enable the same optimizations as the official upstream build.
lto = "thin"
codegen-units = 1
[target.x86_64-unknown-linux-gnu]
# NB the output of llvm-config (i.e. help options) may be
# dumped to the screen when config.toml is parsed.
llvm-config = "/usr/bin/llvm-config"
cc = "/usr/bin/x86_64-future-linux-gnu-gcc"
cxx = "/usr/bin/x86_64-future-linux-gnu-g++"
ar = "/usr/bin/x86_64-future-linux-gnu-gcc-ar"
ranlib = "/usr/bin/x86_64-future-linux-gnu-gcc-ranlib"
EOF
}
build() {
cd ${pkgname}-${pkgver}-src
export RUST_BACKTRACE=1
{ [ ! -e /usr/include/libssh2.h ] || export LIBSSH2_SYS_USE_PKG_CONFIG=1; }
{ [ ! -e /usr/include/sqlite3.h ] || export LIBSQLITE3_SYS_USE_PKG_CONFIG=1; }
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
python3 x.py build -j "$(nproc)"
}
package() {
cd ${pkgname}-${pkgver}-src
DESTDIR=${pkgdir} python3 x.py install rustc std
DESTDIR=${pkgdir} python3 x.py install --stage=1 cargo clippy rustfmt
rm -fv ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/*.old
install -vm644 README.md ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
unset LIB{SSH2,SQLITE3}_SYS_USE_PKG_CONFIG
}