Fix build compatibility with CMake 4, GCC 15, and MSVC#600
Open
imheresamir wants to merge 4 commits into
Open
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.
Author
|
@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!! |
Open
Member
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.