Skip to content

Commit

Permalink
util: nix support (dirty fix not eliminated)
Browse files Browse the repository at this point in the history
  • Loading branch information
SharzyL authored and sequencer committed Oct 27, 2022
1 parent 9344741 commit 3f08a61
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ object cases extends Module {
PathRef(T.ctx.dest / "linker.ld")
}
def compile: T[PathRef] = T {
os.proc(Seq("clang", "-o", name() + ".elf" ,"--target=riscv32", "-march=rv32gcv", s"-L${musl.compile().path}/lib", s"-L${compilerrt.compile().path}/lib/riscv32", "-mno-relax", s"-T${linkScript().path}") ++ allSourceFiles().map(_.path.toString)).call(T.ctx.dest)
os.proc(Seq("/nix/store/jfliw7lqqfchrmnb21xi5d5pmxk1lvyg-clang-14.0.6/bin/clang", "-o", name() + ".elf" ,"--target=riscv32", "-march=rv32gcv", s"-L${musl.compile().path}/lib", s"-L${compilerrt.compile().path}/lib/riscv32", "-mno-relax", s"-T${linkScript().path}") ++ allSourceFiles().map(_.path.toString)).call(T.ctx.dest)
os.proc(Seq("llvm-objcopy", "-O", "binary", "--only-section=.text", name() + ".elf", name())).call(T.ctx.dest)
PathRef(T.ctx.dest / name())
}
Expand Down
65 changes: 65 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{ pkgs ? import <nixpkgs> {}}:

let
myLLVM = pkgs.llvmPackages_14;
espresso = pkgs.stdenv.mkDerivation rec {
pname = "espresso";
version = "2.4";
nativeBuildInputs = [ pkgs.cmake ];
src = pkgs.fetchFromGitHub {
owner = "chipsalliance";
repo = "espresso";
rev = "v${version}";
sha256 = "sha256-z5By57VbmIt4sgRgvECnLbZklnDDWUA6fyvWVyXUzsI=";
};
};
circt = pkgs.stdenv.mkDerivation rec {
pname = "circt";
version = "r4396.ce85204ca";
nativeBuildInputs = with pkgs; [ cmake ninja python3 git ];
src = pkgs.fetchFromGitHub {
owner = "llvm";
repo = "circt";
rev = "da364ea448b70aaa710f9e17063ed745db23b463";
sha256 = "sha256-oS+wh/hJeJcXj5RoxsUOOX8wMsxgMAMdQtPpyENO0JM=";
fetchSubmodules = true;
};
cmakeFlags = [
"-S/build/source/llvm/llvm"
"-DLLVM_ENABLE_PROJECTS=mlir"
"-DBUILD_SHARED_LIBS=OFF"
"-DLLVM_STATIC_LINK_CXX_STDLIB=ON"
"-DLLVM_ENABLE_ASSERTIONS=ON"
"-DLLVM_BUILD_EXAMPLES=OFF"
"-DLLVM_ENABLE_BINDINGS=OFF"
"-DLLVM_ENABLE_OCAMLDOC=OFF"
"-DLLVM_OPTIMIZED_TABLEGEN=ON"
"-DLLVM_EXTERNAL_PROJECTS=circt"
"-DLLVM_EXTERNAL_CIRCT_SOURCE_DIR=/build/source"
"-DLLVM_BUILD_TOOLS=ON"
];
installPhase = ''
mkdir -p $out/bin
mv bin/firtool $out/bin/firtool
'';
};

in pkgs.mkShellNoCC {
name = "vector";
buildInputs = with pkgs; [
myLLVM.clang
myLLVM.llvm
myLLVM.bintools

jdk mill python3
parallel protobuf ninja verilator antlr4 numactl dtc glibc_multi cmake
espresso
circt

git cacert # make cmake fetchContent happy
fmt glog
];
shellHook = ''
export NIX_CC=" "
''; # due to some cmake bug
}

0 comments on commit 3f08a61

Please sign in to comment.