Transpiling Julia to C

Hi,

I’m new to Julia. I read the blog posts on static compilation and transpiling Julia to C, and I tried to do it by myself.
I followed the instructions and I built Julia (0.6.0-dev), I compiled llvm (3.7.1) and llvm-cbe. The bottom line is that I’m running the conversion command and nothing happen, there are no errors and no output file.
The process that I have done is as follows:

  • I’m working on Ubuntu 12.04 (I know it’s old…) in a virtual machine using VirtualBox. I’m using gcc version 4.8.1.
  • I built Julia according to the instructions in the website. I have run the make command successfully, but I didn’t manage to run the make install command due to dependencies in Python that I haven’t resolved yet. Maybe this is the reason for the problem…
  • I compiled llvm (as part of the compilation of Julia).
  • I compiled llvm-cbe.
  • I have generated HelloWorld.jl code:
    function main()
    println(“hello world!”)
    end
  • I saved the file in base directory and I put there a userimg.jl containing the line: include(“HelloWorld.jl”).
  • Then I run the following commands inside the base directory:
  1. sudo julia -C native --output-ji inference.ji coreimg.jl (the inference file was created)
  2. sudo julia -C native --output-o libHelloWorld.o -J inference.ji --startup-file=no sysimg.jl (the o file was created)
  3. sudo cc -L"…/usr/lib" -ljulia -shared -o libHelloWorld.so libHelloWorld.o (the file was created)
  4. sudo julia --output-bc libHelloWorld.bc -J libHelloWorld.so --startup-file=no --compile=yes --eval nothing (the file was created)
    Note: when I have tried the compile all option I got a segmentation fault. The output is attached below the post.
  5. sudo …/deps/scratch/llvm-3.7.1/build_Release/Release/bin/llvm-cbe libHelloWorld.bc libHelloWorld.cbe.c
    During the execution of the command I see the c file created in the directory (with a size of 0B) but it disappears at the end of the run. Except for that I don’t get any errors or something else.

I would be glad if you help me debug the problem. Does everything related to the fact that I didn’t ran the make install?

Thanks.

Output of compile all option:
found 24348 uncompiled methods for compile-all
2789 / 24348
signal (11): Segmentation fault
while loading no file, in expression starting on line 0
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:574
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587
array_to_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]
julia_to_scm_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587 [inlined]
julia_to_scm at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:542
jl_call_scm_on_ast at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:795 [inlined]
jl_expand at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:806
jl_code_for_staged at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/alloc.c:532
get_staged at ./inference.jl:217
typeinf_frame at ./inference.jl:1590
typeinf_code at ./inference.jl:1686
unknown function (ip: 0x952c4324)
jl_call_method_internal at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/julia_internal.h:240 [inlined]
jl_apply_generic at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1861
typeinf_ext at ./inference.jl:1724
unknown function (ip: 0x952b2ee7)
jl_call_method_internal at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/julia_internal.h:240 [inlined]
jl_apply_generic at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1861
jl_apply at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/julia.h:1378 [inlined]
jl_type_infer at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:211 [inlined]
_compile_all_deq at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1539 [inlined]
jl_compile_all_defs at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1618 [inlined]
jl_precompile at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1685
julia_save at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/init.c:720 [inlined]
jl_atexit_hook at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/init.c:196
unknown function (ip: 0x8048dfd)
__libc_start_main at /lib/i386-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x8048e34)
Allocations: 38582925 (Pool: 38581929; Big: 996); GC: 10