-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
Convert AbstractPlatform to Platform #3874
Conversation
Before this pull request: julia> using SnoopCompileCore, Pkg
julia> invalidations = @snoopr using BinaryBuilderBase;
julia> using SnoopCompile
julia> trees = invalidation_trees(invalidations)
3-element Vector{SnoopCompile.MethodInvalidations}:
inserting joinpath(prefix::Prefix, args...) @ BinaryBuilderBase ~/.julia/packages/BinaryBuilderBase/tGUXK/src/Prefix.jl:68 invalidated:
mt_backedges: 1: signature Tuple{typeof(joinpath), Any, String} triggered MethodInstance for Artifacts.jointail(::Any, ::String) (0 children)
inserting repr(p::FileProduct) @ BinaryBuilderBase ~/.julia/packages/BinaryBuilderBase/tGUXK/src/Products.jl:463 invalidated:
backedges: 1: superseding repr(x; context) @ Base strings/io.jl:286 with MethodInstance for repr(::Any) (43 children)
inserting tags(p::AnyPlatform) @ BinaryBuilderBase ~/.julia/packages/BinaryBuilderBase/tGUXK/src/Platforms.jl:14 invalidated:
mt_backedges: 1: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.triplet(::Base.BinaryPlatforms.AbstractPlatform) (0 children)
2: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.libgfortran_version(::Base.BinaryPlatforms.AbstractPlatform) (1 children)
3: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.cxxstring_abi(::Base.BinaryPlatforms.AbstractPlatform) (1 children)
4: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.libstdcxx_version(::Base.BinaryPlatforms.AbstractPlatform) (1 children)
5: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.os_version(::Base.BinaryPlatforms.AbstractPlatform) (2 children)
6: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.call_abi(::Base.BinaryPlatforms.AbstractPlatform) (2 children)
7: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.arch(::Base.BinaryPlatforms.AbstractPlatform) (2 children)
8: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.os(::Base.BinaryPlatforms.AbstractPlatform) (2 children)
9: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.var"#Platform#8"(::Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}, ::Type{Platform}, ::Base.BinaryPlatforms.AbstractPlatform) (5 children)
10: signature Tuple{typeof(Base.BinaryPlatforms.tags), Base.BinaryPlatforms.AbstractPlatform} triggered MethodInstance for Base.BinaryPlatforms.libc(::Base.BinaryPlatforms.AbstractPlatform) (60 children) After this pull request: julia> using SnoopCompileCore, Pkg
julia> invalidations = @snoopr using BinaryBuilderBase;
julia> using SnoopCompile
julia> trees = invalidation_trees(invalidations)
2-element Vector{SnoopCompile.MethodInvalidations}:
inserting joinpath(prefix::Prefix, args...) @ BinaryBuilderBase ~/.julia/packages/BinaryBuilderBase/tGUXK/src/Prefix.jl:68 invalidated:
mt_backedges: 1: signature Tuple{typeof(joinpath), Any, String} triggered MethodInstance for Artifacts.jointail(::Any, ::String) (0 children)
inserting repr(p::FileProduct) @ BinaryBuilderBase ~/.julia/packages/BinaryBuilderBase/tGUXK/src/Products.jl:463 invalidated:
backedges: 1: superseding repr(x; context) @ Base strings/io.jl:286 with MethodInstance for repr(::Any) (43 children) |
@@ -64,6 +64,8 @@ end | |||
|
|||
const PlatformUnion = Union{Linux,MacOS,Windows,FreeBSD} | |||
|
|||
Base.convert(::Type{Platform}, p::PlatformUnion) = p.p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm highlighting this change.
Here we convert most of the AbstractPlatform
subtypes to Platform
by unwrapping them.
The one outlier is UnknownPlatform
but there is another pull request to address that.
@mkitti what's the status of this? |
We might not need it. |
It is not clear to me whether general conversion to |
This pull request hardens Pkg.jl from invalidations involving
AbstractPlatform
. WhenAbstractPlatform
is used as the type of a keyword argument, Julia may notspecialize on the type.
This pull request inserts
convert(Platform, platform)::Platform
to all functions that takeplatform::AbstractPlatform
as a keyword argument.