Skip to content

Turn off debug assertions in release #46

Turn off debug assertions in release

Turn off debug assertions in release #46

name: Rust for Xous
on: [push]
jobs:
build-libstd:
runs-on: ubuntu-latest
strategy:
matrix:
target: [armv7a-unknown-xous-elf]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Setup ARM Profile-A GCC toolchain
run: sudo apt install gcc-arm-none-eabi
if: matrix.target == 'armv7a-unknown-xous-elf'
- name: Extract Rust information.
shell: bash
id: extract_rust_info
run: |
case "${{ matrix.target }}" in
riscv32imac-unknown-xous-elf)
target=riscv32imac-unknown-none-elf
target_cross_compile=riscv-none-embed
;;
armv7a-unknown-xous-elf)
target=armv7a-none-eabi
target_cross_compile=arm-none-eabi
;;
esac
echo "##[set-output name=target;]$target"
echo "##[set-output name=version;]$(echo ${GITHUB_REF} | cut -d/ -f3 | cut -d- -f1 | cut -d. -f1,2,3)"
echo "##[set-output name=cc;]$target_cross_compile-gcc"
echo "##[set-output name=ar;]$target_cross_compile-ar"
- name: Install Rust toolchain v${{ steps.extract_rust_info.outputs.version }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ steps.extract_rust_info.outputs.version }}
default: true
override: true
target: ${{ steps.extract_rust_info.outputs.target }}
- name: Install toolchain file
run: |
rm -rf $(rustc --print sysroot)/lib/rustlib/${{ matrix.target }} \
&& mkdir -p $(rustc --print sysroot)/lib/rustlib/${{ matrix.target }}/lib \
&& cp ${{ matrix.target }}.json $(rustc --print sysroot)/lib/rustlib/${{ matrix.target }}/target.json \
&& rustc --version | awk '{print $2}' > $(rustc --print sysroot)/lib/rustlib/${{ matrix.target }}/RUST_VERSION
- name: Patch LLVM for 128-bit support
run: sed -i '/^#define CRT_HAS_128BIT/d' src/llvm-project/compiler-rt/lib/builtins/int_types.h
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Build Rust libstd
run: |
export RUST_COMPILER_RT_ROOT=$(pwd)/src/llvm-project/compiler-rt \
&& rm -rf target \
&& cargo build \
--target ${{ matrix.target }} \
-Zbinary-dep-depinfo \
--release \
--features "panic-unwind compiler-builtins-c compiler-builtins-mem" \
--manifest-path "library/sysroot/Cargo.toml" \
&& cp target/${{ matrix.target }}/release/deps/*.rlib $(rustc --print sysroot)/lib/rustlib/${{ matrix.target }}/lib \
&& (dest=$(pwd) && cd $(rustc --print sysroot) && zip -r ${dest}/${{ matrix.target }}_${{ steps.extract_rust_info.outputs.version }}.zip lib/rustlib/${{ matrix.target }}/)
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_PROFILE_RELEASE_DEBUG: 0
CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS: false
CARGO_PROFILE_RELEASE_OPT_LEVEL: 3
RUSTC_BOOTSTRAP: 1
RUSTFLAGS: -Cforce-unwind-tables=yes -Cembed-bitcode=yes
__CARGO_DEFAULT_LIB_METADATA: stablestd
CC: ${{ steps.extract_rust_info.outputs.cc }}
AR: ${{ steps.extract_rust_info.outputs.ar }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ matrix.target }}_${{ steps.extract_rust_info.outputs.version }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}