clean up firmware compilation

This commit is contained in:
Sebastien Bourdeauducq 2019-06-09 00:05:40 +08:00
parent fd05fa560f
commit d9b42a0807
2 changed files with 4 additions and 7 deletions

View File

@ -1,4 +1,4 @@
{ rustPlatform, rust-riscv32i-crates, binutils-riscv32, rustc, cargo }: { rustPlatform, rust-riscv32i-crates, binutils-riscv32 }:
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
name = "helloworld"; name = "helloworld";
@ -7,14 +7,10 @@ rustPlatform.buildRustPackage rec {
src = ./.; src = ./.;
cargoSha256 = "0kf2pnfylfmzm0qvi4jfci43qvrnj1v5f037sb9zpvfqyddhdffl"; cargoSha256 = "0kf2pnfylfmzm0qvi4jfci43qvrnj1v5f037sb9zpvfqyddhdffl";
# HACK - rustc overlay does not update rustPlatform. Find out why.
configurePhase = ''echo XXX ${rustPlatform.rust.rustc} ${rustPlatform.rust.cargo}'';
buildPhase = '' buildPhase = ''
export CARGO_HOME=$(mktemp -d cargo-home.XXX) export CARGO_HOME=$(mktemp -d cargo-home.XXX)
export RUSTFLAGS="-L ${rust-riscv32i-crates}/lib/rustlib/riscv32i-unknown-none-elf/lib -C linker=${binutils-riscv32}/bin/riscv32-unknown-elf-ld -C link-arg=-Tlink.x" export RUSTFLAGS="-L ${rust-riscv32i-crates}/lib/rustlib/riscv32i-unknown-none-elf/lib -C linker=${binutils-riscv32}/bin/riscv32-unknown-elf-ld -C link-arg=-Tlink.x"
export RUSTC=${rustc}/bin/rustc cargo build --release --target riscv32i-unknown-none-elf
${cargo}/bin/cargo build --release --target riscv32i-unknown-none-elf
''; '';
doCheck = false; doCheck = false;

View File

@ -1,5 +1,5 @@
self: super: self: super:
{ rec {
llvm_7 = super.llvm_7.overrideAttrs(oa: { llvm_7 = super.llvm_7.overrideAttrs(oa: {
name = oa.name + "-riscv"; name = oa.name + "-riscv";
cmakeFlags = oa.cmakeFlags ++ ["-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=RISCV"]; cmakeFlags = oa.cmakeFlags ++ ["-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=RISCV"];
@ -7,4 +7,5 @@ self: super:
rustc = super.rustc.overrideAttrs(oa: { rustc = super.rustc.overrideAttrs(oa: {
patches = oa.patches ++ [ ./compilers/rustc-riscv32i.patch ]; patches = oa.patches ++ [ ./compilers/rustc-riscv32i.patch ];
}); });
rustPlatform = super.makeRustPlatform { inherit rustc; inherit (super) cargo; };
} }