Skip to content

Fix build compatibility with CMake 4, GCC 15, and MSVC#600

Open
imheresamir wants to merge 4 commits into
keystone-engine:masterfrom
imheresamir:master
Open

Fix build compatibility with CMake 4, GCC 15, and MSVC#600
imheresamir wants to merge 4 commits into
keystone-engine:masterfrom
imheresamir:master

Conversation

@imheresamir

@imheresamir imheresamir commented Apr 29, 2026

Copy link
Copy Markdown

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):

  • Fixes build breakage introduced by CMake 4's stricter policy handling
  • Fixes build breakage with GCC 15

MSVC fixes for the RISCV backend:

  • LLVM_CONSTEXPR was not defined for MSVC since the existing checks __has_feature(cxx_constexpr) and defined(__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 RegSize and Alignment had already been removed from MCRegisterClass (upstream removal in rL339350, LLVM 7.0).

    Keystone's MCRegisterClass retains 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.

…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.
@imheresamir imheresamir changed the title keystone: fix build with cmake 4 & gcc15 Fix build compatibility with CMake 4, GCC 15, and MSVC Apr 29, 2026
@imheresamir

Copy link
Copy Markdown
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!!

@retornam

Copy link
Copy Markdown

@aquynh @amaanq @kabeor @xwings @wtdcode is this project dead or no longer maintained? there have been a few PRs like this one that would benefit may downstream projects that have been sitting unreviewed and unmerged for months.

@sskras sskras mentioned this pull request Jun 18, 2026
@wtdcode

wtdcode commented Jun 19, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants