Skip to content

LoadError during package precompilation when using @doc to copy docstrings #48390

@topolarity

Description

@topolarity

MWE (derived from MyLib example in PackageCompiler.jl):

module MyLib
​
export increment32, increment64
​
function increment(count)
    count += 1
    return count
end
​
Base.@ccallable function increment32(count::Cint)::Cint
    count = increment(count)
    println("Incremented count: $count (Cint)")
    return count
end
​
Base.@ccallable function increment64(count::Clong)::Clong
    count = increment(count)
    println("Incremented count: $count (Clong)")
    return count
end@doc "Testing" increment32
@doc (@doc increment32) increment64 # This is the problematic lineend

If PackageCompiler.jl is modified to use --strip-metadata during sysimage pre-compilation, then this fails specifically for non-incremental package compilation:

PS C:\Users\topolarity\repos\PackageCompiler.jl\examples> julia +1.8 -q --project
julia> using PackageCompiler

julia> create_library("MyLib", "MyLibCompiled";
                             lib_name="libinc",
                             precompile_execution_file="MyLib/build/generate_precompile.jl",
                             precompile_statements_file="MyLib/build/additional_precompile.jl",
                             header_files = ["MyLib/build/mylib.h"])
✔ [03m:43s] PackageCompiler: compiling base system image (incremental=false)
✔ [05m:08s] PackageCompiler: compiling nonincremental system image
Precompiling project...
  ✗ MyLib
  0 dependencies successfully precompiled in 3 seconds

ERROR: The following 1 direct dependency failed to precompile:

MyLib [a1a1a4a2-71b6-406f-b13d-8701d2765a5f]

Failed to precompile MyLib [a1a1a4a2-71b6-406f-b13d-8701d2765a5f] to C:\Users\topolarity\.julia\compiled\v1.8\MyLib\jl_24B0.tmp.
ERROR: LoadError: Evaluation into the closed module `Order` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `Order` with `eval` during precompilation - don't do this.
Stacktrace:
  [1] initmeta(?::Module)
    @ Base.Docs .\docs\Docs.jl:83
  [2] iterate
    @ .\array.jl:898 [inlined]
  [3] doc(?::Base.Docs.Binding, ?::Type)
    @ REPL C:\Users\topolarity\.julia\juliaup\julia-1.8.5+0.x64.w64.mingw32\share\julia\stdlib\v1.8\REPL\src\docview.jl:0
  [4] doc(?::Base.Docs.Binding)
    @ REPL C:\Users\topolarity\.julia\juliaup\julia-1.8.5+0.x64.w64.mingw32\share\julia\stdlib\v1.8\REPL\src\docview.jl:159
  [5] top-level scope
    @ C:\Users\topolarity\repos\PackageCompiler.jl\examples\MyLib\src\MyLib.jl:23
 ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions