I was wondering if there was a way of checking what happens on Julia side when executing a
ccall function. Consider the following code:
@code_typed ccall(("expm1", Base.Math.libm), Float64, (Float64,), 1.5)
This would give an error:
ERROR: UndefVarError: ccall not defined
Even if wrapping the
ccall in a
function, I don’t get many informations out:
function my_func() return ccall(("expm1", Base.Math.libm), Float64, (Float64,), 1.5) end @code_typed my_func()
CodeInfo( 2 1 ─ %1 = $(Expr(:foreigncall, :((Core.tuple)("expm1", Base.Math.libm)), Float64, svec(Float64), :(:ccall), 1, 1.5, 1.5))::Float64 │ └── return %1 │ ) => Float64
Digging through the source code, I could not find where an
Expr(:foreigncall, ...) actually turns into Julia functions. I would like to find these, and precompile them for some calls into C libraries that I need, without having to execute
ccall once per C function to compile all the Julia stuff, considering that all the C side is already compiled.
I hope it makes sense.