firrtl icon indicating copy to clipboard operation
firrtl copied to clipboard

Support RiscV host

Open tmagik opened this issue 6 years ago • 4 comments

Type of issue: other enhancement

  • What is the current behavior? 'make -f Makefile.veraiofpga' from https://github.com/sifive/freedom fails on a RiscV host with 'unknown os.arch: riscv64' error
[error] java.lang.RuntimeException: error occurred while compiling protobuf files: unknown os.arch: riscv64
[error] 	at sbtprotobuf.ScopedProtobufPlugin.executeProtoc(ProtobufPlugin.scala:99)
[error] 	at sbtprotobuf.ScopedProtobufPlugin.compile(ProtobufPlugin.scala:115)
[error] 	at sbtprotobuf.ScopedProtobufPlugin.$anonfun$sourceGeneratorTask$3(ProtobufPlugin.scala:157)
[error] 	at sbt.util.FileFunction$.$anonfun$cached$1(FileFunction.scala:73)
[error] 	at sbt.util.FileFunction$.$anonfun$cached$4(FileFunction.scala:147)
  • What is the expected behavior? command completes the same as on x86 host
  • Please tell us about your environment:
    • version: commit abaa38f4f63b35105796916e3df2ccf5c1639f65 (HEAD) Author: Jack Koenig <[email protected]> Date: Thu Aug 23 18:19:47 2018 -0700
    • OS: Linux buildroot 4.15.0-00048-gfe92d7905c6e #6 SMP Wed Sep 5 03:57:45 UTC 2018 riscv64 GNU/Linux

What is the use case for changing the behavior? A RiscV host should be able to compile rocket-chip

Impact: unknown

Development Phase: request

Other information: https://github.com/sifive/freedom

tmagik avatar Sep 23 '18 23:09 tmagik

It looks like this is due to the ProtoBuf implementation and is fixed: https://github.com/protocolbuffers/protobuf/issues/4425

Can you try updating the version used by FIRRTL and see if that fixes the issue? https://github.com/freechipsproject/firrtl/blob/7b4bde7e9942e9a25fd730ace5a8c6369707085e/build.sbt#L78

I should note that as far as I know, there is no JVM JIT yet for RISC-V, so I suspect this is going to run really slowly.

jackkoenig avatar Sep 26 '18 18:09 jackkoenig

I bumped to '-v361' which is now very slowly building, so maybe this will work if the top-level Makefile understands it needs to rebuild firrtl now...

tmagik avatar Oct 01 '18 16:10 tmagik

Great! Would you like to PR these changes?

jackkoenig avatar Oct 04 '18 17:10 jackkoenig

It appears that build.sc is relying on protobuf's release artifacts, which unfortunately still don't provide a riscv64 binary as of today.

https://github.com/chipsalliance/firrtl/blob/master/build.sc#L241

I am sed'ing out the versions to match system protobuf on Arch, and successfully compiled firrtl on both x86_64 and riscv64.

https://github.com/archlinux/svntogit-community/commit/e0f33c41b857f8cbee25f6083a5a256fa7d7dabc

I have also tried to alter the checkSystemProtocVersion flag only, which unfortunately doesn't work because protocVersion affects also the version of com.google.protobuf:protobuf-java and breaks when they don't match.

Do you think it a good idea to just set protocVersion to systemProtocVersion when they don't match, but checkSystemProtocVersion is falsy?

felixonmars avatar Oct 25 '22 23:10 felixonmars