From 5f3053d8ffdedf4e4021168096beebc881561cff Mon Sep 17 00:00:00 2001 From: Hashem Aldhaheri Date: Fri, 18 Sep 2026 10:17:39 +0400 Subject: [PATCH 1/2] build: include the Linux variant in the prebuilt cache key The cache key only looked at the run id or version, so on Linux the compat and perf archives shared one directory. Whichever was downloaded first got reused after switching LBUG_LINUX_VARIANT, with no warning. Add the variant to the key on Linux, defaulting to compat like the download script does. Fixes #36 --- build.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 658bf89..c836da0 100644 --- a/build.rs +++ b/build.rs @@ -156,7 +156,7 @@ fn static_lbug_file_name() -> &'static str { } fn prebuilt_cache_key() -> String { - let source = if let Ok(run_id) = env::var("LBUG_PRECOMPILED_RUN_ID") { + let mut source = if let Ok(run_id) = env::var("LBUG_PRECOMPILED_RUN_ID") { format!("run-{run_id}") } else if let Ok(version) = env::var("LBUG_VERSION") { format!("version-{version}") @@ -164,6 +164,21 @@ fn prebuilt_cache_key() -> String { "latest".to_string() }; + // Linux ships more than one static build per release, and the download + // script picks one with LBUG_LINUX_VARIANT. Keep them in separate cache + // directories, otherwise switching the variant reuses whichever archive + // was downloaded first. + if cfg!(target_os = "linux") { + // Same default as download-liblbug.sh, which also treats an empty + // value as unset. + let variant = env::var("LBUG_LINUX_VARIANT") + .ok() + .filter(|v| !v.is_empty()) + .unwrap_or_else(|| "compat".to_string()); + source.push('-'); + source.push_str(&variant); + } + source .chars() .map(|c| { From 1bcb32b2edec8b480d0be7355d55b0d6af4fba5f Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Fri, 18 Sep 2026 10:18:18 -0700 Subject: [PATCH 2/2] build: compute Linux variant suffix upfront, drop mut Same behavior, no functional change: build the - suffix first and interpolate it into the cache key instead of mutating the string. --- build.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/build.rs b/build.rs index c836da0..8347d05 100644 --- a/build.rs +++ b/build.rs @@ -156,28 +156,29 @@ fn static_lbug_file_name() -> &'static str { } fn prebuilt_cache_key() -> String { - let mut source = if let Ok(run_id) = env::var("LBUG_PRECOMPILED_RUN_ID") { - format!("run-{run_id}") - } else if let Ok(version) = env::var("LBUG_VERSION") { - format!("version-{version}") - } else { - "latest".to_string() - }; - // Linux ships more than one static build per release, and the download // script picks one with LBUG_LINUX_VARIANT. Keep them in separate cache // directories, otherwise switching the variant reuses whichever archive // was downloaded first. - if cfg!(target_os = "linux") { + let variant_suffix = if cfg!(target_os = "linux") { // Same default as download-liblbug.sh, which also treats an empty // value as unset. let variant = env::var("LBUG_LINUX_VARIANT") .ok() .filter(|v| !v.is_empty()) .unwrap_or_else(|| "compat".to_string()); - source.push('-'); - source.push_str(&variant); - } + format!("-{variant}") + } else { + String::new() + }; + + let source = if let Ok(run_id) = env::var("LBUG_PRECOMPILED_RUN_ID") { + format!("run-{run_id}{variant_suffix}") + } else if let Ok(version) = env::var("LBUG_VERSION") { + format!("version-{version}{variant_suffix}") + } else { + format!("latest{variant_suffix}") + }; source .chars()