development/rust: Allow building/bootstrapping for i586.

Signed-off-by: David Spencer <idlemoor@slackbuilds.org>
This commit is contained in:
Andrew Clemons 2017-09-08 00:47:18 +01:00 committed by David Spencer
parent ccfcfd9292
commit 34ae60b2d9
2 changed files with 103 additions and 21 deletions

View File

@ -38,27 +38,59 @@ TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i686 ;;
armv7*) ARCH=$( uname -m ) ;;
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
# if you already have rust and cargo installed, you can bootstrap from the
# previous version.
if [ "$LOCAL_BOOTSTRAP" = "" ] && [ -x /usr/bin/cargo ] && [ -x /usr/bin/rustc ] ; then
LOCAL_BOOTSTRAP=yes
fi
# https://forge.rust-lang.org/platform-support.html
# Bootstrapping ARCH:
if [ "$ARCH" = "i586" ]; then
BARCH="i686"
elif case $ARCH in armv7*) true;; *) false;; esac; then
BARCH="armv7"
if [ "$LOCAL_BOOTSTRAP" = "yes" ] ; then
if rustc -Vv | grep host | grep i586 > /dev/null ; then
BARCH="$ARCH"
else
echo "Your exising rust cannot bootstrap an i586 toolchain. Either set LOCAL_BOOTSTRAP=no or remove your existing rust package and do a full bootstrap."
exit 1
fi
else
# i586 must be built on a i686 machine, since the bootstrap compiler is i686
BARCH="i686"
if case "$( uname -m )" in i586) true ;; *) false ;; esac ; then
echo "rust must be bootstrapped from an i686 machine"
exit 1
fi
fi
else
BARCH="$ARCH"
fi
TARCH="$ARCH"
# Bootstrapping ABI:
if case $ARCH in armv7*) true;; *) false;; esac; then
BABI="gnueabihf"
elif [ "$ARCH" = "arm" ]; then
BABI="gnueabi"
if [ "$ARCH" = "arm" ]; then
if readelf -h /bin/bash | grep Flags | grep hard > /dev/null 2>&1 ; then
# hardfloat
BABI="gnueabihf"
BARCH="armv7"
TARCH="$BARCH"
else
# softfloat
BABI="gnueabi"
if case "$( uname -m )" in armv5*) true ;; *) false ;; esac ; then
echo "rust must be bootstrapped from an armv6 machine or later"
exit 1
fi
fi
else
BABI="gnu"
fi
@ -77,9 +109,13 @@ elif [ "$ARCH" = "i686" ]; then
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
elif case $ARCH in armv7*) true;; *) false;; esac; then
SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16"
elif [ "$ARCH" = "arm" ] ; then
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
if [ "$BABI" = "gnueabihf" ] ; then
SLKCFLAGS="$SLKCFLAGS -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
fi
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
@ -94,12 +130,6 @@ rm -rf $SRCNAM-$VERSION-src
tar xvf $CWD/$SRCNAM-$VERSION-src.tar.gz
cd $SRCNAM-$VERSION-src
# if you already have rust and cargo installed, you can bootstrap from the
# previous version.
if [ "$LOCAL_BOOTSTRAP" = "" ] && [ -x /usr/bin/cargo ] && [ -x /usr/bin/rustc ] ; then
LOCAL_BOOTSTRAP=yes
fi
if [ "$LOCAL_BOOTSTRAP" != "yes" ] ; then
# rust requires bootstrapping with the previous rust version.
# versions are defined in src/stage0.txt
@ -108,6 +138,11 @@ if [ "$LOCAL_BOOTSTRAP" != "yes" ] ; then
$CWD/$SRCNAM-$RSTAGE0_VERSION-$BARCH-unknown-linux-$BABI.tar.gz \
build/cache/$RSTAGE0_DIR
if [ "$TARCH" = "i586" ] ; then
cp $CWD/$PRGNAM-std-$RSTAGE0_VERSION-$TARCH-unknown-linux-$BABI.tar.gz \
build/cache/$RSTAGE0_DIR
fi
mkdir -p build/cache/$CSTAGE0_DIR
cp $CWD/cargo-$CSTAGE0_VERSION-$BARCH-unknown-linux-$BABI.tar.gz build/cache/$CSTAGE0_DIR
fi
@ -115,6 +150,9 @@ fi
# src/bootstrap/config.toml.example
cat << EOF > config.toml
[build]
build = "$BARCH-unknown-linux-$BABI"
host = ["$TARCH-unknown-linux-$BABI"]
target = ["$TARCH-unknown-linux-$BABI"]
vendor = true
extended = true
@ -126,12 +164,24 @@ mandir = "man"
[rust]
codegen-units = 0
debuginfo = true
debuginfo = false
channel = "stable"
rpath = false
codegen-tests = false
[target.$BARCH-unknown-linux-$BABI]
[target.i586-unknown-linux-gnu]
llvm-config = "/usr/bin/llvm-config"
[target.i686-unknown-linux-gnu]
llvm-config = "/usr/bin/llvm-config"
[target.x86_64-unknown-linux-gnu]
llvm-config = "/usr/bin/llvm-config"
[target.arm-unknown-linux-gnuabi]
llvm-config = "/usr/bin/llvm-config"
[target.armv7-unknown-linux-gnuabihf]
llvm-config = "/usr/bin/llvm-config"
EOF
@ -146,7 +196,37 @@ find -L . \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi"
if [ "$BARCH" = "i686" ] && [ "$TARCH" = "i586" ] ; then
# this will cause some messages like:
# warning: redundant linker flag specified for library `m`
# but will keep the build from falling over when doing the stage1 compiler
# linking for the i586 compiler. seems the correct flags don't get passed
# through and we end up failures like:
# error: linking with `clang` failed: exit code: 1
# /tmp/SBo/rustc-1.20.0-src/build/i686-unknown-linux-gnu/stage1-rustc/i586-unknown-linux-gnu/release/deps/librustc_llvm-4ab259c9aed547db.so: undefined reference to `xxx`
export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi -lrt -ldl -lcurses -lpthread -lz -lm"
else
# https://github.com/rust-lang/rust/issues/39880
# $ llvm-config --system-libs
# -lrt -ldl -lcurses -lpthread -lz -lm
export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi"
fi
export PKG_CONFIG_ALLOW_CROSS=1
if [ "$BARCH" = "i586" ] ; then
# when bootstrapping from i586 (rust already installed), also build a i686
# rustlib
# from config.toml.example:
# In addition to all host triples, other triples to produce the standard library
# for. Each host triple will be used to produce a copy of the standard library
# for each target triple.
#target = ["x86_64-unknown-linux-gnu"] # defaults to just the build triple
sed -i 's/^target =.*$/target = ["i686-unknown-linux-gnu"]/' config.toml
fi
# README.md says gcc 4.7 / clang 3.x or later needed
# but building fails for me with GCC 5.3 from slackware 14.2
@ -165,7 +245,7 @@ DESTDIR=$PKG python x.py install
#rm -f $PKG/usr/lib$LIBDIRSUFFIX/rustlib/rust-installer-version
#rm -f $PKG/usr/lib$LIBDIRSUFFIX/rustlib/uninstall.sh
# Make sure the paths are correct, though:
sed -i "s,/tmp/package-rust/,/,g" $PKG/usr/lib$LIBDIRSUFFIX/rustlib/install.log $PKG/usr/lib$LIBDIRSUFFIX/rustlib/manifest-*
sed -i "s,$PKG/,/,g" $PKG/usr/lib$LIBDIRSUFFIX/rustlib/install.log $PKG/usr/lib$LIBDIRSUFFIX/rustlib/manifest-*
# And a little compression doesn't hurt either:
gzip -9 $PKG/usr/lib$LIBDIRSUFFIX/rustlib/manifest-*

View File

@ -3,10 +3,12 @@ VERSION="1.20.0"
HOMEPAGE="https://www.rust-lang.org"
DOWNLOAD="https://static.rust-lang.org/dist/rustc-1.20.0-src.tar.gz \
https://static.rust-lang.org/dist/2017-07-20/cargo-0.20.0-i686-unknown-linux-gnu.tar.gz \
https://static.rust-lang.org/dist/2017-07-20/rust-std-1.19.0-i586-unknown-linux-gnu.tar.gz \
https://static.rust-lang.org/dist/2017-07-20/rust-std-1.19.0-i686-unknown-linux-gnu.tar.gz \
https://static.rust-lang.org/dist/2017-07-20/rustc-1.19.0-i686-unknown-linux-gnu.tar.gz"
MD5SUM="1d3c5d25d8e6215e7d0b6d4d4c9835b9 \
1de2d0fb8e09d3c976ac8d874f158f57 \
20462edfd584959cf48d24772fc224ff \
7e7d4a768fe05264fc23cb2afef75740 \
9711f634011658b451f315916234c88e"
DOWNLOAD_x86_64="https://static.rust-lang.org/dist/rustc-1.20.0-src.tar.gz \