fwsGonzo / libriscv

The fastest RISC-V sandbox
BSD 3-Clause "New" or "Revised" License
526 stars 46 forks source link

MSVC compatibility #90

Closed fwsGonzo closed 7 months ago

fwsGonzo commented 1 year ago

Slowly moving towards full MSVC compatibility. Currently it is possible to build 32- and 64-bit for Clang-cl. There is also a minimal system call implementation available.

Zylann commented 1 year ago

Just curious, where does the limitation come from that MSVC would not work? Is it because of system calls? (what if the use case involves simulating RISC-V in a fictive computer, therefore not using real system calls?)

fwsGonzo commented 1 year ago

There seemed to be a build error when using inline static constexpr std::array to initialize all the system call handlers to a default handler that prints "Unhandled system call". It avoids a null-check on the handlers.

Other than that, I can't remember anything. It used to be much harder because 128-bit was always present, but it's now behind a CMake option so I think that MSVC support is much more straight-forward now. That said, I don't really have Windows, so I have limited ability to test (and also limited experience).

fwsGonzo commented 8 months ago

I marked this as help wanted as I still haven't been able to find myself sitting on a Windows machine lately.

fwsGonzo commented 7 months ago

I made a second attempt at MSVC support and this time I am running programs with full 32-bit and 64-bit support. That is, RV32GCB and RV64GCB, so no 128-bit support. Screenshot from 2023-11-14 19-22-07

The MSVC example has been improved a bit: https://github.com/fwsGonzo/libriscv/blob/master/examples/msvc/main.cpp It requires clang-cl to work, but that's the only choice for CMake projects, I believe. I ran 32- and 64-bit programs, including the CLI debugger.

At this point I consider MSVC to be fully supported. It doesn't have all the system calls needed for multi-threading, but that's a saga for another time.