JuliaParallel / JuliaParallel/MPI.jl
Simple hello world example fails with JuliaC using --experimental --trim
- Dominant language
- Julia
- Stars
- 439
- Forks
- 127
- Avg merge
- 19h 6m
- Merged PRs (30d)
- 17
Description
I've been playing around with [JuliaC](https://github.com/JuliaLang/JuliaC.jl) and thought I would give a simple ```MPI.jl``` example a go. This is a simple adaptation of [this Hello, World! example](https://juliaparallel.org/MPI.jl/stable/examples/01-hello/)
```julia
using MPI
function @main(ARGS)
MPI.Init()
comm = MPI.COMM_WORLD
print(Core.stdout, "Hello world, I am rank $(MPI.Comm_rank(comm)) of $(MPI.Comm_size(comm))\n")
return 0
end
```
Without ```--experimental --trim=safe``` everything works as expected with a binary size of around 300MB.
However, with ```--experimental --trim=safe``` we get the following errors
```
Compiling...Verifier error #1: unresolved call from statement (Base.memoryrefget(Base.memoryrefnew(Base.getfield(MPI.mpi_init_hooks, :ref)::MemoryRef{Any}, 1, false::Bool)::MemoryRef{Any}, :not_atomic, false::Bool)::Any)()::Any
Stacktrace:
[1] run_init_hooks()
@ MPI ~/.julia/packages/MPI/hNJm0/src/environment.jl:66
[2] Init(; threadlevel::Symbol, finalize_atexit::Bool, errors_return::Bool)
@ MPI ~/.julia/packages/MPI/hNJm0/src/environment.jl:155
[3] Init()
@ MPI ~/.julia/packages/MPI/hNJm0/src/environment.jl:114 [inlined]
[4] main(ARGS::Vector{String})
@ Main ~/Cthonios/ParaTaxi/examples/src/HelloWorld.jl:4
[5] _main(argc::Int32, argv::Ptr{Ptr{Int8}})
@ Main ~/.julia/packages/JuliaC/EFQEY/src/scripts/juliac-buildscript.jl:77
Verifier error #2: unresolved call from statement (f::typeof(MPI.call))(φ ()::Any)::Any
Stacktrace:
[1] foreach(f::typeof(MPI.call), itr::Vector{Any})
@ Base abstractarray.jl:3188
[2] run_load_time_hooks()
@ MPI ~/.julia/packages/MPI/hNJm0/src/MPI.jl:74
[3] __init__()
@ MPI ~/.julia/packages/MPI/hNJm0/src/MPI.jl:174
Verifier error #3: unresolved call from statement (%new()::MPI.var"#copy#copy##0"{MPI.OpWrapper{typeof(xor), Any}, Ptr{Nothing}, Ptr{Nothing}, Int32})(MPI.to_type(%new()::MPI.Datatype)::Any)::Any
Stacktrace:
[1] (::MPI.OpWrapper{typeof(xor), Any})(_a::Ptr{Nothing}, _b::Ptr{Nothing}, _len::Ptr{Int32}, t::Ptr{Int32})
@ MPI ~/.julia/packages/MPI/hNJm0/src/operators.jl:98
Verifier error #4: unresolved call from statement (%new()::MPI.var"#copy#copy##0"{MPI.OpWrapper{typeof(|), Any}, Ptr{Nothing}, Ptr{Nothing}, Int32})(MPI.to_type(%new()::MPI.Datatype)::Any)::Any
Stacktrace:
[1] (::MPI.OpWrapper{typeof(|), Any})(_a::Ptr{Nothing}, _b::Ptr{Nothing}, _len::Ptr{Int32}, t::Ptr{Int32})
@ MPI ~/.julia/packages/MPI/hNJm0/src/operators.jl:98
Verifier error #5: unresolved call from statement (%new()::MPI.var"#copy#copy##0"{MPI.OpWrapper{typeof(&), Any}, Ptr{Nothing}, Ptr{Nothing}, Int32})(MPI.to_type(%new()::MPI.Datatype)::Any)::Any
Stacktrace:
[1] (::MPI.OpWrapper{typeof(&), Any})(_a::Ptr{Nothing}, _b::Ptr{Nothing}, _len::Ptr{Int32}, t::Ptr{Int32})
@ MPI ~/.julia/packages/MPI/hNJm0/src/operators.jl:98
Verifier error #6: unresolved call from statement (%new()::MPI.var"#copy#copy##0"{MPI.OpWrapper{typeof(*), Any}, Ptr{Nothing}, Ptr{Nothing}, Int32})(MPI.to_type(%new()::MPI.Datatype)::Any)::Any
Stacktrace:
[1] (::MPI.OpWrapper{typeof(*), Any})(_a::Ptr{Nothing}, _b::Ptr{Nothing}, _len::Ptr{Int32}, t::Ptr{Int32})
@ MPI ~/.julia/packages/MPI/hNJm0/src/operators.jl:98
Verifier error #7: unresolved call from statement (%new()::MPI.var"#copy#copy##0"{MPI.OpWrapper{typeof(+), Any}, Ptr{Nothing}, Ptr{Nothing}, Int32})(MPI.to_type(%new()::MPI.Datatype)::Any)::Any
Stacktrace:
[1] (::MPI.OpWrapper{typeof(+), Any})(_a::Ptr{Nothing}, _b::Ptr{Nothing}, _len::Ptr{Int32}, t::Ptr{Int32})
@ MPI ~/.julia/packages/MPI/hNJm0/src/operators.jl:98
Verifier error #8: unresolved call from statement (%new()::MPI.var"#copy#copy##0"{MPI.OpWrapper{typeof(max), Any}, Ptr{Nothing}, Ptr{Nothing}, Int32})(MPI.to_type(%new()::MPI.Datatype)::Any)::Any
Stacktrace:
[1] (::MPI.OpWrapper{typeof(max), Any})(_a::Ptr{Nothing}, _b::Ptr{Nothing}, _len::Ptr{Int32}, t::Ptr{Int32})
@ MPI ~/.julia/packages/MPI/hNJm0/src/operators.jl:98
Verifier error #9: unresolved call from statement (%new()::MPI.var"#copy#copy##0"{MPI.OpWrapper{typeof(min), Any}, Ptr{Nothing}, Ptr{Nothing}, Int32})(MPI.to_type(%new()::MPI.Datatype)::Any)::Any
Stacktrace:
[1] (::MPI.OpWrapper{typeof(min), Any})(_a::Ptr{Nothing}, _b::Ptr{Nothing}, _len::Ptr{Int32}, t::Ptr{Int32})
@ MPI ~/.julia/packages/MPI/hNJm0/src/operators.jl:98
Verifier error #10: unresolved call from statement (Base.memoryrefget(Base.memoryrefnew(Base.getfield(MPI.mpi_init_hooks, :ref)::MemoryRef{Any}, 1, false::Bool)::MemoryRef{Any}, :not_atomic, false::Bool)::Any)()::Any
Stacktrace:
[1] run_init_hooks()
@ MPI ~/.julia/packages/MPI/hNJm0/src/environment.jl:66
[2] Init(; threadlevel::Symbol, finalize_atexit::Bool, errors_return::Bool)
@ MPI ~/.julia/packages/MPI/hNJm0/src/environment.jl:155
[3] Init()
@ MPI ~/.julia/packages/MPI/hNJm0/src/environment.jl:114 [inlined]
[4] main(ARGS::Vector{String})
@ Main ~/Cthonios/ParaTaxi/examples/src/HelloWorld.jl:4
◐ Compiling..._main(argc::Int32, argv::Ptr{Ptr{Int8}})
@ Main ~/.julia/packages/JuliaC/EFQEY/src/scripts/juliac-buildscript.jl:77
Trim verify finished with 10 errors, 0 warnings.
✓ Compiling...
ERROR: LoadError: Failed to compile src/HelloWorld.jl
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:44
[2] compile_products(recipe::ImageRecipe)
@ JuliaC ~/.julia/packages/JuliaC/EFQEY/src/compiling.jl:142
[3] top-level scope
@ ~/Cthonios/ParaTaxi/examples/build.jl:24
[4] include(mod::Module, _path::String)
@ Base ./Base.jl:306
[5] exec_options(opts::Base.JLOptions)
@ Base ./client.jl:317
[6] _start()
@ Base ./client.jl:550
```
From what I can gather through looking through the ```src``` code, it looks like there's an array of functions at the module level that are run during ```MPI.Init()``` that leads to these unresolved calls.
I'm happy to help put effort into fixing this currently *niche* use case, but thought I would open an issue first to see if the maintainers have any qualms before putting effort in.
It would be great to bring small binaries with MPI to the community!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.