Skip to content

Commit 1f34670

Browse files
authored
fix(llama): resolve vendor source from the invoking checkout (#3928)
* workspace: autosave persona work before shared sync (cherry picked from commit eb5a2606b981e5776e1514393cc6e32ec52ca03e) * style(llama): format imported manifest-path correction
1 parent f739df1 commit 1f34670

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

core/llama/build.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,20 @@ use std::env;
1313
use std::path::PathBuf;
1414

1515
fn main() {
16-
let submodule = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
17-
.join("..")
18-
.join("vendor")
19-
.join("llama.cpp");
20-
16+
// Resolve the manifest dir AT RUNTIME, not compile time. `env!(...)
17+
// expands when build.rs itself is compiled and bakes ONE checkout's
18+
// absolute path into the cached build-script binary — with our shared
19+
// target dir that poisons every other worktree (a sibling checkout
20+
// reusing the fingerprinted script would point at this tree's vendor/
21+
// llama.cpp, or fail to find its own). Cargo sets CARGO_MANIFEST_DIR for
22+
// each build-script invocation, so env::var tracks whichever checkout is
23+
// actually building. (env! was a no-op optimization here — the path was
24+
// only ever used at run time.)
25+
let manifest_dir = PathBuf::from(
26+
env::var("CARGO_MANIFEST_DIR")
27+
.expect("CARGO_MANIFEST_DIR must be set when cargo runs this build script"),
28+
);
29+
let submodule = manifest_dir.join("..").join("vendor").join("llama.cpp");
2130
println!("cargo:rerun-if-changed={}", submodule.display());
2231
println!("cargo:rerun-if-changed=build.rs");
2332

0 commit comments

Comments
 (0)