build: include the Linux variant in the prebuilt cache key - #37
Conversation
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 LadybugDB#36
adsharma
left a comment
There was a problem hiding this comment.
Correct, minimal fix for #36. Verified the default (unset/empty -> compat) matches ${LBUG_LINUX_VARIANT:-compat} in scripts/download-liblbug.sh, the variant is appended before the key sanitizer (no path traversal), and keying all three key shapes (run-/version-/latest) is right since the run-artifact name is variant-specific for linux-static too. Suffixing unconditionally on Linux is correct because the prebuilt path is static-only and Linux shared archives carry no variant. The one-time redownload of old version-X dirs is unavoidable and correctly called out. LBUG_LIB_KIND needs no treatment (a shared download misses the liblbug.a lookup and falls back to source build rather than silently reusing). Non-blocking note: arch is not in the key either, but that is pre-existing and out of scope. Manual hash verification plus green CI is adequate for untested build.rs.
Same behavior, no functional change: build the -<variant> suffix first and interpolate it into the cache key instead of mutating the string.
b54683f to
1bcb32b
Compare
Fixes #36.
On Linux the
compatandperfstatic archives were cached under the same key (version-X,run-Xorlatest), so after switchingLBUG_LINUX_VARIANTthe build script found the old archive and kept using it.This adds the variant to the key on Linux, e.g.
version-0.20.4-compatandversion-0.20.4-perf. When the variable is unset or empty it falls back tocompat, the same defaultdownload-liblbug.shuses. Nothing changes on macOS or Windows.One side effect: on Linux the first build after this lands downloads the archive again, because an existing
version-Xdirectory no longer matches the new key. I think that's fine, since there's no way to tell which variant an old directory actually holds.How I tested it
On Ubuntu 24.04 (x86_64) with
LBUG_VERSION=0.20.4and a sharedLBUG_PREBUILT_CACHE_DIR:LBUG_LINUX_VARIANT=perfleaves a singleversion-0.20.4/directory, and itsliblbug.ais still the compat one.version-0.20.4-compat/andversion-0.20.4-perf/. Their sha256 hashes match theliblbug-static-linux-x86_64-compatand-perfassets from the v0.20.4 release. Switching back to the default reuses the compat directory without downloading again.cargo testpasses (158 + 3).I didn't add a test because
build.rsisn't covered bycargo test. If you'd like one, I'm happy to move the key logic somewhere testable.