Accelerate compiler start time

I am developing a CLI package CLI.jl, but it seems that the start time of the compiler makes a CLI script slower than a Python script or an executable. (precompile is on)

I tried to use static-julia to compile it to an executable, but I got segment fault…

So I am wondering if there is any other approach to accelerate launch time of such a CLI script?

module tcli

using CLI

"""
build docstring
"""
@fire function build(;help=false)
    println("-- build")

    if help
        return Docs.doc(build)
    end
end

struct Foo
end

function (f::Foo)()
    println("hello")
end

a = Foo()

println(CLI.ENVS["entries"])

@fire a

b = 2
@fire b


Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
    main(ARGS)
    return 0
end

end
1 Like

See the stuff mentioned on PackageCompiler.jl. The README talks about some segfaults with AOT compilation and what to do.

Yes, without AOT compilation command line scripts have quite a bit of startup time. Thanks for taking on this problem since I know a lot of people will be happy to see a solution there.

On OS X at least there’s a bug that makes any executable crash as soon as the GC is triggered, so if you have this there’s not much to do afaik.

@Roger-luo you can test if you are affected by this issue, but also set this variable to global const since that might also cause problems.

Thanks for reply. However, it seems the only solution for AOT compile’s segment faults is to use gdb, according to this README.md… I am wondering if it is possible to generate like C code and link it back to libjulia? Do you if there is anyone who have tried this before?