Skip to content

Commit d3d6523

Browse files
committed
Fix metal compilation on macos
* changes upstream in ggml-org/llama.cpp#8006 - ggml-org/llama.cpp@f3f6542
1 parent 8ea1482 commit d3d6523

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

llama-cpp-sys-2/build.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ fn compile_cuda(cx: &mut Build, cxx: &mut Build, featless_cxx: Build) -> &'stati
457457
let lib_name = "ggml-cuda";
458458
let ggml_path = LLAMA_PATH.join("ggml");
459459
let ggml_src = ggml_path.join("src");
460-
let cuda_path = ggml_src.join("ggml-cuda");
460+
let cuda_path = ggml_src.join(lib_name);
461461
let cuda_sources = read_dir(cuda_path.as_path())
462462
.unwrap()
463463
.map(|f| f.unwrap())
@@ -497,15 +497,19 @@ fn compile_metal(cx: &mut Build, cxx: &mut Build) {
497497
// It's idiomatic to use OUT_DIR for intermediate c/c++ artifacts
498498
let out_dir = env::var("OUT_DIR").unwrap();
499499

500-
let ggml_metal_shader_path = LLAMA_PATH.join("ggml-metal.metal");
500+
let lib_name = "ggml-metal.metal";
501+
let ggml_path = LLAMA_PATH.join("ggml");
502+
let ggml_src = ggml_path.join("src");
503+
let ggml_include = ggml_path.join("include");
504+
let ggml_metal_shader_path = ggml_src.join(lib_name);
501505

502506
// Create a temporary assembly file that will allow for static linking to the metal shader.
503507
let ggml_metal_embed_assembly_path = PathBuf::from(&out_dir).join("ggml-metal-embed.asm");
504508
let mut ggml_metal_embed_assembly_file = File::create(&ggml_metal_embed_assembly_path)
505509
.expect("Failed to open ggml-metal-embed.asm file");
506510

507-
let ggml_metal_shader_out_path = PathBuf::from(&out_dir).join("ggml-metal.metal");
508-
let common = LLAMA_PATH.join("ggml-common.h");
511+
let ggml_metal_shader_out_path = PathBuf::from(&out_dir).join(lib_name);
512+
let common = ggml_src.join("ggml-common.h");
509513

510514
let input_file = File::open(ggml_metal_shader_path).expect("Failed to open input file");
511515
let output_file =
@@ -580,8 +584,8 @@ fn compile_metal(cx: &mut Build, cxx: &mut Build) {
580584
println!("cargo:rustc-link-search=native={}", &out_dir);
581585
println!("cargo:rustc-link-lib=static=ggml-metal-embed");
582586

583-
cx.include(LLAMA_PATH.join("ggml-metal.h"))
584-
.file(LLAMA_PATH.join("ggml-metal.m"));
587+
cx.include(ggml_include.join("ggml-metal.h"))
588+
.file(ggml_src.join("ggml-metal.m"));
585589
}
586590

587591
fn find_windows_vulkan_sdk() -> PathBuf {

0 commit comments

Comments
 (0)