You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: switching LBUG_LINUX_VARIANT keeps using the previously cached archive #36
Ladybug version:lbug crate 0.19.1 with engine v0.20.1 (LBUG_VERSION=0.20.1). build.rs on main still has the same logic, so I'd expect 0.20.4 to behave the same.
OS: Ubuntu 24.04.5 LTS, x86_64, Rust 1.83.0
What happened?
I was comparing the compat and perf Linux builds of the engine, so I set LBUG_LINUX_VARIANT=perf on a project that had already built once with compat. The build went through without any complaints, but it was still linking the compat archive. I only noticed because the linked liblbug.a hash didn't change.
It looks like the variant isn't part of the prebuilt cache key. prebuilt_cache_key() builds the key from LBUG_PRECOMPILED_RUN_ID or LBUG_VERSION and nothing else, and try_download_prebuilt_lbug() skips the download whenever liblbug.a already exists at that path. So switching the variant does re-run the build script (thanks to rerun-if-env-changed=LBUG_LINUX_VARIANT), but it finds the old archive in the same directory and uses it again.
I expected changing the variant to either download the other archive, or at least fail loudly rather than silently giving me the one I just asked not to use.
This one is easy to miss. If you A/B the two variants you end up measuring compat twice and conclude the variant doesn't matter. With LBUG_PREBUILT_CACHE_DIR pointing at a shared cache it can also spill across projects.
Steps to reproduce
On Linux x86_64, build any crate that depends on lbug with the default variant, e.g. LBUG_VERSION=0.20.1 cargo build --release.
Note the hash of the cached archive (.../lbug-prebuilt/version-0.20.1/lib/liblbug.a).
Rebuild with LBUG_VERSION=0.20.1 LBUG_LINUX_VARIANT=perf cargo build --release.
The build script re-runs, nothing is downloaded, and the archive hash is exactly the same as before.
Another quick check is counting AVX register uses in the final binary, e.g. objdump -d --no-show-raw-insn <bin> | grep -coE '%ymm[0-9]+'. For me the count came out noticeably different between the two variants when each was built from a clean cache, but it didn't change at all after just switching the env var.
Possible fix
Probably a small one: add the variant to the key in prebuilt_cache_key() (something like version-0.20.1-perf) on Linux. LBUG_LIB_KIND might need the same treatment, but I've only actually run into the variant case.
For now I'm working around it by clearing the cached lbug-prebuilt/<key>/ directory (and running cargo clean -p lbug) whenever I switch variants, then checking the archive hash against the published release.
I've opened #37 with that change. Happy to adjust it if you'd rather fix it a different way.
Activity
build: include the Linux variant in the prebuilt cache key