JuliaLang / PackageCompiler.jl

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

ERROR: System image file failed consistency check [MacBook Pro M3, macOs 14.5, latest Julia and PackageCompiler.jl] #950

Closed mgiugliano closed 1 day ago

mgiugliano commented 3 months ago

Minimal Working Example

using PackageCompiler
create_sysimage(["Plots"], sysimage_path="sys_myimage.so", include_transitive_dependencies=false, precompile_execution_file="myfile.jl")

with myfile.jl being:

using Plots

x = 1:10:100
y = sin.(x)

plot(x,y, show=true)

PackageCompiler returns the following output, with ld returning a warning:

Precompiling project...
  38 dependencies successfully precompiled in 20 seconds. 139 already precompiled.
[ Info: PackageCompiler: Executing /Users/michi/myfile.jl => /var/folders/kx/lw7dt7y50_98_hknqssfl4xh0000gn/T/jl_packagecompiler_eho51P/jl_YrqDBD
[ Info: PackageCompiler: Done
✔ [00m:48s] PackageCompiler: compiling incremental system image
ld: warning: reexported library with install name '@rpath/libunwind.1.dylib' found at '/Users/michi/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/lib/julia/libunwind.1.0.dylib' couldn't be matched with any parent library and will be linked directly

(note1: adding or removing the include_transitive_dependencies=false makes no difference) (note2: if include_transitive_dependencies=true, then an error is produced:

[ Info: PackageCompiler: Done
⠇ [00m:06s] PackageCompiler: compiling incremental system image┌ Error: Error during loading of extension UnitfulExt of Plots, use `Base.retry_load_extensions()` to retry.
│   exception = 1-element ExceptionStack:
ConcurrencyViolationError("deadlock detected in loading UnitfulLatexify -> UnitfulLatexify && UnitfulExt")

Then, in any case, the sys_myimage.so generated is only 16KB in size (you find it here for download), and it does not work with

julia --sysimage sys_myimage.so

that returns an error:

ERROR: System image file failed consistency check: maybe opened the wrong version?

Finally, the exact same MWE works as expected and it generates a larger image, on a different architecture (i.e., Google Colab - see this minimal notebook)

Output of versioninfo()

Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 12 × Apple M3 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 6 virtual cores)
Environment:
  JULIA_EDITOR = /opt/homebrew/bin/code

Julia installed with Juliaup 1.14.8

Installed packages

Status `~/.julia/environments/v1.10/Project.toml`
  [8bb1440f] DelimitedFiles v1.9.1
  [f67ccb44] HDF5 v0.17.2
  [7073ff75] IJulia v1.25.0
  [b964fa9f] LaTeXStrings v1.3.1
  [5fb14364] OhMyREPL v0.5.27
  [9b87118b] PackageCompiler v2.1.17
  [91a5bcdd] Plots v1.40.4
  [e409e4f3] PoissonRandom v0.4.4
  [295af30f] Revise v3.5.15
  [37e2e46d] LinearAlgebra
  [2f01184e] SparseArrays v1.10.0
topolarity commented 3 months ago

Looks like https://github.com/JuliaLang/PackageCompiler.jl/issues/738 - @gbaraldi it would be great if we can land your fix in the coming weeks

mgiugliano commented 3 months ago

@topolarity Thank you!!

For the records:

I just tried, without success,

export JULIA_CC="gcc-14"

(sys image is now 2.6 MB, instead of 16 KB).

However it finally worked, when I adopted the modified create_sysimg_from_object_file function in the /src/PackageCompiler.jl source code, as mentioned in #738 !

DilumAluthge commented 1 day ago

This looks like a duplicate of #738, which should be fixed in the recently-released PackageCompiler v2.1.19.

@mgiugliano Can you try out PackageCompiler v2.1.19 and let me know if it fixes the bug for you?

If your issue still occurs on PackageCompiler v2.1.19, let me know, and I will re-open this issue.

DilumAluthge commented 1 day ago

Duplicate of #738