fusesoc icon indicating copy to clipboard operation
fusesoc copied to clipboard

bazel based fusesoc

Open Dan10012 opened this issue 4 years ago • 10 comments

Hi,

During COVID lockdown people in my team ended up creating a POC of a build system similar to fusesoc, but using bazel.

I want to discuss the possibility to migrate fusesoc to use basel. For myself I'm unsure about pros & cons of the current python implementation, though I can elaborate on bazel (superficially, as I wasn't part of the group working on the build system).

Bazel is an open source build system by Google, designed to be language-agnostic, configurable to the specific use by rules (written in Starlark, a derivative of python).

Bazel brings to the table:

  • Sandboxing - building in a sandbox environmnet, where files / other env dependencies not explicitly specified can't be accessed. This prevents having hidden dependancies which can harm reproduceability.

  • Transitive dependencies - Internal packages dependendy in a project (workspace, sort of equivalent to git repo) is transitive. External dependencies are also supported, but they are not transitive (A depends on B depends on C + A depends on D depends on C might might lead to A depending on 2 different versions of C). So instead bazel demands explicit dependency of external transitive ones.

  • Parallel Execution - bazel parallelizes independent build procceses, which leads to faster builds. (This can be useful with regressions for example)

  • Smart Cache - bazel tracks changes in source files and together with the dependency graph it creats, it keeps tabs on what portions of the build proccess should be redone. This also results in faster builds.

This issue is mainly to discuss this possibility and pros & cons, as I'm really impressed with the fusesoc project but I don't have the technical knowledge of fusesoc current implementation to judge if the bazel option is good.

Regarding our implementation: I can say that we are using the POC to simulate in vcs, generate modules, run regressions in CI, and working towards integrating it with our PnR python wrapper (which seems close to edalize). All configured similarly to how fusesoc does it (with equvalent to core files specifying targets etc...)

Unfortunately my workplace have a seperate network and it will be hard bringing out the bazel rules code (I'll have to ask not only legal premission but also security-wise...). There may be an early version of it using verilator that isn't in the seperate network. I'll see what I can do.

For the meantime you can look at Bazel's documentation , and maybe in this example I've found today (which I'm unsure how good it is).

Dan10012 avatar Sep 26 '21 09:09 Dan10012

Have you seen https://github.com/hdl/bazel_rules_hdl ?

mithro avatar Sep 27 '21 15:09 mithro

While Bazel has a lot of nice features, it is a very heavy dependency. I doubt it would be a good idea for FuseSoC to require it. However, (optional) FuseSoC and Bazel integration sounds like a good idea.

mithro avatar Sep 27 '21 15:09 mithro