[mypyc] Import librt.base64 capsule automatically if needed#20233
Merged
[mypyc] Import librt.base64 capsule automatically if needed#20233
Conversation
p-sawicki
approved these changes
Nov 13, 2025
| # Switch to lower abstraction level IR. | ||
| lower_ir(fn, compiler_options) | ||
| # Calculate implicit module dependencies (needed for librt) | ||
| capsules = find_implicit_capsule_dependencies(fn) |
Collaborator
There was a problem hiding this comment.
is the top-level code (outside any functions) converted into a FuncIR at this point? either way it might be good to add a test where the only use of the dependency is outside a function.
Collaborator
Author
There was a problem hiding this comment.
Yes, but I can add a test case.
Collaborator
Author
|
Related issue: mypyc/mypyc#1128 |
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.
Allow primitives to specify the capsule they need via module name such as
librt.base64.This way we can import the capsule automatically only when there are references to the
contents of the capsule in the compiled code.
Only make the change for
librt.base64, but we can also do a similar thing forlibrt.internalin a follow-up PR.