JuliaLang / PackageCompiler.jl

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

Sysimage with `Plots.jl` breaks loading some shared libraries in R (via `RCall.jl`) #926

Closed artemsolod closed 4 months ago

artemsolod commented 4 months ago

I feel this is most likely related to PackageCompiler.jl as the problem appears only when using sysimages. The issue: Without the sysimage R sees all the shared libraries necessary for plotting:

julia> using RCall

julia> R"grSoftVersion()"
RObject{StrSxp}
                   cairo                  cairoFT                    pango
                "1.18.0"                       ""                 "1.52.1"
                  libpng                     jpeg                  libtiff
                "1.6.43"                    "8.0" "LIBTIFF, Version 4.6.0"

with sysimage it doesn't julia --sysimage img_plots.so

julia> using RCall
Precompiling RCall
  1 dependency successfully precompiled in 2 seconds. 28 already precompiled.
[ Info: Precompiling RCall [6f49c342-dc21-5d91-9882-a32aef131414]
[ Info: Precompiling DataFramesExt [9e668153-f473-5010-85ff-a85cbe3b95ea]
[ Info: Precompiling SpecialFunctionsExt [997ecda8-951a-5f50-90ea-61382e97704b]

julia> R"grSoftVersion()"
┌ Warning: RCall.jl: Warning in grSoftVersion() :
│   unable to load shared object '/home/artem.solod/.julia/conda/3/x86_64/lib/R/modules//R_X11.so':
│   /home/artem.solod/.julia/conda/3/x86_64/lib/R/modules//../../libpango-1.0.so.0: undefined symbol: hb_ot_color_has_paint
│ Warning in cairoVersion() :
│   unable to load shared object '/home/artem.solod/.julia/conda/3/x86_64/lib/R/library/grDevices/libs//cairo.so':
│   /home/artem.solod/.julia/conda/3/x86_64/lib/R/library/grDevices/libs//../../../../libpango-1.0.so.0: undefined symbol: hb_ot_color_has_paint
└ @ RCall ~/.julia/packages/RCall/dDAVd/src/io.jl:172
RObject{StrSxp}
  cairo cairoFT   pango  libpng    jpeg libtiff
     ""      ""      ""      ""      ""      ""

Sysimage was built with create_sysimage(["Plots"]; sysimage_path="img_plots.so") Package versions:

(plots_precomp_R_bug) pkg> st
Status `~/plots_precomp_R_bug/Project.toml`
  [9b87118b] PackageCompiler v2.1.17
  [91a5bcdd] Plots v1.40.2
  [6f49c342] RCall v0.14.1

The easiest way to install RCall is to set ENV["R_HOME"] = "*" and then add RCall this will use Conda.jl. I've tried both my system-wide R and fresh installs with the same results. For reference: https://juliainterop.github.io/RCall.jl/stable/installation/

Julia 1.10.2 installed with juliaup

julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, broadwell)
Threads: 1 default, 0 interactive, 1 GC 

Thanks!

artemsolod commented 4 months ago

Narrowed down the issue further, it appears whenever Plots.jl is loaded before RCall.jl so not directly related to PackageCompiler.jl. Will raise an issue in RCall.jl