JuliaLang / Pkg.jl

Pkg - Package manager for the Julia programming language
https://pkgdocs.julialang.org
Other
616 stars 258 forks source link

Extensions: pre-compilation fails if more than one extension #3728

Closed omlins closed 8 months ago

omlins commented 8 months ago

MWE: https://github.com/omlins/ParallelStencil.jl/pull/130/files#diff-4fd906dc9bd8d9fc59a9eab475a5119bbd4505ba46a091bede7d8cec6cabe8b8 In brief this MWE contains:

name = "Diffusion3D_minimal"
uuid = "91637811-9d05-4227-81a2-fe1d069b6ecb"
authors = ["Samuel Omlin <samuel.omlin@cscs.ch>"]
version = "0.1.0"

[deps]
ParallelStencil = "94395366-693c-11ea-3b26-d9b7aac5d958"

[compat]
ParallelStencil = ">= 0.4.0"

[weakdeps]
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

[extensions]
D3D_AMDGPUExt = "AMDGPU"
D3D_CUDAExt = "CUDA"

and:

module Diffusion3D_minimal
    using ParallelStencil
    f() = return
end

module D3D_CUDAExt
    import Diffusion3D_minimal
    g() = return
end

module D3D_AMDGPUExt
    import Diffusion3D_minimal
    h() = return
end

The error is the following:

julia> Base.compilecache(Base.PkgId(Base.UUID("94395366-693c-11ea-3b26-d9b7aac5d958"), "ParallelStencil")); Base.compilecache(Base.PkgId(Base.UUID("91637811-9d05-4227-81a2-fe1d069b6ecb"), "Diffusion3D_minimal")); Base.compilecache(Base.PkgId(Base.UUID("38fae68b-b861-5d3c-b423-1a3f5200d4e2"), "D3D_CUDAExt"))
[ Info: Precompiling ParallelStencil [94395366-693c-11ea-3b26-d9b7aac5d958]
[ Info: Precompiling Diffusion3D_minimal [91637811-9d05-4227-81a2-fe1d069b6ecb]
[ Info: Precompiling D3D_CUDAExt [38fae68b-b861-5d3c-b423-1a3f5200d4e2]
┌ Warning: Module D3D_CUDAExt with build ID ffffffff-ffff-ffff-000e-c267534cc71f is missing from the cache.
│ This may mean D3D_CUDAExt [38fae68b-b861-5d3c-b423-1a3f5200d4e2] does not support precompilation but is imported by a module that does.
└ @ Base loading.jl:1942
┌ Error: Error during loading of extension D3D_CUDAExt of Diffusion3D_minimal, use `Base.retry_load_extensions()` to retry.
│   exception =
│    1-element ExceptionStack:
│    Declaring __precompile__(false) is not allowed in files that are being precompiled.
│    Stacktrace:
│      [1] _require(pkg::Base.PkgId, env::Nothing)
│        @ Base ./loading.jl:1946
│      [2] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
│        @ Base ./loading.jl:1806
│      [3] #invoke_in_world#3
│        @ Base ./essentials.jl:921 [inlined]
│      [4] invoke_in_world
│        @ Base ./essentials.jl:918 [inlined]
│      [5] _require_prelocked
│        @ Base ./loading.jl:1797 [inlined]
│      [6] _require_prelocked
│        @ Base ./loading.jl:1796 [inlined]
│      [7] run_extension_callbacks(extid::Base.ExtensionId)
│        @ Base ./loading.jl:1289
│      [8] run_extension_callbacks(pkgid::Base.PkgId)
│        @ Base ./loading.jl:1324
│      [9] run_package_callbacks(modkey::Base.PkgId)
│        @ Base ./loading.jl:1158
│     [10] __require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base ./loading.jl:1813
│     [11] #invoke_in_world#3
│        @ Base ./essentials.jl:921 [inlined]
│     [12] invoke_in_world
│        @ Base ./essentials.jl:918 [inlined]
│     [13] _require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base ./loading.jl:1797
│     [14] macro expansion
│        @ Base ./loading.jl:1784 [inlined]
│     [15] macro expansion
│        @ Base ./lock.jl:267 [inlined]
│     [16] __require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:1747
│     [17] #invoke_in_world#3
│        @ Base ./essentials.jl:921 [inlined]
│     [18] invoke_in_world
│        @ Base ./essentials.jl:918 [inlined]
│     [19] require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:1740
│     [20] include
│        @ Base ./Base.jl:489 [inlined]
│     [21] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
│        @ Base ./loading.jl:2216
│     [22] top-level scope
│        @ stdin:3
│     [23] eval
│        @ Core ./boot.jl:383 [inlined]
│     [24] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
│        @ Base ./loading.jl:2070
│     [25] include_string
│        @ Base ./loading.jl:2080 [inlined]
│     [26] exec_options(opts::Base.JLOptions)
│        @ Base ./client.jl:316
│     [27] _start()
│        @ Base ./client.jl:552
└ @ Base loading.jl:1295
("/scratch/snx3000tds/julia/omlins/daint-gpu/compiled/v1.10/D3D_CUDAExt/owmDu_K34O8.ji", "/scratch/snx3000tds/julia/omlins/daint-gpu/compiled/v1.10/D3D_CUDAExt/owmDu_K34O8.so")

If one of the two extensions is deactivated by commenting the corresponding line in the project.toml (e.g. #D3D_AMDGPUExt = "AMDGPU" to deactivate the AMDGPU extension), then the problem disappears, e.g.:

julia> Base.compilecache(Base.PkgId(Base.UUID("94395366-693c-11ea-3b26-d9b7aac5d958"), "ParallelStencil")); Base.compilecache(Base.PkgId(Base.UUID("91637811-9d05-4227-81a2-fe1d069b6ecb"), "Diffusion3D_minimal")); Base.compilecache(Base.PkgId(Base.UUID("38fae68b-b861-5d3c-b423-1a3f5200d4e2"), "D3D_CUDAExt"))
[ Info: Precompiling ParallelStencil [94395366-693c-11ea-3b26-d9b7aac5d958]
[ Info: Precompiling Diffusion3D_minimal [91637811-9d05-4227-81a2-fe1d069b6ecb]
[ Info: Precompiling D3D_CUDAExt [38fae68b-b861-5d3c-b423-1a3f5200d4e2]
("/scratch/snx3000tds/julia/omlins/daint-gpu/compiled/v1.10/D3D_CUDAExt/owmDu_K34O8.ji", "/scratch/snx3000tds/julia/omlins/daint-gpu/compiled/v1.10/D3D_CUDAExt/owmDu_K34O8.so")

Note that ParallelStencil does not contain any module __init__ definition.

The problem appears with both tested julia versions, 1.9.4 and 1.10.