JuliaLang / PackageCompiler.jl

Compile your Julia Package
https://julialang.github.io/PackageCompiler.jl/dev/
MIT License
1.42k stars 191 forks source link

Package extensions don't load if the dependency is not in the system image #816

Closed JackDunnNZ closed 1 year ago

JackDunnNZ commented 1 year ago

Suppose that PackageA has an extension that depends on PackageB. If a system image is created containing PackageA, then if I use this system image and add and load PackageB, it seems like the extension for PackageA/PackageB is not triggered.

Is this the intended behavior or might something be going wrong on my end? This type of conditional loading does work with Requires.jl

Here is a quick example I was trying with BangBang.jl (as an arbitrary choice of package with an extension):

using PackageCompiler
PackageCompiler.create_sysimage(:BangBang, sysimage_path="path/to/sys.dylib")

Testing on Julia 1.6.7 (so falling back to Requires.jl):

julia> length(methods(BangBang.implements))
10

julia> using StaticArrays

julia> length(methods(BangBang.implements))
12

On 1.9.0:

julia> length(methods(BangBang.implements))
10

julia> using StaticArrays

julia> length(methods(BangBang.implements))
10

So the extension hasn't been loaded as the new method definitions aren't present

Of course, and for completeness, if both packages are included in the system image then the extension is also loaded in the system image.

KristofferC commented 1 year ago

This looks fixed on upcoming 1.9.1:

kristofferc$ ./julia-5412389f72/bin/julia --sysimage=sysimg.so -q

julia> Base.EXT_DORMITORY
Dict{Base.PkgId, Vector{Base.ExtensionId}} with 6 entries:
  DataFrames [a93c6f00-e5… => [ExtensionId(BangBangDataFramesExt [d787bcad-b5…
  StaticArrays [90137ffa-… => [ExtensionId(ConstructionBaseStaticArraysExt [8…
  IntervalSets [8197267c-… => [ExtensionId(ConstructionBaseIntervalSetsExt [a…
  ChainRulesCore [d360d2e… => [ExtensionId(BangBangChainRulesCoreExt [47e8a63…
  TypedTables [9d95f2ec-7… => [ExtensionId(BangBangTypedTablesExt [dde14a2d-6…
  StructArrays [09ab397b-… => [ExtensionId(BangBangStructArraysExt [d139770a-…

julia> length(methods(BangBang.implements))
10

julia> using StaticArrays
[ Info: Precompiling StaticArrays [90137ffa-7385-5640-81b9-e52037218182]
[ Info: Precompiling ConstructionBaseStaticArraysExt [8497ba20-d017-5d93-8a79-2639523b7219]
[ Info: Precompiling BangBangStaticArraysExt [a9f1882a-14fa-573e-a12d-824431257a23]

julia> length(methods(BangBang.implements))
12
JackDunnNZ commented 1 year ago

Fantastic, thank you for checking!