Skip to content

Commit ea20450

Browse files
authored
Merge pull request #417 from brittlewis12/update-llama-cpp-2024-07-09
macOS `build.rs` fixes to align w ggml-org/llama.cpp@f3f6542
2 parents 8ea1482 + 22db5f4 commit ea20450

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

llama-cpp-sys-2/build.rs

Lines changed: 11 additions & 7 deletions
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 {
@@ -683,7 +687,7 @@ fn main() {
683687
println!("cargo:rustc-link-lib=llama");
684688
println!("cargo:rustc-link-lib=ggml");
685689

686-
let llama_header_path = std::env::var("LLAMA_HEADE");
690+
let llama_header_path = std::env::var("LLAMA_HEADER");
687691
if let Ok(llama_header_path) = llama_header_path {
688692
compile_bindings(&out_path, Path::new(&llama_header_path))
689693
.expect("failed to generate bindings");

0 commit comments

Comments
 (0)