Correct usage of build_sysimg

I am unable to build a system image using the build_sysimg command. I get different types of errors.

Assume that I want to build a system with the following user definitions:

# file userimg.jl
function bar()
  println("Hi bar!")

@generated function foo(x::T) where T
  println("Compiling foo function for type $T")

# Force compilation

Then, following the docuentation in
I try to build the system image as follows:

$ julia ~/Apps/julia/julia-1.1.0-linux-x86_64/julia-1.1.0/share/julia/build_sysimg.jl ./sys native ./userimg.jl
ERROR: LoadError: UndefVarError: Libdl not defined
 [1] #build_sysimg#3(::Bool, ::Bool, ::Function, ::String, ::String, ::String) at /home/verdugo/Apps/julia/julia-1.1.0-linux-x86_64/julia-1.1.0/share/julia/build_sysimg.jl:33
 [2] (::getfield(Main, Symbol("#kw##build_sysimg")))(::NamedTuple{(:force, :debug),Tuple{Bool,Bool}}, ::typeof(build_sysimg), ::String, ::String, ::String) at ./none:0
 [3] top-level scope at /home/verdugo/Apps/julia/julia-1.1.0-linux-x86_64/julia-1.1.0/share/julia/build_sysimg.jl:209
 [4] include at ./boot.jl:326 [inlined]
 [5] include_relative(::Module, ::String) at ./loading.jl:1038
 [6] include(::Module, ::String) at ./sysimg.jl:29
 [7] exec_options(::Base.JLOptions) at ./client.jl:267
 [8] _start() at ./client.jl:436
in expression starting at /home/verdugo/Apps/julia/julia-1.1.0-linux-x86_64/julia-1.1.0/share/julia/build_sysimg.jl:187

Seems to be a missin using Libdl, right? So I try to load Libdl and run the command, but I get another error:

verdugo@debian:~/Code/jl/tests/userimg$ julia
   _       _ _(_)_     |  Documentation:
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.0 (2019-01-21)
 _/ |\__'_|_|_|\__'_|  |  Official release
|__/                   |

julia> include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "build_sysimg.jl"))

julia> using Libdl

julia> build_sysimg("sys","native","userimg.jl")
ERROR: UndefVarError: info not defined
 [1] (::getfield(Main, Symbol("##4#5")){Bool,String,String})() at /home/verdugo/Apps/julia/julia-1.1.0-linux-x86_64/julia-1.1.0/share/julia/build_sysimg.jl:74
 [2] cd(::getfield(Main, Symbol("##4#5")){Bool,String,String}, ::String) at ./file.jl:96
 [3] #build_sysimg#3(::Bool, ::Bool, ::Function, ::String, ::String, ::String) at /home/verdugo/Apps/julia/julia-1.1.0-linux-x86_64/julia-1.1.0/share/julia/build_sysimg.jl:48
 [4] build_sysimg(::String, ::String, ::String) at /home/verdugo/Apps/julia/julia-1.1.0-linux-x86_64/julia-1.1.0/share/julia/build_sysimg.jl:28
 [5] top-level scope at none:0

Can somebody tell me what I am doing wrong? Thanks for the help! suggests that this is a known issue and the docs should be adjusted to point to PackageCompiler.jl instead of the method in the manual.

1 Like

Good to know. Thanks!