#!/bin/sh MAKEDEPS="cmake llvm clang" DEPS="curl gcc libssh2 openssl" PKG_VER=1.58.1 SOURCE=https://static.rust-lang.org/dist/rustc-$PKG_VER-src.tar.gz DESC="Systems programming language focused on safety, speed and concurrency" ADDITIONAL=" patches/rustc/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch patches/rustc/0007-do-not-install-libunwind-source.patch patches/rustc/install-template-shebang.patch patches/rustc/link-musl-dynamically.patch patches/rustc/musl-fix-linux_musl_base.patch patches/rustc/need-rpath.patch patches/rustc/need-ssp_nonshared.patch patches/rustc/need-ssp_nonshared.patch " prepare () { apply_patches mkdir -p $PKG_DEST/opt/rustc-$PKG_VER && ln -sf rustc-$PKG_VER $PKG_DEST/opt/rustc } build () { export RUSTFLAGS="$RUSTFLAGS -C link-arg=-lffi" && target=x86_64-unknown-linux-musl build=x86_64-unknown-linux-musl CFLAGS="-fPIE" CXXFLAGS="-fPIE" ./configure \ --build="$build" \ --host="$target" \ --target="$target" \ --prefix="/usr" \ --release-channel="stable" \ --llvm-root="/usr/lib/" \ --disable-docs \ --enable-extended \ --tools="analysis,cargo,src,rustfmt" \ --enable-llvm-link-shared \ --enable-option-checking \ --enable-locked-deps \ --enable-vendor \ --set="rust.musl-root=/usr" \ --set="rust.codegen-units=1" \ --set="rust.codegen-units-std=1" \ --set="rust.parallel-compiler=true" \ --set="target.$target.llvm-config=/usr/bin/llvm-config" \ --set="target.$target.musl-root=/usr" \ --set="target.$target.crt-static=false" \ --set="target.$target.cc=clang" \ --set="target.$target.cxx=clang++" \ --set="target.$target.ar=llvm-ar" \ --set="target.$target.linker=clang" \ --set="target.$build.musl-root=/usr" \ --set="target.$build.crt-static=false" \ --set="target.$build.cc=clang" \ --set="target.$build.cxx=clang++" \ --set="target.$build.ar=llvm-ar" \ --set="target.$build.linker=clang" python ./x.py dist --jobs $JOBS } package () { export LIBSSH2_SYS_USE_PKG_CONFIG=1 && DESTDIR=${PWD}/install python3 ./x.py install && unset LIBSSH2_SYS_USE_PKG_CONFIG chown -R root:root install && cp -a install/* $PKG_DEST mkdir -p $PKG_DEST/etc/profile.d/ cat > $PKG_DEST/etc/profile.d/rustc.sh << "EOF" # Begin /etc/profile.d/rustc.sh pathprepend /opt/rustc/bin PATH # End /etc/profile.d/rustc.sh EOF mkdir -p $PKG_DEST/etc/ld.so.conf.d cat >> $PKG_DEST/etc/ld.so.conf.d/rustc.conf << EOF # Begin rustc addition /opt/rustc/lib # End rustc addition EOF }