JuliaC with --trim=no

Hi,

Is JuliaC supposed to work compiling arbitrary code with --trim=no?

I’m trying to compile an interactive Makie plot (wouldn’t expect it to work with --trim), so I set --trim=no. I don’t mind a (very) large binary if JuliaC can buy me convenient compilation for faster startup.

The cmdline is

~/.julia/bin/juliac \
  --project . \
  --output-exe beta-binomial-clinical-trial \
  --bundle build \
  --trim=no \
  --experimental \
  trial.jl

and compilation seems to proceed smoothly:

✓ Compiling...
PackageCompiler: bundled libraries:
  ├── Base:
  │    ├── libLLVM.so.18.1jl - 108.317 MiB
  │    ├── libatomic.so.1.2.0 - 159.875 KiB
  │    ├── libdSFMT.so - 21.602 KiB
  │    ├── libgcc_s.so.1 - 892.930 KiB
  │    ├── libgfortran.so.5.0.0 - 9.603 MiB
  │    ├── libgmp.so.10.5.0 - 707.688 KiB
  │    ├── libgmpxx.so.4.7.0 - 47.453 KiB
  │    ├── libgomp.so.1.0.0 - 1.469 MiB
  │    ├── libjulia-codegen.so.1.12.1 - 77.474 MiB
  │    ├── libjulia-internal.so.1.12.1 - 14.173 MiB
  │    ├── libmpfr.so.6.2.2 - 2.416 MiB
  │    ├── libopenlibm.so.4.0 - 248.109 KiB
  │    ├── libpcre2-8.so.0.13.0 - 663.234 KiB
  │    ├── libquadmath.so.0.0.0 - 966.984 KiB
  │    ├── libssp.so.0.0.0 - 35.555 KiB
  │    ├── libstdc++.so.6.0.33 - 3.018 MiB
  │    ├── libunwind.so.8.1.0 - 510.797 KiB
  │    ├── libuv.so.2.0.0 - 656.695 KiB
  │    ├── libz.so.1.3.1 - 116.062 KiB
  │    ├── libjulia.so.1.12.1 - 246.195 KiB
  ├── Stdlibs:
  │   ├── OpenBLAS_jll
  │   │   ├── libopenblas64_.0.3.29.so - 34.444 MiB
  │   ├── LibCURL_jll
  │   │   ├── libcurl.so.4.8.0 - 893.742 KiB
  │   ├── LibGit2_jll
  │   │   ├── libgit2.so.1.9.0 - 1.845 MiB
  │   ├── nghttp2_jll
  │   │   ├── libnghttp2.so.14.28.3 - 762.971 KiB
  │   ├── SuiteSparse_jll
  │   │   ├── libamd.so.3.3.3 - 40.984 KiB
  │   │   ├── libbtf.so.2.3.2 - 12.875 KiB
  │   │   ├── libcamd.so.3.3.3 - 45.023 KiB
  │   │   ├── libccolamd.so.3.3.4 - 48.969 KiB
  │   │   ├── libcholmod.so.5.3.0 - 2.093 MiB
  │   │   ├── libcolamd.so.3.3.4 - 32.758 KiB
  │   │   ├── libklu.so.2.3.5 - 214.812 KiB
  │   │   ├── libldl.so.3.3.2 - 12.974 KiB
  │   │   ├── librbio.so.4.3.4 - 68.945 KiB
  │   │   ├── libspqr.so.4.3.4 - 458.539 KiB
  │   │   ├── libsuitesparseconfig.so.7.8.3 - 14.906 KiB
  │   │   ├── libumfpack.so.6.3.5 - 819.430 KiB
  │   ├── libblastrampoline_jll
  │   │   ├── libblastrampoline.so.5 - 3.418 MiB
  │   ├── OpenSSL_jll
  │   │   ├── libcrypto.so.3 - 6.308 MiB
  │   │   ├── libssl.so.3 - 1.289 MiB
  │   ├── LibSSH2_jll
  │   │   ├── libssh2.so.1.0.1 - 381.633 KiB
  Total library file size: 274.738 MiB
PackageCompiler: bundled artifacts:
  ├── Bzip2_jll - 1.440 MiB
  ├── CRlibm_jll - 477.009 KiB
  ├── Cairo_jll - 6.078 MiB
  ├── Dbus_jll - 1.245 MiB
  ├── EarCut_jll - 465.485 KiB
  ├── Expat_jll - 851.049 KiB
  ├── FFMPEG_jll - 27.047 MiB
  ├── FFTW_jll - 5.637 MiB
  ├── Fontconfig_jll - 2.734 MiB
  ├── FreeType2_jll - 4.306 MiB
  ├── FriBidi_jll - 322.748 KiB
  ├── GLFW_jll - 688.202 KiB
  ├── GettextRuntime_jll - 1.781 MiB
  ├── Giflib_jll - 352.143 KiB
  ├── Glib_jll - 27.295 MiB
  ├── Graphite2_jll - 290.547 KiB
  ├── HarfBuzz_jll - 4.532 MiB
  ├── Imath_jll - 882.477 KiB
  ├── JpegTurbo_jll - 5.122 MiB
  ├── LAME_jll - 886.247 KiB
  ├── LERC_jll - 803.197 KiB
  ├── LLVMOpenMP_jll - 1.976 MiB
  ├── LZO_jll - 890.119 KiB
  ├── Libffi_jll - 128.649 KiB
  ├── Libglvnd_jll - 4.743 MiB
  ├── Libiconv_jll - 4.064 MiB
  ├── Libmount_jll - 20.990 MiB
  ├── Libtiff_jll - 8.818 MiB
  ├── Libuuid_jll - 11.162 MiB
  ├── Makie
  │   └── MakieAssets - 41.279 MiB
  ├── Ogg_jll - 557.139 KiB
  ├── OpenBLASConsistentFPCSR_jll - 35.825 MiB
  ├── OpenEXR_jll - 7.532 MiB
  ├── OpenSpecFun_jll - 545.579 KiB
  ├── Opus_jll - 2.713 MiB
  ├── Pango_jll - 3.126 MiB
  ├── Pixman_jll - 965.658 KiB
  ├── Rmath_jll - 269.463 KiB
  ├── Wayland_jll - 1.335 MiB
  ├── XZ_jll - 5.103 MiB
  ├── Xorg_libX11_jll - 51.111 MiB
  ├── Xorg_libXau_jll - 128.466 KiB
  ├── Xorg_libXcursor_jll - 690.396 KiB
  ├── Xorg_libXdmcp_jll - 297.893 KiB
  ├── Xorg_libXext_jll - 2.311 MiB
  ├── Xorg_libXfixes_jll - 223.277 KiB
  ├── Xorg_libXi_jll - 5.872 MiB
  ├── Xorg_libXinerama_jll - 151.557 KiB
  ├── Xorg_libXrandr_jll - 1.252 MiB
  ├── Xorg_libXrender_jll - 1.457 MiB
  ├── Xorg_libxcb_jll - 10.588 MiB
  ├── Xorg_libxkbfile_jll - 1.487 MiB
  ├── Xorg_xkbcomp_jll - 753.413 KiB
  ├── Xorg_xkeyboard_config_jll - 3.191 MiB
  ├── Xorg_xtrans_jll - 216.336 KiB
  ├── Zstd_jll - 1.615 MiB
  ├── isoband_jll - 79.016 KiB
  ├── libaom_jll - 18.100 MiB
  ├── libass_jll - 1.234 MiB
  ├── libdecor_jll - 154.640 KiB
  ├── libfdk_aac_jll - 8.483 MiB
  ├── libpng_jll - 971.621 KiB
  ├── libsixel_jll - 643.053 KiB
  ├── libvorbis_jll - 1.083 MiB
  ├── libwebp_jll - 8.757 MiB
  ├── x264_jll - 5.311 MiB
  ├── x265_jll - 6.621 MiB
  └── xkbcommon_jll - 808.265 KiB
  Total artifact file size: 378.508 MiB

but trying to run the binary buries my terminal in text and I don’t see the GLMakie window. The output begins:

fatal: error thrown and no exception handler available.
MethodError(f=Base.convert, args=(Int32, Makie.Figure(scene=Makie.Scene(parent=nothing, events=Makie.Events(window_area=Observables.Observable{GeometryBasics.HyperRectangle{2, Int64}}(listeners=Array{Pair{Int64, Any}, 1}(dims=(1,), mem=Memory{Pair{Int64, Any}}(3, 0x7f71955f4c50)[Pair{Int64, Any}(first=0, second=#<null>), Pair{Int64, Any}(first=9223372036854775807, second=Makie.var"#295#296"(viewport=Core.Box(contents=Observables.Observable{GeometryBasics.HyperRectangle{2, Int64}}(listeners=Array{Pair{Int64, Any}, 1}(dims=(15,), mem=Memory{Pair{Int64, Any}}(34, 0x7f7195321fa0)[Pair{Int64, Any}(first=9223372036854775806, second=ComputePipeline.var"#add_input!##0#add_input!##1"{ComputePipeline.ComputeGraph, Symbol}(attr=ComputePipeline.ComputeGraph(inputs=Base.Dict{Symbol, ComputePipeline.Input{T} where T}(slots=Memory{UInt8}(16, 0x7f719561ec00)[0xfe, 0xee, 0xca, 0x95, 0x00, 0x93, 0xff, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0xa7, 0xa0, 0xf9], keys=Memory{Symbol}(16, 0x7f719578e640)[
  :view_direction,
  :viewport,
  :view,
  :ambient_color,
  #<null>,
  :lights,
  :transform_func,
  #<null>,

Many thanks! I’m very excited to be able to start to use Julia in more places.

2 Likes

Have you tried CairoMakie and writing the plot to a file? I could imagine that the interaction with OpenGL may be tricky…

Just guessing here but the error says that a conversion from Makie.Figure to Int32 is being attempted, which sounds a bit like you return a Makie figure at the end of your program (as you usually would in the REPL to make it display) and instead this is attempted to be used as the exit code. Outside of the REPL displaying a plot works differently, you need to call wait(display(fig)) which will keep the process running as long as the window is open.

9 Likes