Fix build compatibility with CMake 4, GCC 15, and MSVC#600
Conversation
Adapted from NixOS/nixpkgs#450265
Adapted from NixOS/nixpkgs#450265
…alizers Keystone's MCRegisterClass retains the RegSize and Alignment fields from the LLVM 4.0 era, before they were moved to TargetRegisterInfo in LLVM 5.0 (D31783) and eventually removed from MCRegisterClass entirely in LLVM 7.0 (rL339350). The RISCV backend was ported from a newer LLVM snapshot where these fields no longer existed, so RISCVGenRegisterInfo.inc was generated without them, causing a member count mismatch against keystone's MCRegisterClass definition and a compile error on MSVC (C3852). Add the missing RegSize and Alignment values to each register class initializer to match the layout expected by MCRegisterClass. The values chosen reflect the natural register width of each class (4 bytes for FPR32, 8 bytes for all others). These fields are structurally required to satisfy the initializer but are never consulted by the assembler — spill slot calculations belong to the codegen layer which keystone does not include. All other architectures in keystone were ported from pre-LLVM-5.0 and have correct initializers. This change makes RISCV consistent with them.
|
@wtdcode Hi, when you get a chance would you mind taking a look at this small PR to fix the master branch build pipeline please? It would help a lot of downstream projects. Thanks!! |
|
I put my response here as well for completeness. Well, the answer is somewhat obvious in this case, but honestly, I have been monitoring the issues and pull requests here since I took on responsibility from Quynh. The fact is that I simply lack time, as a Ph.D. student in my last year, during this stage. I know this answer is not ideal, but I sincerely apologize for it. Regarding maintenance, I hope to be back to both Unicorn and Keystone here soon, but I can not guarantee it. |
|
@wtdcode I hope you or somebody else will merge this PR or fix on your own the issue with building with the current CMake and compiler versions soon, because patience is wearing thin after so long a time of just waiting. I'm literally forced to patch this project everywhere, where it used, I just can't wait now |
| // NOTE: Manually patched for keystone. RegSize/Alignment fields added to match | ||
| // the LLVM 4.0-era MCRegisterClass layout used by this fork. These values are | ||
| // not used by the assembler (no spill slot allocation) so correctness of the | ||
| // values is not critical. |
There was a problem hiding this comment.
Can we trim or delete this ai comment
This PR applies several small patches to fix build failures across different compilers and build systems.
CMake 4 and GCC 15 fixes (taken unaltered from NixOS/nixpkgs#450265):
MSVC fixes for the RISCV backend:
LLVM_CONSTEXPRwas not defined for MSVC since the existing checks__has_feature(cxx_constexpr)anddefined(__GXX_EXPERIMENTAL_CXX0X__)are GCC/Clang-specific.Added a
defined(_MSC_VER)check so that array_lengthof is correctly marked constexpr on MSVC, fixing a static_assert compile error in RISCVAsmBackend.h.RISCVGenRegisterInfo.inc was generated from a newer LLVM snapshot where
RegSizeandAlignmenthad already been removed fromMCRegisterClass(upstream removal in rL339350, LLVM 7.0).Keystone's
MCRegisterClassretains these fields from the LLVM 4.0 era, causing a member count mismatch and MSVC error C3852.Added the missing fields to each register class initializer to match keystone's struct layout. These values are never consulted by the assembler — spill slot calculations belong to the codegen layer which keystone does not include.