How to compile a julia script?

主宰稳场 提交于 2019-12-03 23:37:42

Here's an example, from a julia source build on OS X, with /tmp/test.jl as:

function foo()
    print(123)
end

precompile(foo, ())

And julia/base/userimg.jl as include("/tmp/test.jl")

Execute the following inside the julia/base directory:

julia --compile=yes --output-bc test.bc -J ../usr/lib/julia/inference.ji sysimg.jl

Then run llvm-dis test.bc -o test.ll. Somewhere in the (enormous) image we have the relevant bytecode for the test function:

define internal %jl_value_t* @julia_foo_22542() {
top:
  %0 = alloca [4 x %jl_value_t*], align 8, !dbg !51528 
...

That said, as of now (Dec. 2015), Julia is not usable for ahead-of-time compilation of stand-alone executables. However, the following may be of interest:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!