RFC: Add a simple feature checking mechanism. #48764
Open
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.
This PR adds a simple mechanism to check if a build of Julia has certain features:
The purpose of this function is to use this to drive conditional code in packages. Currently, we use:
VERSION
checks, e.g.if VERSION >= v"1.10.0-DEV.649"
, which doesn't tell me much if I read this codeif isdefined(Base, :get_extension)
The other problem with version checks is that they need the Julia PR to be merged before we can adapt packages. For example, in #48611 PkgEval revealed quite some breakage. I'd like to fix packages without having to merge the (re-landed version of) that PR, but there isn't any easy way to check for the changed behavior without looking deeply into compiler internals, which is ugly. In fact, I think the
isdefined(Base, :get_extension)
is ugly too, and a call toBase.has_feature("extensions")
would be much easier on the eyes.Currently, the set of
features
is hard-coded, just as a starting point for this PR. I considered automating its generation during build, e.g. making it possible to check for PR numbers, but AFAIK that would require use of the GitHub API during build which isn't great.