|
| 1 | +name: Rust for Xous |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-libstd: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + steps: |
| 10 | + - name: Setup riscv gnu/gcc toolchain |
| 11 | + uses: gregdavill/[email protected] |
| 12 | + |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v2 |
| 15 | + with: |
| 16 | + submodules: 'recursive' |
| 17 | + |
| 18 | + - name: Determine Rust version |
| 19 | + shell: bash |
| 20 | + run: echo "##[set-output name=version;]$(echo ${GITHUB_REF} | cut -d/ -f3 | cut -d- -f1 | cut -d. -f1,2,3)" |
| 21 | + id: extract_rust_version |
| 22 | + |
| 23 | + - name: Install Rust toolchain v${{ steps.extract_rust_version.outputs.version }} |
| 24 | + uses: actions-rs/toolchain@v1 |
| 25 | + with: |
| 26 | + toolchain: ${{ steps.extract_rust_version.outputs.version }} |
| 27 | + default: true |
| 28 | + override: true |
| 29 | + target: riscv32imac-unknown-none-elf |
| 30 | + |
| 31 | + - name: Install riscv32imac-unknown-xous-elf toolchain file |
| 32 | + run: | |
| 33 | + rm -rf $(rustc --print sysroot)/lib/rustlib/riscv32imac-unknown-xous-elf \ |
| 34 | + && mkdir -p $(rustc --print sysroot)/lib/rustlib/riscv32imac-unknown-xous-elf/lib \ |
| 35 | + && rustc --version | awk '{print $2}' > $(rustc --print sysroot)/lib/rustlib/riscv32imac-unknown-xous-elf/RUST_VERSION |
| 36 | +
|
| 37 | + - name: Build Rust libstd |
| 38 | + run: | |
| 39 | + export RUST_COMPILER_RT_ROOT=$(pwd)/src/llvm-project/compiler-rt \ |
| 40 | + && rm -rf target \ |
| 41 | + && sed -i '/^#define CRT_HAS_128BIT/d' src/llvm-project/compiler-rt/lib/builtins/int_types.h \ |
| 42 | + && cargo build \ |
| 43 | + --target riscv32imac-unknown-xous-elf \ |
| 44 | + -Zbinary-dep-depinfo \ |
| 45 | + --release \ |
| 46 | + --features "panic-unwind compiler-builtins-c compiler-builtins-mem" \ |
| 47 | + --manifest-path "library/sysroot/Cargo.toml" \ |
| 48 | + && cp target/riscv32imac-unknown-xous-elf/release/deps/*.rlib $(rustc --print sysroot)/lib/rustlib/riscv32imac-unknown-xous-elf/lib \ |
| 49 | + && (dest=$(pwd) && cd $(rustc --print sysroot) && zip -r ${dest}/riscv32imac-unknown-xous_${{ steps.extract_rust_version.outputs.version }}.zip lib/rustlib/riscv32imac-unknown-xous-elf/) |
| 50 | + env: |
| 51 | + CARGO_PROFILE_RELEASE_DEBUG: 0 |
| 52 | + CARGO_PROFILE_RELEASE_OPT_LEVEL: 3 |
| 53 | + CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS: false |
| 54 | + RUSTC_BOOTSTRAP: 1 |
| 55 | + RUSTFLAGS: -Cforce-unwind-tables=yes -Cembed-bitcode=yes |
| 56 | + __CARGO_DEFAULT_LIB_METADATA: stablestd |
| 57 | + CC: riscv-none-embed-gcc |
| 58 | + AR: riscv-none-embed-ar |
| 59 | + |
| 60 | + - name: Release |
| 61 | + uses: softprops/action-gh-release@v1 |
| 62 | + if: startsWith(github.ref, 'refs/tags/') |
| 63 | + with: |
| 64 | + files: | |
| 65 | + riscv32imac-unknown-xous_${{ steps.extract_rust_version.outputs.version }}.zip |
| 66 | + env: |
| 67 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments