|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Build script for Rust on Solaris. |
| 4 | +# |
| 5 | +set -xe |
| 6 | + |
| 7 | +VERSION=1.82.0 |
| 8 | + |
| 9 | +PATH=$RUST_BOOTSTRAP:/usr/gnu/bin:/usr/bin |
| 10 | + |
| 11 | +CONFIGURE_OPTIONS+=" --default-linker=gcc" |
| 12 | +CONFIGURE_OPTIONS+=" --enable-local-rust" |
| 13 | +CONFIGURE_OPTIONS+=" --release-channel=stable" |
| 14 | + |
| 15 | +WS="`pwd`" |
| 16 | +BUILD_DIR="$WS/build_dir" |
| 17 | + |
| 18 | +SRC_DIR=rustc-${VERSION}-src |
| 19 | +SRC_ARCHIVE=${SRC_DIR}.tar.xz |
| 20 | + |
| 21 | +BUILD_HOME="$BUILD_DIR"/rustc-${VERSION}-home |
| 22 | +PROTO_DIR="$BUILD_DIR"/rustc-${VERSION}-proto |
| 23 | + |
| 24 | +GCC=/usr/gcc/11/bin/gcc |
| 25 | +GXX=/usr/gcc/11/bin/g++ |
| 26 | + |
| 27 | +mkdir -p "$BUILD_DIR" |
| 28 | + |
| 29 | +# Clean build directory |
| 30 | +( cd "$BUILD_DIR"; rm -rf $SRC_DIR $SRC_ARCHIVE $BUILD_HOME $PROTO_DIR ) |
| 31 | + |
| 32 | +mkdir -p $BUILD_HOME $PROTO_DIR |
| 33 | + |
| 34 | +# Download source archive |
| 35 | +( cd "$BUILD_DIR"; wget -q https://static.rust-lang.org/dist/${SRC_ARCHIVE} ) |
| 36 | + |
| 37 | +# Unpack source archive |
| 38 | +( cd "$BUILD_DIR" ; gtar xf ${SRC_ARCHIVE} ) |
| 39 | + |
| 40 | +# Patch sources |
| 41 | +( cd "$BUILD_DIR"/${SRC_DIR}; |
| 42 | + cat "$WS/patches-$VERSION/series" | while read patch args; do |
| 43 | + echo $patch | grep ^\# > /dev/null && continue |
| 44 | + gpatch --batch --forward --strip=1 $args -i "$WS/patches-$VERSION/$patch" |
| 45 | + done ) |
| 46 | + |
| 47 | +# Force cargo to use vendored sources |
| 48 | +( cd "$BUILD_HOME" |
| 49 | + mkdir -p .cargo |
| 50 | + echo "[source.crates-io]" > .cargo/config.toml |
| 51 | + echo "replace-with = \"vendored-sources\"" >> .cargo/config.toml |
| 52 | + echo "[source.vendored-sources]" >> .cargo/config.toml |
| 53 | + echo "directory = \""$BUILD_DIR"/${SRC_DIR}/vendor\"" >> .cargo/config.toml ) |
| 54 | + |
| 55 | +cd "$BUILD_DIR"/$SRC_DIR |
| 56 | + |
| 57 | +# Configuration |
| 58 | +PATH="$PATH" CC=$GCC CXX=$GXX bash ./configure ${CONFIGURE_OPTIONS} |
| 59 | + |
| 60 | +# Build Rust |
| 61 | +PATH=$PATH PKG_CONFIG_PATH=/usr/lib/64/pkgconfig HOME=$BUILD_HOME gmake install DESTDIR=$PROTO_DIR |
| 62 | + |
| 63 | +# Create Rust distribution archive |
| 64 | +( cd $PROTO_DIR/usr && mv local rustc-${VERSION} && gtar cfJ $BUILD_DIR/rust-${VERSION}-Solaris-11.4.42-CBE-`mach`.tar.xz rustc-${VERSION} ) |
0 commit comments