ERROR: could not open file boot.jl

Ubuntu: 19.10
Julia: 1.3.1
when I try to generate LLVM bitcode I got this error

joseph@joseph-X541UJ:~/Documents/Julia$ julia --output-bc test.jl
ERROR: could not open file boot.jl

my test.jl file contains

print("Hello World")

please show me step by step how to fix this issue I’m very begginer.

Hi, @Yousef_Saber, welcome!

Why are you using “–output-bc”? I do not know that option.

Have you tried julia test.jl?

EDIT: Searching by Internet, I think it was used to Generate LLVM bitcode, it is nothing you should require. You also can see it with @code_llvm in the julia REPL.

You need to give an explicit path to the sysimage when you use the --output option (-J path/to/sysimage).

Why are you using “–output-bc”? I do not know that option.

Have you tried julia test.jl ?

I want to compile my julia code not to interpret it.

EDIT: Searching by Internet, I think it was used to Generate LLVM bitcode, it is nothing you should require. You also can see it with @code_llvm in the julia REPL.

yeah I tried that I put the generated code in a text file called test.ll tried to run it using the command

joseph@joseph-X541UJ:~/Documents/Julia$ lli-9 test.ll
lli-9: test.ll:3:15: error: use of undefined type named 'jl_value_t'
  %0 = alloca %jl_value_t addrspace(10)*
              ^

the code in test.ll is as follows

define void @julia_test_17011() {
top:
  %0 = alloca %jl_value_t addrspace(10)*
  %1 = getelementptr %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %0, i32 0
  store %jl_value_t addrspace(10)* addrspacecast (%jl_value_t* inttoptr (i64 139954068073584 to %jl_value_t*) to %jl_value_t addrspace(10)*), %jl_value_t addrspace(10)** %1
  %2 = call nonnull %jl_value_t addrspace(10)* @jsys1_print_4315(%jl_value_t addrspace(10)* addrspacecast (%jl_value_t* inttoptr (i64 139954134778592 to %jl_value_t*) to %jl_value_t addrspace(10)*), %jl_value_t addrspace(10)** %0, i32 1)
  ret void
}
julia> test() = print("Hello World")
test (generic function with 1 method)

julia> @code_llvm test()

;  @ REPL[4]:1 within `test'
define void @julia_test_17031() {
top:
  %0 = alloca %jl_value_t addrspace(10)*
  %1 = getelementptr %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %0, i32 0
  store %jl_value_t addrspace(10)* addrspacecast (%jl_value_t* inttoptr (i64 139954065591888 to %jl_value_t*) to %jl_value_t addrspace(10)*), %jl_value_t addrspace(10)** %1
  %2 = call nonnull %jl_value_t addrspace(10)* @jsys1_print_4315(%jl_value_t addrspace(10)* addrspacecast (%jl_value_t* inttoptr (i64 139954134778592 to %jl_value_t*) to %jl_value_t addrspace(10)*), %jl_value_t addrspace(10)** %0, i32 1)
  ret void
}

You need to give an explicit path to the sysimage when you use the --output option ( -J path/to/sysimage ).

I tired to generate one using the command but it gives the same error.

joseph@joseph-X541UJ:~/Documents/Julia$ julia --output-ji test.jl 
ERROR: could not open file boot.jl
joseph@joseph-X541UJ:~/Documents/Julia$ julia --output-ji /home/joseph/Documents/Julia/test.jl 
ERROR: could not open file boot.jl

I’ve been meaning to try out StaticCompiler.jl. Probably worth taking a look at.

2 Likes

You have to use the default sysimage, located wherever your julia install is located.

May I ask why you need LLVM bitcode? Julia code is not interpreted by default (though using a REPL makes it seem that way). Rather, your code is compiled to native code at first run and executed afterwards.

What? None of those commands gave a path to the sysimage using -J.

Hi,

Sorry for reviving this topic, but I couldn’t find an answer anywhere.
I’m trying to do the same thing, and tried running:

./julia --output-bc out.bc -Jpath-to-julia/julia/usr/lib/julia/sys.ji ../../in.jl

I’m getting:

ERROR: LoadError: ArgumentError: Package Distributed not found in current path:
- Run `import Pkg; Pkg.add("Distributed")` to install the Distributed package.

The error makes some sense since I have using Distributed in the file in.jl.

PS: After some googling I found that this could be related to the environment variable $JULIA_LOAD_PATH. I’ve tried setting it to path-to-julia/julia/usr/share/julia/stdlib/vx.x, but no still got the same error.