Cache prefix info from staging environments for linking checks#2210
Open
Cache prefix info from staging environments for linking checks#2210
Conversation
When a package output inherits from a staging cache, the cache's host dependencies (e.g. zlib, libiconv) were not installed in the host prefix. This caused the linking checks to fail to attribute shared libraries to their providing packages, showing them as "not found" (red/unmarked) instead of properly linked. The root cause: `install_environments` only installed the output's own host dependencies, but the staging cache's host packages (which provided the libraries the build artifacts link against) were absent. Without their conda-meta records and library files in the prefix, `PrefixInfo::from_prefix()` couldn't map DSOs to packages. The fix merges the staging cache's host resolved packages into the output's host environment before installation, ensuring all relevant packages are present for post-processing (linking checks, relinking). Closes #2186 https://claude.ai/code/session_014mGW5MYfcfu8NFWxUJbU1J
…st packages Instead of reinstalling the staging cache's host packages during install_environments (which is slow), cache the PrefixInfo data (path-to-package and package nature mappings) in the staging cache metadata. When linking checks run, merge this cached info into the current prefix's PrefixInfo so shared libraries from the staging cache's host packages can be correctly attributed. This avoids the performance cost of re-downloading and installing packages while still providing the linking check with the information it needs. https://claude.ai/code/session_014mGW5MYfcfu8NFWxUJbU1J
c5bd2c8 to
00f8fe0
Compare
Member
Author
|
This doesn't work well yet. |
Hofer-Julian
added a commit
to Hofer-Julian/rattler-build
that referenced
this pull request
Apr 2, 2026
When a package output inherits from a staging cache, the staging cache's host dependencies aren't installed in the prefix during overlinking checks. This means libraries like libz.so.1 can't be attributed to zlib, even though zlib is a run dependency via inherited run_exports. Fix: at staging build time, capture a LibraryNameMap (filename to package mapping) from PrefixInfo while conda-meta still exists. Store it in the staging cache metadata, thread it to BuildOutput, and use it as a fallback in perform_linking_checks when resolve_libraries can't find the library on disk. Fixes prefix-dev#2186 Supersedes prefix-dev#2210
Hofer-Julian
added a commit
to Hofer-Julian/rattler-build
that referenced
this pull request
Apr 7, 2026
When a package output inherits from a staging cache, the staging cache's host dependencies aren't installed in the prefix during overlinking checks. This means libraries like libz.so.1 can't be attributed to zlib, even though zlib is a run dependency via inherited run_exports. Fix: at staging build time, capture a LibraryNameMap (filename to package mapping) from PrefixInfo while conda-meta still exists. Store it in the staging cache metadata, thread it to BuildOutput, and use it as a fallback in perform_linking_checks when resolve_libraries can't find the library on disk. Fixes prefix-dev#2186 Supersedes prefix-dev#2210
Hofer-Julian
added a commit
to Hofer-Julian/rattler-build
that referenced
this pull request
Apr 8, 2026
When a package output inherits from a staging cache, the staging cache's host dependencies aren't installed in the prefix during overlinking checks. This means libraries like libz.so.1 can't be attributed to zlib, even though zlib is a run dependency via inherited run_exports. Fix: at staging build time, capture a LibraryNameMap (filename to package mapping) from PrefixInfo while conda-meta still exists. Store it in the staging cache metadata, thread it to BuildOutput, and use it as a fallback in perform_linking_checks when resolve_libraries can't find the library on disk. Fixes prefix-dev#2186 Supersedes prefix-dev#2210
Hofer-Julian
added a commit
to Hofer-Julian/rattler-build
that referenced
this pull request
Apr 8, 2026
When a package output inherits from a staging cache, the staging cache's host dependencies aren't installed in the prefix during overlinking checks. This means libraries like libz.so.1 can't be attributed to zlib, even though zlib is a run dependency via inherited run_exports. Fix: at staging build time, capture a LibraryNameMap (filename to package mapping) from PrefixInfo while conda-meta still exists. Store it in the staging cache metadata, thread it to BuildOutput, and use it as a fallback in perform_linking_checks when resolve_libraries can't find the library on disk. Fixes prefix-dev#2186 Supersedes prefix-dev#2210 test: add e2e test for staging overlinking check
Hofer-Julian
added a commit
to Hofer-Julian/rattler-build
that referenced
this pull request
Apr 8, 2026
When a package output inherits from a staging cache, the staging cache's host dependencies aren't installed in the prefix during overlinking checks. This means libraries like libz.so.1 can't be attributed to zlib, even though zlib is a run dependency via inherited run_exports. Fix: at staging build time, capture a LibraryNameMap (filename to package mapping) from PrefixInfo while conda-meta still exists. Store it in the staging cache metadata, thread it to BuildOutput, and use it as a fallback in perform_linking_checks when resolve_libraries can't find the library on disk. Fixes prefix-dev#2186 Supersedes prefix-dev#2210 test: add e2e test for staging overlinking check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enables linking checks to correctly attribute shared libraries to packages from inherited staging caches by caching and merging prefix information (path-to-package and package nature mappings) from the staging cache's host environment.
Problem
When an output inherits from a staging cache, the cache's host dependencies are installed into the prefix but their
conda-metarecords are not present. This causes linking checks to fail when trying to attribute shared libraries to packages that were built in the staging cache, since the package metadata is unavailable.Solution
The changes implement a caching mechanism for prefix information:
CachedPrefixInfostruct: A serializable representation ofPrefixInfothat stores path-to-package and package nature mappings as strings, suitable for storage in staging cache metadataconda-metarecords are present) and stored in the cache metadataClone,Serialize, andDeserializederives toPackageNatureto support serializationKey Changes
CachedPrefixInfostruct with serialization support for storing prefix mappingsPrefixInfo::merge_cached()to merge cached mappings into the current prefix infoStagingCacheMetadatato includecached_prefix_infofieldCachedPrefixInfoalongside dependencies and sourcesBuildOutputto storecached_prefix_infofrom inherited staging cachesImplementation Details
CachedPrefixInfousesStringkeys instead ofPackageNameto avoid deserialization failures if package name formats changeentry().or_insert())#[serde(default)]for backward compatibility with existing cache metadatahttps://claude.ai/code/session_014mGW5MYfcfu8NFWxUJbU1J