GithubHelp home page GithubHelp logo

rivosinc / rust Goto Github PK

View Code? Open in Web Editor NEW

This project forked from betrusted-io/rust

0.0 1.0 0.0 951.68 MB

Empowering everyone to build reliable and efficient software.

Home Page: https://www.rust-lang.org

License: Other

Shell 0.26% JavaScript 0.38% C++ 0.20% Python 0.32% C 0.06% Assembly 0.02% Rust 97.66% Puppet 0.01% PowerShell 0.01% TypeScript 0.20% XSLT 0.01% CSS 0.10% Pascal 0.01% Makefile 0.27% HTML 0.36% CMake 0.01% RenderScript 0.02% Batchfile 0.01% Dockerfile 0.11% Roff 0.02%

rust's Introduction

Rust Stable for Xous

Build stable Rust binaries for Xous! This release targets Rust 1.70.0.

Supported Features

When porting the standard library to a new operating system, a piecemeal approach is taken. Features are gradually brought up as they are needed. So far, the following features work:

  • println!()
  • sync::Mutex
  • sync::Condvar
  • net::TcpStream
  • net::UdpSocket
  • net::LookupHost
  • time::Duration
  • time::Instant
  • thread::sleep
  • thread::spawn
  • thread::local

Installing Prebuilt Releases

  1. Ensure you are running Rust 1.70.0. Future versions of Rust will need a different version of this software.
  2. Download the latest release from the releases page
  3. Unzip the zipfile to your Rust sysroot. On Unix systems can do this with something like:
cd $(rustc --print sysroot)
wget https://github.com/betrusted-io/rust/releases/latest/download/riscv32imac-unknown-xous_1.70.0.zip
rm -rf lib/rustlib/riscv32imac-unknown-xous-elf # Remove any existing version
unzip *.zip
rm *.zip
cd -

On Windows with Powershell you can run:

Push-Location $(rustc --print sysroot)
if (Test-Path lib\rustlib\riscv32imac-unknown-xous-elf) { Remove-Item -Recurse -Force lib\rustlib\riscv32imac-unknown-xous-elf }
Invoke-WebRequest -Uri https://github.com/betrusted-io/rust/releases/latest/download/riscv32imac-unknown-xous_1.70.0.zip -Outfile toolchain.zip
Expand-Archive -DestinationPath . -Path toolchain.zip
Remove-Item toolchain.zip
Pop-Location

Building From Source

  1. Install a RISC-V toolchain, and ensure it's in your path. Set CC and AR to point to the toolchain's -gcc and -ar binaries.
  2. Set RUST_COMPILER_RT_ROOT to $(pwd)/src/llvm-project/compiler-rt
  3. Patch src/llvm-project/compiler-rt/lib/builtins/int_types.h to remove #define CRT_HAS_128BIT.
  4. Copy riscv32imac-unknown-xous-elf.json to your Rust sysroot under a new target directory. This can be done on Unix-like systems by running:
mkdir -p $(rustc --print sysroot)/lib/rustlib/riscv32imac-unknown-xous-elf/lib
cp riscv32imac-unknown-xous-elf.json $(rustc --print sysroot)/lib/rustlib/riscv32imac-unknown-xous-elf/target.json
  1. Compile the standard library:
CARGO_PROFILE_RELEASE_DEBUG=0 \
CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS=false \
RUSTC_BOOTSTRAP=1 \
__CARGO_DEFAULT_LIB_METADATA=stablestd \
cargo build \
    --target riscv32imac-unknown-xous-elf \
    -Zbinary-dep-depinfo \
    --release \
    --features "panic-unwind backtrace compiler-builtins-c compiler-builtins-mem" \
    --manifest-path "library/test/Cargo.toml"
  1. Install the standard library to your new sysroot:
mkdir -p $(rustc --print sysroot)/lib/rustlib/riscv32imac-unknown-xous-elf/lib/
cp target/riscv32imac-unknown-xous-elf/release/deps/*.rlib $(rustc --print sysroot)/lib/rustlib/riscv32imac-unknown-xous-elf/lib/
  1. Use the new stdlib by setting --target:
cargo build --target riscv32imac-unknown-xous-elf

Building on Windows Powershell

On Windows, you can use the rebuild.ps1 script to build and install this package. You will need to have a Riscv compiler in your path.

Run rebuild.ps1. It is recommended that you run it under a new shell in order to avoid polluting your environment with Rust-specific variables:

powershell .\rebuild.ps1

Alternately, you can run the following commands to manually build things:

$env:RUST_TARGET_PATH=$(rustc --print sysroot)
Copy-Item riscv32imac-unknown-xous-elf.json $env:RUST_TARGET_PATH
$env:CARGO_PROFILE_RELEASE_DEBUG=0
$env:CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS="false"
$env:RUSTC_BOOTSTRAP=1
$env:__CARGO_DEFAULT_LIB_METADATA="stablestd"
Remove-Item .\target\riscv32imac-unknown-xous-elf\release\deps\*.rlib
cargo build `
    --target riscv32imac-unknown-xous-elf `
    -Zbinary-dep-depinfo `
    --release `
    --features "panic-unwind backtrace compiler-builtins-c compiler-builtins-mem" `
    --manifest-path "library/test/Cargo.toml"
New-Item -Type Directory -Path "$env:RUST_TARGET_PATH\lib\rustlib\riscv32imac-unknown-xous-elf\lib"
Remove-Item "$env:RUST_TARGET_PATH\lib\rustlib\riscv32imac-unknown-xous-elf\lib\*.rlib"
Copy-Item target\riscv32imac-unknown-xous-elf\release\deps\*.rlib "$env:RUST_TARGET_PATH\lib\rustlib\riscv32imac-unknown-xous-elf\lib"

rust's People

Contributors

bors avatar ralfjung avatar matklad avatar brson avatar alexcrichton avatar matthiaskrgr avatar guillaumegomez avatar oli-obk avatar centril avatar nikomatsakis avatar manishearth avatar bjorn3 avatar dylan-dpc avatar johntitor avatar pcwalton avatar graydon avatar nrc avatar estebank avatar eddyb avatar petrochenkov avatar kennytm avatar veykril avatar steveklabnik avatar mark-simulacrum avatar topecongiro avatar cjgillot avatar catamorphism avatar compiler-errors avatar flip1995 avatar jonas-schievink avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.