Skip to content

Commit 70e319a

Browse files
committed
Replace llama-cpp-sys-2's crate features for CPU features with checking target_feature directly in build.rs instead of in llama-cpp-2
1 parent a8a71a5 commit 70e319a

File tree

3 files changed

+12
-48
lines changed

3 files changed

+12
-48
lines changed

llama-cpp-2/Cargo.toml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,6 @@ vulkan = ["llama-cpp-sys-2/vulkan"]
2222
native = ["llama-cpp-sys-2/native"]
2323
sampler = []
2424

25-
[target.'cfg(target_feature = "avx")'.dependencies]
26-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
27-
"avx",
28-
] }
29-
[target.'cfg(target_feature = "avx2")'.dependencies]
30-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
31-
"avx2",
32-
] }
33-
[target.'cfg(target_feature = "avx512f")'.dependencies]
34-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
35-
"avx512",
36-
] }
37-
[target.'cfg(target_feature = "avx512vbmi")'.dependencies]
38-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
39-
"avx512_vmbi",
40-
] }
41-
[target.'cfg(target_feature = "avx512vnni")'.dependencies]
42-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
43-
"avx512_vnni",
44-
] }
45-
[target.'cfg(target_feature = "f16c")'.dependencies]
46-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
47-
"f16c",
48-
] }
49-
[target.'cfg(target_feature = "fma")'.dependencies]
50-
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
51-
"fma",
52-
] }
53-
5425
[target.'cfg(all(target_os = "macos", any(target_arch = "aarch64", target_arch = "arm64")))'.dependencies]
5526
llama-cpp-sys-2 = { path = "../llama-cpp-sys-2", version = "0.1.63", features = [
5627
"metal",

llama-cpp-sys-2/Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,7 @@ cc = { workspace = true, features = ["parallel"] }
5353
once_cell = "1.19.0"
5454

5555
[features]
56-
avx = []
57-
avx2 = []
58-
avx512 = []
59-
avx512_vmbi = []
60-
avx512_vnni = []
6156
cuda = []
62-
f16c = []
63-
fma = []
6457
metal = []
6558
dynamic_link = []
6659
vulkan = []

llama-cpp-sys-2/build.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,59 +259,59 @@ fn push_feature_flags(cx: &mut Build, cxx: &mut Build) {
259259
cxx.flag("-march=native");
260260
}
261261

262-
if cfg!(feature = "fma") && cfg!(target_family = "unix") {
262+
if cfg!(target_feature = "fma") && cfg!(target_family = "unix") {
263263
cx.flag("-mfma");
264264
cxx.flag("-mfma");
265265
}
266266

267-
if cfg!(feature = "f16c") && cfg!(target_family = "unix") {
267+
if cfg!(target_feature = "f16c") && cfg!(target_family = "unix") {
268268
cx.flag("-mf16c");
269269
cxx.flag("-mf16c");
270270
}
271271

272272
if cfg!(target_family = "unix") {
273-
if cfg!(feature = "avx512") {
273+
if cfg!(target_feature = "avx512f") {
274274
cx.flag("-mavx512f").flag("-mavx512bw");
275275
cxx.flag("-mavx512f").flag("-mavx512bw");
276276

277-
if cfg!(feature = "avx512_vmbi") {
277+
if cfg!(target_feature = "avx512vbmi") {
278278
cx.flag("-mavx512vbmi");
279279
cxx.flag("-mavx512vbmi");
280280
}
281281

282-
if cfg!(feature = "avx512_vnni") {
282+
if cfg!(target_feature = "avx512vnni") {
283283
cx.flag("-mavx512vnni");
284284
cxx.flag("-mavx512vnni");
285285
}
286286
}
287287

288-
if cfg!(feature = "avx2") {
288+
if cfg!(target_feature = "avx2") {
289289
cx.flag("-mavx2");
290290
cxx.flag("-mavx2");
291291
}
292292

293-
if cfg!(feature = "avx") {
293+
if cfg!(target_feature = "avx") {
294294
cx.flag("-mavx");
295295
cxx.flag("-mavx");
296296
}
297297
} else if cfg!(target_family = "windows") {
298-
if cfg!(feature = "avx512") {
298+
if cfg!(target_feature = "avx512f") {
299299
cx.flag("/arch:AVX512");
300300
cxx.flag("/arch:AVX512");
301301

302-
if cfg!(feature = "avx512_vmbi") {
302+
if cfg!(target_feature = "avx512vbmi") {
303303
cx.define("__AVX512VBMI__", None);
304304
cxx.define("__AVX512VBMI__", None);
305305
}
306306

307-
if cfg!(feature = "avx512_vnni") {
307+
if cfg!(target_feature = "avx512vnni") {
308308
cx.define("__AVX512VNNI__", None);
309309
cxx.define("__AVX512VNNI__", None);
310310
}
311-
} else if cfg!(feature = "avx2") {
311+
} else if cfg!(target_feature = "avx2") {
312312
cx.flag("/arch:AVX2");
313313
cxx.flag("/arch:AVX2");
314-
} else if cfg!(feature = "avx") {
314+
} else if cfg!(target_feature = "avx") {
315315
cx.flag("/arch:AVX");
316316
cxx.flag("/arch:AVX");
317317
}

0 commit comments

Comments
 (0)