如何编译julia脚本? [英] How to compile a julia script?

查看:2189
本文介绍了如何编译julia脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到julia的版本0.4。*有一个 - compile 选项。



奇怪,我找不到任何关于它的文档。



我试图(在Ubuntu中)将julia脚本编译为可执行的LLVM字节码文件。但直到这里,我失败了:

  julia --compile = yes --output -bc test.bc test.jl 
分段错误(内核转储)

我也可以得到这个错误信息:

  julia --compile = yes --output-bc test.bc test.jl 
错误:无法打开文件boot.jl

这个错误不再出现,如果我放一个 boot.jl 文件。



如何将julia脚本编译为可执行文件/混淆的字节码?



编辑:FYI,我的 test.jl 文件只包含 print(123) p>

解决方案

这里有一个例子,来自于在OS X上构建的julia源代码,其中/tmp/test.jl为:

  function foo()
print(123)
end

预编译(foo, )

julia / base / userimg.jl include(/ tmp / test.jl)



执行 julia / base 目录:

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

然后运行 llvm-dis test.bc -o test.ll 。在(巨大的)图像的某处,我们有测试函数的相关字节码:

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

这就是说,截至目前(2015年12月),Julia不能用于独立可执行文件的提前编译。但是,您可能会感兴趣以下内容:




I have noticed that the version 0.4.* of julia has a --compile option.

Strangely, I cannot find any documentation about it.

I was trying (in Ubuntu), to compile a julia script to an executable LLVM bytecode file. But until here, I failed:

julia --compile=yes --output-bc test.bc test.jl
Segmentation fault (core dumped)

I also can get this error message:

julia --compile=yes --output-bc test.bc test.jl
ERROR: could not open file boot.jl

This error does not appear anymore, if I put a boot.jl file in the same folder.

How should I do to compile a julia script to an executable/obfuscated bytecode ?

Edit: FYI, my test.jl file contains only print(123)

解决方案

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:

这篇关于如何编译julia脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆