Skip to content

Conversation

topolarity
Copy link
Member

@topolarity topolarity commented Aug 7, 2025

Like many registration / hook-like functions in Julia, this function is somewhat dangerous to use at (pre)compile-time. Depending on whether the LazyLibrary you are adding dependencies to was constructed in a separate pre-compilation process or not, your dependencies may or may not persist.

This change errs on the side of consistency, and makes it so that add_dependency! is always an ephemeral operation that does not persist beyond the lifetime of the process, which makes it safe to temporarily register dependencies, e.g., during a sysimage build.

(originally for JuliaLang/LinearAlgebra.jl#1407)

@topolarity topolarity requested a review from staticfloat August 7, 2025 23:38
@topolarity topolarity force-pushed the ct/lazylibrary-ephemeral-deps branch from 38ec67b to 7669c4b Compare August 7, 2025 23:52
@topolarity topolarity requested a review from giordano as a code owner August 7, 2025 23:52
@topolarity topolarity force-pushed the ct/lazylibrary-ephemeral-deps branch 2 times, most recently from 87fcc6e to fed86d9 Compare August 8, 2025 11:16
Like many registration / hook-like functions in Julia, this function is
somewhat dangerous to use at compile-time. Depending on whether the
`LazyLibrary` you are adding dependencies to was constructed in a prior
pre-compilation process or not, your dependencies may or may not persist.

This change errs on the side of consistency, and makes it so that
`add_dependency!` is always an ephemeral operation that does not persist
beyond the lifetime of the process. This makes it safe to temporarily
register dependencies, e.g., during a sysimage build.
@topolarity topolarity force-pushed the ct/lazylibrary-ephemeral-deps branch from fed86d9 to ba0fe07 Compare August 8, 2025 11:20
@topolarity
Copy link
Member Author

Despite JuliaLang/LinearAlgebra.jl#1407 closing, I think this might be a good change to take anyway.

Possibly with a re-name to make it clear that this registration only lasts for the existing process?

@staticfloat
Copy link
Member

I'm totally in favor of anything that makes the semantics around how this interacts with __init__() simpler to reason about. I tested this with the LazyJLLWrappers.jl test suite and it all seems fine, so I'm fine with this.

@topolarity topolarity merged commit 4a83470 into JuliaLang:master Aug 14, 2025
10 checks 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.

2 participants