In section Compilation of functions https://julialang.github.io/PackageCompiler.jl/dev/sysimages.html#tracing, a snippet julia -JExampleSysimagePrecompile.so --trace-compile=stderr -e 'import Example; Example.hello("friend")' is used, however it does not work as of 1.10.1 and error is thrown:
❯ julia -JExampleSysimagePrecompile.so --trace-compile=stderr -e 'import Example; Example.hello("friend")'
precompile(Tuple{typeof(Base.getproperty), NamedTuple{(:exception, :backtrace), Tuple{ArgumentError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}}, Symbol})
precompile(Tuple{typeof(Base.display_error), Base.TTY, Base.ExceptionStack})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), Base.TTY, String})
ERROR: precompile(Tuple{typeof(Base.indexed_iterate), NamedTuple{(:exception, :backtrace), Tuple{ArgumentError, Array{Base.StackTraces.StackFrame, 1}}}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), NamedTuple{(:exception, :backtrace), Tuple{ArgumentError, Array{Base.StackTraces.StackFrame, 1}}}, Int64, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:backtrace,), Tuple{Bool}}, typeof(Base.showerror), Base.IOContext{Base.TTY}, ArgumentError, Array{Base.StackTraces.StackFrame, 1}})
ArgumentError: Package Example not found in current path, maybe you meant `import/using .Example`.
- Otherwise, run `import Pkg; Pkg.add("Example")` to install the Example package.
Stacktrace:
[1] macro expansion
@ ./loading.jl:1772 [inlined]
[2] macro expansion
@ ./lock.jl:267 [inlined]
[3] __require(into::Module, mod::Symbol)
@ Base ./loading.jl:1753
[4] #invoke_in_world#3
@ ./essentials.jl:926 [inlined]
[5] invoke_in_world
@ ./essentials.jl:923 [inlined]
[6] require(into::Module, mod::Symbol)
@ Base ./loading.jl:1746
Similar error is thrown, when changed import to using.
However, in the documentation is shown, that the snippet works.
The correct way (or the way that works) is julia -JExampleSysimagePrecompile.so --trace-compile=stderr -e 'Example.hello("friend")', since the module is already loaded and does not need to be imported.
Version:
julia> versioninfo()
Julia Version 1.10.1
Commit 7790d6f0641 (2024-02-13 20:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × AMD Ryzen 5 2600X Six-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, znver1)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)
In section Compilation of functions https://julialang.github.io/PackageCompiler.jl/dev/sysimages.html#tracing, a snippet
julia -JExampleSysimagePrecompile.so --trace-compile=stderr -e 'import Example; Example.hello("friend")'
is used, however it does not work as of1.10.1
and error is thrown:Similar error is thrown, when changed
import
tousing
. However, in the documentation is shown, that the snippet works.The correct way (or the way that works) is
julia -JExampleSysimagePrecompile.so --trace-compile=stderr -e 'Example.hello("friend")'
, since the module is already loaded and does not need to be imported.Version:
Installed via juliaup.
Steps to reproduce: follow the article https://julialang.github.io/PackageCompiler.jl/dev/sysimages.html