23 lines
805 B
Nix
23 lines
805 B
Nix
{ rustPlatform, rust-riscv32imc-crates, binutils-riscv }:
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
name = "helloworld";
|
|
version = "0.0.0";
|
|
|
|
src = ./.;
|
|
cargoSha256 = "1j8ipk7mwf6jqjnddpvkdydhgl7lfddxkv6p1vhzlfhqlf8am42j";
|
|
|
|
buildPhase = ''
|
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
|
export RUSTFLAGS="-L ${rust-riscv32imc-crates}/lib/rustlib/riscv32imc-unknown-none-elf/lib -C linker=${binutils-riscv}/bin/riscv32-unknown-elf-ld -C link-arg=-Tlink.x"
|
|
cargo build --release --target riscv32imc-unknown-none-elf
|
|
'';
|
|
|
|
doCheck = false;
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp target/riscv32imc-unknown-none-elf/release/helloworld $out
|
|
${binutils-riscv}/bin/riscv32-unknown-elf-objcopy -O binary target/riscv32imc-unknown-none-elf/release/helloworld $out/helloworld.bin
|
|
'';
|
|
}
|