fabianschuiki / moore

A hardware compiler based on LLHD and CIRCT
http://www.llhd.io
Apache License 2.0
246 stars 31 forks source link

Desync between cargo build and repo. #248

Open samerogers opened 2 years ago

samerogers commented 2 years ago

I recently downloaded moore to test it out and have been having issues with building it. One thing I noticed while working through my build errors is that there is a significant desync between the files downloaded by cargo and the files in the repo. For instance in src/circt-sys/wrapper.cpp:15 the repo version has IntegerAttr::get(intType, APInt(tmpWidth, valueStr, 10).trunc(intWidth))); but the version downloaded by cargo has IntegerAttr::get(intType, APInt(tmpWidth, valueStr, 10).truncOrSelf(intWidth))); I've notice several other issues, but it looks like a large number of them may be fixed by fixing the repo version that cargo is pulling.

EDIT: I see that the latest release tag is 0.14.0, however this tagged build is incompatible with the current release of LLVM and CIRCT.

fabianschuiki commented 2 years ago

Hey @samerogers, thanks for reporting this. The integration of LLVM and CIRCT is pretty delicate dance due to the fast-paced development style on the LLVM side. As a rule of thumb, Moore only really works with the exact commit of CIRCT and LLVM that is pointed at by the submodule in this repository. There are a lot of rapid, breaking changes that happen upstream regularly, with very little stability guarantee. At some point in the future we'll be able to point the Moore repo at more strict release tags of CIRCT (once CIRCT starts to do actual releases), but in the current phase of rapid iteration we have to make due with arbitrary but known-good commits that we point to.

One unsolved probleme here is the challenge of installing Moore through cargo install moore. That does fetch the repo properly with the correct CIRCT checkout, but the moore-circt-sys crate then builds against whatever local installation of CIRCT and LLVM you have (pointed to by a few env vars checked in src/circt-sys/build.rs). This is likely not the right version and will probably break the installation. The only way to make this work as of now is to manually clone the Moore repo, do an LLVM and CIRCT build in the circt submodule, and then run cargo install --path . in the Moore repo with the env vars pointing at the circt submodule build dir. (The scripts in the .github/ directory do this automatically for CI, and should also work locally.)

Ideally we'd have a mode where cargo install moore would actually properly build the correct LLVM and CIRCT commit as part of compiling moore-circt-sys.

snarlawar123 commented 1 year ago

Hey @samerogers, thanks for reporting this. The integration of LLVM and CIRCT is pretty delicate dance due to the fast-paced development style on the LLVM side. As a rule of thumb, Moore only really works with the exact commit of CIRCT and LLVM that is pointed at by the submodule in this repository. There are a lot of rapid, breaking changes that happen upstream regularly, with very little stability guarantee. At some point in the future we'll be able to point the Moore repo at more strict release tags of CIRCT (once CIRCT starts to do actual releases), but in the current phase of rapid iteration we have to make due with arbitrary but known-good commits that we point to.

One unsolved probleme here is the challenge of installing Moore through cargo install moore. That does fetch the repo properly with the correct CIRCT checkout, but the moore-circt-sys crate then builds against whatever local installation of CIRCT and LLVM you have (pointed to by a few env vars checked in src/circt-sys/build.rs). This is likely not the right version and will probably break the installation. The only way to make this work as of now is to manually clone the Moore repo, do an LLVM and CIRCT build in the circt submodule, and then run cargo install --path . in the Moore repo with the env vars pointing at the circt submodule build dir. (The scripts in the .github/ directory do this automatically for CI, and should also work locally.)

Ideally we'd have a mode where cargo install moore would actually properly build the correct LLVM and CIRCT commit as part of compiling moore-circt-sys.

@fabianschuiki - I followed all the above steps as mentioned but I am getting below error while running - cargo install --path .

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/hir/lib.rs:21:35
   |
21 |     units: Vec<&'t LatentNode<'t, Node<'t>>>,
   |                                   ^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/hir/pkg.rs:14:35
   |
14 |     decls: Vec<&'t LatentNode<'t, Decl2<'t>>>,
   |                                   ^^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/scope2.rs:26:34
   |
26 |     Node(&'t hir::LatentNode<'t, Node<'t>>),
   |                                  ^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
   --> src/vhdl/debug.rs:134:41
    |
134 | impl<'a, 'b, 't: 'a> AllocOwned<'b, 't, konst2::Const2<'t>> for &'a TypeVisitor<'t> {
    |                                         ^^^^^^^^^^^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
   --> src/vhdl/debug.rs:140:41
    |
140 | impl<'a, 'b, 't: 'a> AllocOwned<'b, 't, ty2::Type> for &'a TypeVisitor<'t> {
    |                                         ^^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/hir/expr.rs:32:26
   |
32 |     + AllocOwnedInto<'t, Const2<'t>>
   |                          ^^^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/hir/expr.rs:33:26
   |
33 |     + AllocOwnedInto<'t, Type>
   |                          ^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/hir/expr.rs:40:30
   |
40 |         + AllocOwnedInto<'t, Const2<'t>>
   |                              ^^^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/hir/expr.rs:41:30
   |
41 |         + AllocOwnedInto<'t, Type>
   |                              ^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/hir/lib.rs:62:49
   |
62 |     pub fn units(&self) -> &[&'t LatentNode<'t, Node<'t>>] {
   |                                                 ^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/hir/pkg.rs:25:49
   |
25 |     pub fn decls(&self) -> &[&'t LatentNode<'t, Decl2<'t>>] {
   |                                                 ^^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/konst2/arena.rs:16:29
   |
16 | impl<'t> AllocOwned<'t, 't, Const2<'t>> for ConstArena<'t> {
   |                             ^^^^^^^^^^

error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an 
explicit bound
  --> src/vhdl/ty2/arena.rs:27:29
   |
27 | impl<'t> AllocOwned<'t, 't, Type> for TypeArena<'t> {
   |                             ^^^^