rustc-nightly: Make it possible to build the deb package

This is squashed 6 commits into the first one.

- Fix containing unneccessary files that prevents dpkg install

- Move rustc-nightly from disabled-package to package

- Reduce the amount of disk needed

- Fix using specific version of beta

- Fix wrong PATH value

- Fix how to retrieve LLVM_VERSION
This commit is contained in:
muku Takeda 2022-03-23 22:21:04 +09:00 committed by Henrik Grimler
parent 27c38932d3
commit 5ec9a796fa
No known key found for this signature in database
GPG Key ID: B0076E490B71616B
11 changed files with 50 additions and 52 deletions

View File

@ -2,21 +2,22 @@ TERMUX_PKG_HOMEPAGE=https://www.rust-lang.org
TERMUX_PKG_DESCRIPTION="Rust compiler and utilities (nightly version)"
TERMUX_PKG_DEPENDS="libc++, clang, openssl, lld, zlib, libllvm"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@its-pointless"
TERMUX_PKG_VERSION=1.52.0
TERMUX_PKG_REVISION=2
TERMUX_PKG_SRCURL=https://static.rust-lang.org/dist/2021-02-24/rustc-nightly-src.tar.xz
TERMUX_PKG_SHA256=80536b0050fc83cdffedf617bac0fd23dc60081adc00648b90404e1a14baba18
TERMUX_PKG_KEEP_SHARE_DOC=true
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1.61.0
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://static.rust-lang.org/dist/2022-03-07/rustc-nightly-src.tar.xz
TERMUX_PKG_SHA256=7c7eb8e20f62c1701a369c033ed2c06f1de8c35c3673658e12691243a1d41558
TERMUX_PKG_RM_AFTER_INSTALL="bin/llvm-* bin/llc bin/opt"
termux_step_configure () {
termux_setup_cmake
termux_setup_rust
# nightlys don't build with stable
rustup install beta-2021-02-14-x86_64-unknown-linux-gnu
rustup target add $CARGO_TARGET_NAME
export PATH=$HOME/.rustup/toolchains/beta-2021-02-14-x86_64-unknown-linux-gnu/bin:$PATH
BETA_VER=beta-2022-02-22
rustup install ${BETA_VER}
rustup target add --toolchain ${BETA_VER} $CARGO_TARGET_NAME
export PATH=$HOME/.rustup/toolchains/${BETA_VER}-x86_64-unknown-linux-gnu/bin:$PATH
export RUST_BACKTRACE=1
mkdir -p $TERMUX_PREFIX/opt/rust-nightly
RUST_PREFIX=$TERMUX_PREFIX/opt/rust-nightly
@ -25,6 +26,7 @@ termux_step_configure () {
-e "s|@RUST_PREFIX@|$RUST_PREFIX|g" \
-e "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" \
-e "s|@TERMUX_HOST_PLATFORM@|$TERMUX_HOST_PLATFORM|g" \
-e "s|@TERMUX_STANDALONE_TOOLCHAIN@|$TERMUX_STANDALONE_TOOLCHAIN|g" \
-e "s|@RUST_TARGET_TRIPLE@|$CARGO_TARGET_NAME|g" \
-e "s|@CARGO@|$(command -v cargo)|g" \
-e "s|@RUSTC@|$(command -v rustc)|g" > $TERMUX_PKG_BUILDDIR/config.toml
@ -35,21 +37,26 @@ termux_step_configure () {
# for backtrace-sys
export CC_x86_64_unknown_linux_gnu=gcc
export CFLAGS_x86_64_unknown_linux_gnu="-O2"
export LLVM_VERSION=$(. $TERMUX_SCRIPTDIR/packages/libllvm/build.sh; echo $TERMUX_PKG_VERSION)
# it won't link with it in TERMUX_PREFIX/lib without breaking other things.
cp $PREFIX/lib/libLLVM-11.1.0.so $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/
unset CC CXX CPP LD CFLAGS CXXFLAGS CPPFLAGS LDFLAGS PKG_CONFIG AR RANLIB
if [ $TERMUX_ARCH = "x86_64" ]; then
cp $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/x86_64-linux-android/$TERMUX_PKG_API_LEVEL/libc.so $TERMUX_PREFIX/lib/
cp $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/x86_64-linux-android/$TERMUX_PKG_API_LEVEL/libdl.so $TERMUX_PREFIX/lib/
mv $TERMUX_PREFIX/lib/libtinfo.so.6 $TERMUX_PREFIX/lib/libtinfo.so.6.tmp
ln -sf $PREFIX/lib/libLLVM-$LLVM_VERSION.so $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/
# rust checks libs in PREFIX/lib. It then can't find libc.so and libdl.so because rust program doesn't
# know where those are. Putting them temporarly in $PREFIX/lib prevents that failure
if [ -e $TERMUX_PREFIX/lib/libtinfo.so.6 ]; then
mv $TERMUX_PREFIX/lib/libtinfo.so.6 $TERMUX_PREFIX/lib/libtinfo.so.6.tmp
fi
if [ -e $TERMUX_PREFIX/lib/libz.so.1 ]; then
mv $TERMUX_PREFIX/lib/libz.so.1 $TERMUX_PREFIX/lib/libz.so.1.tmp
fi
if [ -e $TERMUX_PREFIX/lib/libz.so ]; then
mv $TERMUX_PREFIX/lib/libz.so $TERMUX_PREFIX/lib/libz.so.tmp
fi
}
termux_step_make_install () {
if [ ! -f "/usr/bin/llvm-dwp" ]; then
# errr yeah this needs to be here for docker stuff
sudo ln -s /usr/bin/llvm-dwp-10 /usr/bin/llvm-dwp
fi
if [ $TERMUX_ARCH = "x86_64" ]; then
mv $TERMUX_PREFIX ${TERMUX_PREFIX}a
../src/x.py dist cargo --host x86_64-unknown-linux-gnu
@ -63,46 +70,49 @@ termux_step_make_install () {
../src/x.py dist --host $CARGO_TARGET_NAME --target $CARGO_TARGET_NAME --target wasm32-unknown-unknown || bash
mkdir $TERMUX_PKG_BUILDDIR/install
# miri-nightly not working.
for tar in rustc-nightly miri-nightly rustc-dev-nightly rust-docs-nightly rust-std-nightly rust-analysis-nightly cargo-nightly rls-nightly rustc-dev-nightly rustfmt-nightly clippy-nightly; do
tar -xf $TERMUX_PKG_BUILDDIR/build/dist/$tar-$CARGO_TARGET_NAME.tar.gz -C $TERMUX_PKG_BUILDDIR/install
# uninstall previous version
$TERMUX_PKG_BUILDDIR/install/$tar-$CARGO_TARGET_NAME/install.sh --uninstall --prefix=$RUST_PREFIX || true
$TERMUX_PKG_BUILDDIR/install/$tar-$CARGO_TARGET_NAME/install.sh --prefix=$RUST_PREFIX
for tar in rustc-nightly miri-nightly rustc-dev-nightly rust-docs-nightly rust-std-nightly rust-analysis-nightly cargo-nightly rls-nightly rustfmt-nightly clippy-nightly; do
if [ -e $TERMUX_PKG_BUILDDIR/build/dist/$tar-$CARGO_TARGET_NAME.tar.gz ]; then
tar -xf $TERMUX_PKG_BUILDDIR/build/dist/$tar-$CARGO_TARGET_NAME.tar.gz -C $TERMUX_PKG_BUILDDIR/install
# uninstall previous version
$TERMUX_PKG_BUILDDIR/install/$tar-$CARGO_TARGET_NAME/install.sh --uninstall --prefix=$RUST_PREFIX || true
$TERMUX_PKG_BUILDDIR/install/$tar-$CARGO_TARGET_NAME/install.sh --prefix=$RUST_PREFIX
fi
done
tar -xf $TERMUX_PKG_BUILDDIR/build/dist/rust-src-nightly.tar.gz -C $TERMUX_PKG_BUILDDIR/install
$TERMUX_PKG_BUILDDIR/install/rust-src-nightly/install.sh --uninstall --prefix=$RUST_PREFIX || true
$TERMUX_PKG_BUILDDIR/install/rust-src-nightly/install.sh --prefix=$RUST_PREFIX
WASM=wasm32-unknown-unknown
for tar in rust-std-nightly rust-analysis-nightly; do
for tar in rust-std-nightly; do
tar -xf $TERMUX_PKG_BUILDDIR/build/dist/$tar-$WASM.tar.gz -C $TERMUX_PKG_BUILDDIR/install
# uninstall previous version
$TERMUX_PKG_BUILDDIR/install/$tar-$WASM/install.sh --uninstall --prefix=$RUST_PREFIX || true
$TERMUX_PKG_BUILDDIR/install/$tar-$WASM/install.sh --prefix=$RUST_PREFIX
done
if [ $TERMUX_ARCH = "x86_64" ]; then
rm -f $TERMUX_PREFIX/lib/libc.so $TERMUX_PREFIX/lib/libdl.so
mv $TERMUX_PREFIX/lib/libtinfo.so.6.tmp $TERMUX_PREFIX/lib/libtinfo.so.6
fi
mv $TERMUX_PREFIX/lib/libtinfo.so.6.tmp $TERMUX_PREFIX/lib/libtinfo.so.6
mv $TERMUX_PREFIX/lib/libz.so.1.tmp $TERMUX_PREFIX/lib/libz.so.1
mv $TERMUX_PREFIX/lib/libz.so.tmp $TERMUX_PREFIX/lib/libz.so
}
termux_step_post_massage () {
rm $TERMUX_PKG_MASSAGEDIR/$RUST_PREFIX/lib/rustlib/{components,rust-installer-version,install.log,uninstall.sh}
rm $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/libLLVM-$LLVM_VERSION.so
rm -f lib/libtinfo.so.6
rm -f lib/libz.so
rm -f lib/libz.so.1
mkdir -p $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/etc/profile.d
mkdir -p $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/lib
echo "#!$TERMUX_PREFIX/bin/sh" > $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/etc/profile.d/rust-nightly.sh
echo "export PATH=$RUST_PREFIX/bin:\$PATH" >> $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/etc/profile.d/rust-nightly.sh
cd $TERMUX_PKG_MASSAGEDIR/$RUST_PREFIX/lib
ln -sf rustlib/$CARGO_TARGET_NAME/lib/lib*.so .
cd $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/lib
ln -sf ../opt/rust-nightly/lib/lib*.so .
ln -sf $TERMUX_PREFIX/bin/lld $TERMUX_PKG_MASSAGEDIR$RUST_PREFIX/bin/rust-lld
rm -f ../bin/llvm-dwp
if [ $TERMUX_ARCH = "x86_64" ]; then
rm -f $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/lib/libtinfo.so.6
fi
rm $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/libLLVM-11.1.0.so
ln -sf $TERMUX_PREFIX/bin/lld $TERMUX_PKG_MASSAGEDIR/$RUST_PREFIX/bin/rust-lld
}
termux_step_create_debscripts () {
echo "#!$TERMUX_PREFIX/bin/sh" > postinst

View File

@ -2,47 +2,35 @@
build = "x86_64-unknown-linux-gnu"
host = [ "@RUST_TARGET_TRIPLE@" ]
target = [ '@RUST_TARGET_TRIPLE@', 'wasm32-unknown-unknown' ]
#python = "python2.7"
#full-bootstrap = false
docs = false
extended = true
rustc = '@RUSTC@'
cargo = '@CARGO@'
#configure-args = ['--target=wasm32-unknown-unknown', '--set', 'llvm.experimental-targets=WebAssembly']
#tools = ["rls", "rustfmt", "analysis"]
local-rebuild = false
tools = ["cargo", "src"]
[install]
prefix = "@RUST_PREFIX@"
[llvm]
experimental-targets = 'WebAssembly'
link-shared = true
skip-rebuild = true
[rust]
#backtrace = false
#default-linker = "clang"
#default-ar = "ar"
channel = "nightly"
rpath = true
optimize-tests = false
codegen-tests = false
#lld = false
deny-warnings = false
backtrace-on-ice = true
[target.wasm32-unknown-unknown]
#linker = @TERMUX_PREFIX@/bin/wasm-ld
#crt-static = true
[target.x86_64-unknown-linux-gnu]
llvm-config = "/usr/bin/llvm-config-10"
llvm-config = "/usr/bin/llvm-config-12"
[target.@RUST_TARGET_TRIPLE@]
cc = "@TERMUX_HOST_PLATFORM@-clang"
cxx = "@TERMUX_HOST_PLATFORM@-clang++"
android-ndk = "@TERMUX_STANDALONE_TOOLCHAIN@"
llvm-config = "@TERMUX_PREFIX@/bin/llvm-config"
ar = "llvm-ar"
#jemalloc = "/path/to/jemalloc/libjemalloc_pic.a"
#android-ndk = "/path/to/ndk"
[dist]
missing-tools = true