如何编译julia脚本? [英] How to compile a julia script?
问题描述
我注意到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 {
pre>
top:
%0 = alloca [4 x%jl_value_t *],align 8,!dbg!51528
...
这就是说,截至目前(2015年12月),Julia不能用于独立可执行文件的提前编译。但是,您可能会感兴趣以下内容:
- https://github.com/dhoegh/BuildExecutable.jl (不使用
- output-bc
,但是有一个更好的用户界面,并且该选项很容易添加) - https://github.com / JuliaLang / julia / pull / 13677
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:
- https://github.com/dhoegh/BuildExecutable.jl (doesn't use
--output-bc
, as yet, but has a nicer user interface and that option would be easy to add) - https://github.com/JuliaLang/julia/pull/13677
这篇关于如何编译julia脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!