-
-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try using Preferences.jl instead of Pkg.build #524
Conversation
Why can't you do this at precompile time instead? What's special about |
Possibly? What happens if we modify the preferences? Is there a way to trigger a second round of precompilation? |
That’s the major feature of preferences: if you use a preference value at
compile-time, it gets logged, and if that value changes, the next time you
load the package it will get recompiled.
…On Mon, Dec 6, 2021 at 18:34 Simon Byrne ***@***.***> wrote:
Possibly? What happens if we modify the preferences? Is there a way to
trigger a second round of precompilation?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#524 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA762AZQWYC5YXJIZSLQNDUPVXC5ANCNFSM5JNFB7GA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Ah. So to clarify, the hash is based on the state of the preferences after precompilation, not before? i.e. so if I call |
That is correct. Every time you call All that being said, you're absolutely responsible for ensuring that the state of your package is consistent, and it can get really confusing if a top-level definition changes halfway through precompilation. Example:
If you compile this once,
But I really dislike this for the following reasons:
It's much better to provide the user a |
Thanks @staticfloat. One of the challenges I'm trying to solve is figuring out the ABI of the user-provided MPI library: this should be stored in the Preferences.jl, since we want to invalidate the precompile cache if it changes. So I want to do something like: const abi = begin
_abi = @load_preference("abi", nothing)
if isnothing(_abi)
_abi = find_abi()
@set_preference!("abi" => _abi)
end
_abi
end Is that reasonable usage? Also, if the ABI is not known, then we need to generate a .jl file with the constants by compiling and running a C program. Previously we stored this information in include(joinpath(@get_scratch!("constants"), "consts.jl")) statement inside the |
Yes, as long as you don't expect the ABI to change out from underneath the user. Your module only calls
Yes, that's a great idea. Using |
This is an attempt to switch to using Preferences.jl instead of relying on environment variables. It is somewhat orthogonal to #513, but there are some design decisions that will necessarily interact.
This is based on discussion #483.
Instead of using environment variables, users would now call
There are a couple of pain points that I think would need to be addressed:
cc: @carstenbauer @giordano @staticfloat @vchuravy