Skip to content

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Nov 13, 2025

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 for librt.internal
in a follow-up PR.

# Switch to lower abstraction level IR.
lower_ir(fn, compiler_options)
# Calculate implicit module dependencies (needed for librt)
capsules = find_implicit_capsule_dependencies(fn)
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but I can add a test case.

@JukkaL JukkaL merged commit 17f8b31 into master Nov 13, 2025
14 checks passed
@JukkaL JukkaL deleted the mypyc-base64-1 branch November 13, 2025 16:31
@JukkaL
Copy link
Collaborator Author

JukkaL commented Nov 13, 2025

Related issue: mypyc/mypyc#1128

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.

3 participants