1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
From 41197bc85d6b95de3345f5a09d321469c2bba58e Mon Sep 17 00:00:00 2001
From: Jordan Moore <lockbox@struct.foo>
Date: Mon, 2 Jun 2025 16:36:27 -0400
Subject: [PATCH 1/5] fix: cstdint explicitly included when used
* fixes error in gcc15 where this header is no longer
implicitly included
---
llvm/include/llvm/ADT/STLExtras.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 3346de93..a2adf853 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -21,6 +21,7 @@
#include <algorithm> // for std::all_of
#include <cassert>
#include <cstddef> // for std::size_t
+#include <cstdint>
#include <cstdlib> // for qsort
#include <functional>
#include <iterator>
From f3f792cc05080a4bcc3c2886c0c7cee9294c4a05 Mon Sep 17 00:00:00 2001
From: Jordan Moore <lockbox@struct.foo>
Date: Mon, 2 Jun 2025 16:58:31 -0400
Subject: [PATCH 2/5] fix: build with modern cmake
---
CMakeLists.txt | 19 +------------------
kstool/CMakeLists.txt | 2 +-
llvm/CMakeLists.txt | 15 +--------------
3 files changed, 3 insertions(+), 33 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 938d4983..9ce08362 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
# Keystone Assembler Engine (www.keystone-engine.org)
# By Nguyen Anh Quynh, 2016
-cmake_minimum_required(VERSION 2.8.7)
+cmake_minimum_required(VERSION 3.10.0)
project(keystone)
set(KEYSTONE_VERSION_MAJOR 0)
@@ -15,23 +15,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug")
endif()
-if (POLICY CMP0022)
- cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
-endif()
-
-if (POLICY CMP0051)
- # CMake 3.1 and higher include generator expressions of the form
- # $<TARGETLIB:obj> in the SOURCES property. These need to be
- # stripped everywhere that access the SOURCES property, so we just
- # defer to the OLD behavior of not including generator expressions
- # in the output for now.
- cmake_policy(SET CMP0051 OLD)
-endif()
-
-if (POLICY CMP0063)
- set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) # automatic when 3.3.2 is required
-endif()
-
if (CMAKE_VERSION VERSION_LESS 3.1.20141117)
set(cmake_3_2_USES_TERMINAL)
else()
diff --git a/kstool/CMakeLists.txt b/kstool/CMakeLists.txt
index d28da481..25113821 100644
--- a/kstool/CMakeLists.txt
+++ b/kstool/CMakeLists.txt
@@ -1,7 +1,7 @@
# Kstool for Keystone assembler engine.
# By Nguyen Anh Quynh, 2016
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.10.0)
project(kstool)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index d926b082..518613a5 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1,6 +1,6 @@
# See docs/CMake.html for instructions about how to build LLVM with CMake.
-cmake_minimum_required(VERSION 2.8.7)
+cmake_minimum_required(VERSION 3.10.0)
set(LLVM_INSTALL_TOOLCHAIN_ONLY ON)
@@ -9,19 +9,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug")
endif()
-if(POLICY CMP0022)
- cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
-endif()
-
-if (POLICY CMP0051)
- # CMake 3.1 and higher include generator expressions of the form
- # $<TARGETLIB:obj> in the SOURCES property. These need to be
- # stripped everywhere that access the SOURCES property, so we just
- # defer to the OLD behavior of not including generator expressions
- # in the output for now.
- cmake_policy(SET CMP0051 OLD)
-endif()
-
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
set(cmake_3_2_USES_TERMINAL)
else()
From 4e2fcaa8fad81fc6016bd4d7d245d04719195381 Mon Sep 17 00:00:00 2001
From: Jordan Moore <lockbox@struct.foo>
Date: Mon, 2 Jun 2025 17:49:30 -0400
Subject: [PATCH 3/5] fix: bindings: rust: moderize and format
---
bindings/rust/Cargo.toml | 1 +
bindings/rust/keystone-sys/Cargo.toml | 1 +
bindings/rust/keystone-sys/build.rs | 2 +-
bindings/rust/keystone-sys/src/lib.rs | 14 ++------------
bindings/rust/src/lib.rs | 2 +-
5 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml
index 3342e5a1..013a6e9d 100644
--- a/bindings/rust/Cargo.toml
+++ b/bindings/rust/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "keystone"
version = "0.9.2"
+edition = "2018"
authors = [
"Remco Verhoef <remco.verhoef@dutchcoders.io>",
"Tasuku SUENAGA a.k.a. gunyarakun <tasuku-s-github@titech.ac>"
diff --git a/bindings/rust/keystone-sys/Cargo.toml b/bindings/rust/keystone-sys/Cargo.toml
index a836c305..7b88aff6 100644
--- a/bindings/rust/keystone-sys/Cargo.toml
+++ b/bindings/rust/keystone-sys/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "keystone-sys"
version = "0.9.2"
+edition = "2018"
authors = [
"Remco Verhoef <remco.verhoef@dutchcoders.io>",
"Tasuku SUENAGA a.k.a. gunyarakun <tasuku-s-github@titech.ac>"
diff --git a/bindings/rust/keystone-sys/build.rs b/bindings/rust/keystone-sys/build.rs
index 9670fcb3..a92a41f2 100644
--- a/bindings/rust/keystone-sys/build.rs
+++ b/bindings/rust/keystone-sys/build.rs
@@ -17,7 +17,7 @@ fn build_with_cmake() {
// This only happens when using the crate via a `git` reference as the
// published version already embeds keystone's source.
let pwd = std::env::current_dir().unwrap();
- let keystone_dir = pwd.ancestors().skip(3).next().unwrap();
+ let keystone_dir = pwd.ancestors().nth(3).unwrap();
symlink(keystone_dir, "keystone").expect("failed to symlink keystone");
}
diff --git a/bindings/rust/keystone-sys/src/lib.rs b/bindings/rust/keystone-sys/src/lib.rs
index 6eb282a6..8bd5eefd 100644
--- a/bindings/rust/keystone-sys/src/lib.rs
+++ b/bindings/rust/keystone-sys/src/lib.rs
@@ -10,19 +10,9 @@ extern crate libc;
pub mod keystone_const;
+use ::libc::{c_char, c_int, c_uchar, c_uint, size_t};
+use ::std::{ffi::CStr, fmt, ptr};
use keystone_const::{Arch, Error, Mode, OptionType, OptionValue};
-use ::std::{
- ffi::CStr,
- fmt,
- ptr,
-};
-use ::libc::{
- c_char,
- c_uchar,
- c_int,
- c_uint,
- size_t,
-};
/// Opaque type representing the Keystone engine
#[repr(C)]
diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs
index dd5bd042..dc8cd5e0 100644
--- a/bindings/rust/src/lib.rs
+++ b/bindings/rust/src/lib.rs
@@ -90,7 +90,7 @@ impl Keystone {
let err = unsafe { ffi::ks_open(arch, mode, &mut handle) };
if err == Error::OK {
Ok(Keystone {
- handle: handle.expect("Got NULL engine from ks_open()")
+ handle: handle.expect("Got NULL engine from ks_open()"),
})
} else {
Err(err)
From bf3b00fba5a32bba3b3f7fb1d54e374338614a96 Mon Sep 17 00:00:00 2001
From: Jordan Moore <lockbox@struct.foo>
Date: Mon, 2 Jun 2025 17:50:07 -0400
Subject: [PATCH 4/5] fix: only attempt to publish bindings on master
---
.github/workflows/python-publish.yml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
index 6f5e8554..cb0d2d5c 100644
--- a/.github/workflows/python-publish.yml
+++ b/.github/workflows/python-publish.yml
@@ -1,6 +1,9 @@
name: PyPI 📦 Distribution
-on: [push]
+on:
+ push:
+ branches:
+ - master
jobs:
build:
From 667cce956ce9c3b2ec7eb30d23198deb9596b427 Mon Sep 17 00:00:00 2001
From: Jordan Moore <lockbox@struct.foo>
Date: Mon, 2 Jun 2025 17:50:50 -0400
Subject: [PATCH 5/5] feat: basic CI
---
.github/workflows/cmake-build.yml | 31 +++++++++++++++++++++++++++++++
.github/workflows/rust-build.yml | 31 +++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
create mode 100644 .github/workflows/cmake-build.yml
create mode 100644 .github/workflows/rust-build.yml
diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml
new file mode 100644
index 00000000..4de36eab
--- /dev/null
+++ b/.github/workflows/cmake-build.yml
@@ -0,0 +1,31 @@
+# Builds the codebase with cmake
+
+name: CMake CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+
+jobs:
+ linux-build:
+ name: Linux
+ runs-on: ubuntu-24.04
+ steps:
+ - name: Checkout source code
+ uses: actions/checkout@v4
+ - name: Install prerequisites
+ shell: bash
+ run: |
+ sudo apt-get -y update
+ sudo apt-get install -y \
+ cmake \
+ gcc
+ - name: Configure
+ shell: bash
+ run: |
+ cmake -B build
+ - name: Bulid
+ shell: bash
+ run: |
+ cmake --build build
diff --git a/.github/workflows/rust-build.yml b/.github/workflows/rust-build.yml
new file mode 100644
index 00000000..7f7c8e01
--- /dev/null
+++ b/.github/workflows/rust-build.yml
@@ -0,0 +1,31 @@
+# Builds the codebase with cmake on ubuntu, windows and macos.
+#
+name: Rust CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+
+jobs:
+ linux-test:
+ name: Linux
+ runs-on: ubuntu-24.04
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+
+ - name: Install prerequisites
+ shell: bash
+ run: |
+ sudo apt-get -y update
+ sudo apt-get install -y \
+ cmake \
+ libclang-dev \
+ pkg-config \
+ gcc
+ - name: Build and test rust
+ shell: bash
+ run: |
+ cd bindings/rust
+ cargo test
|