Skip to content

Commit f815079

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

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

llama-cpp-sys-2/build.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fn compile_cuda(cx: &mut Build, cxx: &mut Build, featless_cxx: Build) -> &'stati
452452
let lib_name = "ggml-cuda";
453453
let ggml_path = LLAMA_PATH.join("ggml");
454454
let ggml_src = ggml_path.join("src");
455-
let cuda_path = ggml_src.join("ggml-cuda");
455+
let cuda_path = ggml_src.join(lib_name);
456456
let cuda_sources = read_dir(cuda_path.as_path())
457457
.unwrap()
458458
.map(|f| f.unwrap())
@@ -492,15 +492,19 @@ fn compile_metal(cx: &mut Build, cxx: &mut Build) {
492492
// It's idiomatic to use OUT_DIR for intermediate c/c++ artifacts
493493
let out_dir = env::var("OUT_DIR").unwrap();
494494

495-
let ggml_metal_shader_path = LLAMA_PATH.join("ggml-metal.metal");
495+
let lib_name = "ggml-metal.metal";
496+
let ggml_path = LLAMA_PATH.join("ggml");
497+
let ggml_src = ggml_path.join("src");
498+
let ggml_include = ggml_path.join("include");
499+
let ggml_metal_shader_path = ggml_src.join(lib_name);
496500

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

502-
let ggml_metal_shader_out_path = PathBuf::from(&out_dir).join("ggml-metal.metal");
503-
let common = LLAMA_PATH.join("ggml-common.h");
506+
let ggml_metal_shader_out_path = PathBuf::from(&out_dir).join(lib_name);
507+
let common = ggml_src.join("ggml-common.h");
504508

505509
let input_file = File::open(ggml_metal_shader_path).expect("Failed to open input file");
506510
let output_file =
@@ -575,8 +579,8 @@ fn compile_metal(cx: &mut Build, cxx: &mut Build) {
575579
println!("cargo:rustc-link-search=native={}", &out_dir);
576580
println!("cargo:rustc-link-lib=static=ggml-metal-embed");
577581

578-
cx.include(LLAMA_PATH.join("ggml-metal.h"))
579-
.file(LLAMA_PATH.join("ggml-metal.m"));
582+
cx.include(ggml_include.join("ggml-metal.h"))
583+
.file(ggml_src.join("ggml-metal.m"));
580584
}
581585

582586
fn find_windows_vulkan_sdk() -> PathBuf {

0 commit comments

Comments
 (0)