Skip to content

build: include the Linux variant in the prebuilt cache key - #37

Merged
adsharma merged 2 commits into
LadybugDB:mainfrom
aenawi:fix-linux-variant-cache-key
Sep 18, 2026
Merged

adsharma merged 2 commits into
LadybugDB:mainfrom
aenawi:fix-linux-variant-cache-key

Conversation

@aenawi

@aenawi aenawi commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #36.

On Linux the compat and perf static archives were cached under the same key (version-X, run-X or latest), so after switching LBUG_LINUX_VARIANT the 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-compat and version-0.20.4-perf. When the variable is unset or empty it falls back to compat, the same default download-liblbug.sh uses. 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-X directory 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.4 and a shared LBUG_PREBUILT_CACHE_DIR:

  • Without the patch: building with the default variant and then with LBUG_LINUX_VARIANT=perf leaves a single version-0.20.4/ directory, and its liblbug.a is still the compat one.
  • With the patch: the same two builds create version-0.20.4-compat/ and version-0.20.4-perf/. Their sha256 hashes match the liblbug-static-linux-x86_64-compat and -perf assets from the v0.20.4 release. Switching back to the default reuses the compat directory without downloading again.
  • cargo test passes (158 + 3).

I didn't add a test because build.rs isn't covered by cargo test. If you'd like one, I'm happy to move the key logic somewhere testable.

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 adsharma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@adsharma
adsharma force-pushed the fix-linux-variant-cache-key branch from b54683f to 1bcb32b Compare September 18, 2026 17:19
@adsharma
adsharma merged commit c941bbb into LadybugDB:main Sep 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: switching LBUG_LINUX_VARIANT keeps using the previously cached archive

2 participants