packages/rust/PKGBUILD
2024-09-07 09:03:25 +02:00

236 lines
5.6 KiB
Bash

# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Johannes Löthberg <johannes@kyriasis.com>
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Alexander F Rødseth <xyproto@archlinux.org>
# Contributor: Daniel Micay <danielmicay@gmail.com>
# Contributor: userwithuid <userwithuid@gmail.com>
pkgbase=rust
pkgname=(
rust
rust-src
)
epoch=1
pkgver=1.81.0
pkgrel=1
pkgdesc="Systems programming language focused on safety, speed and concurrency"
url=https://www.rust-lang.org/
arch=(powerpc64le powerpc64 powerpc riscv64)
license=("Apache-2.0 OR MIT")
options=(
!emptydirs
!lto
)
[ "${CARCH}" == 'powerpc' ] && options+=(!debug)
depends=(
curl
gcc
gcc-libs
libssh2
llvm-libs
)
makedepends=(
cmake
libffi
lld
llvm
ninja
perl
python
rust
wasi-libc
)
checkdepends=(
gdb
procps-ng
)
source=(
"https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz"{,.asc}
0001-bootstrap-Change-libexec-dir.patch
0002-bootstrap-Change-bash-completion-dir.patch
0003-compiler-Change-LLVM-targets.patch
xxxx-Use-ELFv2-ABI-on-all-powerpc64-targets.patch
)
b2sums=('0bc0ae9207306458c6721ddaff0bf56280a4ca4918502b44cfdfc200e73c4a5af88c95f9df53c1fe927f94ffe09d855e21dd6a749331041d719704dc209940ba'
'SKIP'
'ef56a70741bae70a95695b4d05d1a6395f545e671c9d016c7180732f69a09b828ff5e16964ef16f9ebec55dd778a1b50927275cd4c21a7b78ae4959946a0657c'
'd20861a8a8e16d4bb0143f00d4beb42e2c52eeb2c1894e9f9c04e3d74ecd750d9bdacf15bb39fd0ade4487b9d3d14da24cf5f25ceab112f096fddcd329320a15'
'64391cf17e7d801fb263e9d637928c3a2f6aa11aca6afbf115be4e38e9afce42371ed4884929cf11d6c74c2aa497fb26abbba1812d4f31f44dcda38e4978a33f'
'a12ab3f62987d3de257ef4bb66220559efe46c92f0d9820390ed36bf404c56f05253619b5c46e37b44dc30386f54ef3c856124a1cc1a8b854b7f6426183b2d6d')
validpgpkeys=(
108F66205EAEB0AAA8DD5E1C85AB96E6FA1BE5FE # Rust Language (Tag and Release Signing Key) <rust-key@rust-lang.org>
)
prepare() {
cd rustc-$pkgver-src
# Patch bootstrap so that rust-analyzer-proc-macro-srv
# is in /usr/lib instead of /usr/libexec
patch -Np1 -i ../0001-bootstrap-Change-libexec-dir.patch
# Put bash completions where they belong
patch -Np1 -i ../0002-bootstrap-Change-bash-completion-dir.patch
# Use our *-pc-linux-gnu targets, making LTO with clang simpler
patch -Np1 -i ../0003-compiler-Change-LLVM-targets.patch
# Ensure powerpc64 uses ELFv2
patch -Np1 -i ../xxxx-Use-ELFv2-ABI-on-all-powerpc64-targets.patch
_rust_target="\"${CHOST}\""
case "${CARCH}" in
powerpc)
# fails to link with -O3 due to 32bit related relocation problems
export RUSTFLAGS="-C opt-level=1"
;;
riscv64)
_rust_target='"riscv64gc-unknown-linux-gnu"'
;;
esac
cat >config.toml <<END
profile = "user"
change-id = 123711
[llvm]
link-shared = true
[build]
target = [
${_rust_target}
]
cargo = "/usr/bin/cargo"
rustc = "/usr/bin/rustc"
rustfmt = "/usr/bin/rustfmt"
locked-deps = true
vendor = true
tools = [
"cargo",
"clippy",
"rustdoc",
"rustfmt",
"rust-analyzer-proc-macro-srv",
"analysis",
"src",
"rust-demangler",
]
sanitizers = true
profiler = true
# Generating docs fails with the wasm32-* targets
docs = false
[install]
prefix = "/usr"
[rust]
debuginfo-level = 1
debuginfo-level-std = 2
channel = "stable"
description = "Arch POWER $pkgbase $epoch:$pkgver-$pkgrel"
rpath = false
frame-pointers = true
backtrace-on-ice = true
jemalloc = true
# Causes "error: --remap-path-prefix must contain '=' between FROM and TO"
# even after creating the missing ~/.cargo/registry/src dir.
# https://github.com/rust-lang/rust/issues/117885
remap-debuginfo = false
# LLVM crashes when passing an object through ThinLTO twice. This is triggered
# when using rust code in cross-language LTO if libstd was built using ThinLTO.
# http://blog.llvm.org/2019/09/closing-gap-cross-language-lto-between.html
# https://github.com/rust-lang/rust/issues/54872
codegen-units-std = 1
# musl target produces warnings
deny-warnings = false
[dist]
compression-formats = ["gz"]
[target.${_rust_target}]
cc = "/usr/bin/gcc"
cxx = "/usr/bin/g++"
ar = "/usr/bin/gcc-ar"
ranlib = "/usr/bin/gcc-ranlib"
llvm-config = "/usr/bin/llvm-config"
END
}
_pick() {
local p="$1" f d; shift
for f; do
d="$srcdir/$p/$f"
mkdir -p "$(dirname "$d")"
mv "$f" "$d"
rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
done
}
build() {
cd rustc-$pkgver-src
export RUST_BACKTRACE=1
unset CFLAGS CXXFLAGS LDFLAGS
DESTDIR="$srcdir/dest-rust" python ./x.py install -j "$(nproc)"
cd ../dest-rust
# delete unnecessary files, e.g. files only used for the uninstall script
rm -v usr/lib/rustlib/{components,install.log,rust-installer-version,uninstall.sh}
rm -v usr/lib/rustlib/manifest-*
# licenses for main rust package
local ldir="usr/share/licenses/rust" f d
mkdir -p "$ldir"
for f in usr/share/doc/*/{COPYRIGHT,LICENSE}*; do
d="$(dirname "$f")"
case $f in
*/LICENSE-APACHE) rm -v "$f" ;;
*) mv -v "$f" "$ldir/${f##*/}.${d##*/}" ;;
esac
rmdir -p --ignore-fail-on-non-empty "$d"
done
_pick dest-src usr/lib/rustlib/src
}
package_rust() {
optdepends=(
'gdb: rust-gdb script'
'lldb: rust-lldb script'
)
provides=(
cargo
rustfmt
)
conflicts=(
cargo
'rust-docs<1:1.56.1-3'
rustfmt
)
replaces=(
cargo
cargo-tree
'rust-docs<1:1.56.1-3'
rustfmt
)
cp -a dest-rust/* "$pkgdir"
}
package_rust-src() {
pkgdesc="Source code for the Rust standard library"
depends=(rust)
cp -a dest-src/* "$pkgdir"
install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 \
rustc-$pkgver-src/{COPYRIGHT,LICENSE-MIT}
}
# vim:set ts=2 sw=2 et: