I’m trying to compile an old Julia 0.6 code of mine with PackageCompiler
and I’m running into trouble with the following situation:
module M
type A a end
export A
end
using M
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
a = A(1.0) ## works
path1 = string(@__DIR__, "/file1.jl")
path2 = string(@__DIR__, "/file2.jl")
file1 = open(path1, "w")
write(file1, "type B field::M.A end")
close(file1)
file2 = open(path2, "w")
write(file2, "type B field::A end")
close(file2)
include(path1) ## works
include(path2) ## fails
return 0
end
I can use A
fine in julia_main
if calling it directly. Loading file1.jl
works but not file2.jl
, I get the following error:
fatal: error thrown and no exception handler available.
LoadError(at "/Users/plppplp/.julia/v0.6/PackageCompiler/examples/file2.jl" line 1: UndefVarError(var=:A))
rec_backtrace at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
jl_throw at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
jl_undefined_var_error at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
eval at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
do_call at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
eval at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
eval at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
eval_body at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
jl_toplevel_eval_body at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
jl_parse_eval_all at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
jl_load_ at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/libjulia.dylib (unknown line)
include_from_node1 at /Users/plppplp/.julia/v0.6/PackageCompiler/builddir/module.dylib (unknown line)
jlcall_include_from_node1_1175 at /Users/plppplp/.julia/v0.6/PackageCompiler/builddir/module.dylib (unknown line)
include at /Users/plppplp/.julia/v0.6/PackageCompiler/builddir/module.dylib (unknown line)
julia_main at /Users/plppplp/.julia/v0.6/PackageCompiler/builddir/module.dylib (unknown line)
julia_main at /Users/plppplp/.julia/v0.6/PackageCompiler/builddir/module.dylib (unknown line)
main at /Users/plppplp/.julia/v0.6/PackageCompiler/./builddir/module (unknown line)
In practice module M
is huge and I can’t really afford to specify M.
in front of all variables from module M
in included files. This code worked fine without using PackageCompiler
. Is there any way to make PackageCompiler
understand I’m referring to variables from module M
…?
Many thanks!