riscv / sail-riscv

Sail RISC-V model
https://lists.riscv.org/g/tech-golden-model
Other
429 stars 158 forks source link

Switch to CMake #551

Open Timmmm opened 11 hours ago

Timmmm commented 11 hours ago

I think we should switch from Make to CMake. This would have a number of benefits:

  1. We can easily make the arch part of the targets instead of a Make parameter. I.e. instead of
ARCH=RV32 make c_emulator/riscv_sim_RV32
ARCH=RV64 make c_emulator/riscv_sim_RV64

you can do

make -j2 c_emulator/riscv_sim_RV32 c_emulator/riscv_sim_RV64

which is less redundant and confusing, and also easier to do in parallel (this would half CI time).

  1. We can use CTest. This allows running tests in parallel, uploading JUnit results to Github, etc.
  2. CMake - while pretty shit on an absolute scale - is much nicer to use than Make. E.g. generating a compile_commands.json for IDEs is one line, as is enabling LTO, PIC, etc. It supports splitting your build config into multiple files in a sane way.
  3. CMake is pretty much a de facto standard at this point and has native support from lots of IDEs.
jrtc27 commented 10 hours ago

You can do 1 already in Make if you write the file properly, we have that in sail-cheri-riscv.

jrtc27 commented 10 hours ago

3 and 4 don’t seem very relevant, there’s no IDE for Sail, and the C is extremely basic, it doesn’t warrant an IDE.

jrtc27 commented 10 hours ago

That leaves 2, for which using CMake seems a bit overkill?

Timmmm commented 9 hours ago

You can do 1 already in Make if you write the file properly, we have that in sail-cheri-riscv.

Ah you mean this? We should do that in this repo if we don't move to CMake at least. Still it is definitely easier in CMake (just do a loop over the architectures).

the C is extremely basic, it doesn’t warrant an IDE.

I would like to use an IDE with it please! I don't feel like I should not have nice tools just because it's only 2k lines of code (so far).

That leaves 2, for which using CMake seems a bit overkill?

I still think the other benefits are significant. We've been using CMake internally and it's a much nicer experience. Are there any downsides (apart from having to run cmake)?

arichardson commented 1 hour ago

I also think this would be nice.

CTest is a bit awkward to use but having a real test driver is definitely worthwhile.

I also use CLion for the sail C code and it has basic syntax highlighting for sail if you import the sail syntax files (https://github.com/rems-project/sail?tab=readme-ov-file#editor-support).

I think point 2 is a strong enough reason and I am definitely supportive of this change.