Skip to content

Commit 7edde0b

Browse files
committed
fix(core): give nested eBPF build.rs cargo invocation its own target dir
The outer `cargo build` holds the workspace target-dir lock for the whole session; build.rs's nested `cargo build --package oom-watcher-ebpf` invocation targeted the same dir and blocked acquiring that lock, while build.rs blocked waiting on the nested process — a permanent deadlock. Surfaced by the release workflow's cold-cache native-arch builds hanging indefinitely on both amd64 and arm64 at the same point (compiling oom-watcher, right as build.rs fires).
1 parent e8dba0b commit 7edde0b

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

oom-watcher/build.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ fn main() {
2525

2626
println!("cargo:warning=Building eBPF program...");
2727

28+
// Build into a dedicated target dir: the outer `cargo build` holds the
29+
// lock on the workspace's target dir for the whole session, and this
30+
// nested cargo invocation would otherwise block acquiring the same lock
31+
// (build.rs, in turn, blocks waiting for this process) — a deadlock.
32+
let ebpf_target_dir = workspace_root.join("target/ebpf-subbuild");
33+
2834
// Build the eBPF program
2935
let mut cmd = Command::new("cargo");
3036
cmd.arg("+nightly")
@@ -34,6 +40,8 @@ fn main() {
3440
.arg("oom-watcher-ebpf")
3541
.arg("--target")
3642
.arg("bpfel-unknown-none")
43+
.arg("--target-dir")
44+
.arg(&ebpf_target_dir)
3745
.arg("-Z")
3846
.arg("build-std=core")
3947
.current_dir(&workspace_root);
@@ -53,9 +61,9 @@ fn main() {
5361

5462
// Look for the eBPF binary in multiple possible locations
5563
let possible_paths = vec![
56-
workspace_root.join("target/bpfel-unknown-none/release/oom-watcher-ebpf"),
57-
PathBuf::from("../target/bpfel-unknown-none/release/oom-watcher-ebpf"),
58-
PathBuf::from("target/bpfel-unknown-none/release/oom-watcher-ebpf"),
64+
ebpf_target_dir.join("bpfel-unknown-none/release/oom-watcher-ebpf"),
65+
PathBuf::from("../target/ebpf-subbuild/bpfel-unknown-none/release/oom-watcher-ebpf"),
66+
PathBuf::from("target/ebpf-subbuild/bpfel-unknown-none/release/oom-watcher-ebpf"),
5967
];
6068

6169
let mut found_path = None;
@@ -93,10 +101,10 @@ fn main() {
93101
println!("cargo:warning= {}", path.display());
94102
}
95103

96-
// List contents of workspace target directory
97-
let workspace_target = workspace_root.join("target/bpfel-unknown-none/release/");
98-
println!("cargo:warning=Contents of {}:", workspace_target.display());
99-
if let Ok(entries) = fs::read_dir(&workspace_target) {
104+
// List contents of the eBPF build's target directory
105+
let ebpf_release_dir = ebpf_target_dir.join("bpfel-unknown-none/release/");
106+
println!("cargo:warning=Contents of {}:", ebpf_release_dir.display());
107+
if let Ok(entries) = fs::read_dir(&ebpf_release_dir) {
100108
for entry in entries.flatten() {
101109
println!("cargo:warning= {}", entry.file_name().to_string_lossy());
102110
}

0 commit comments

Comments
 (0)