PackageCompiler: Setting the number of threads

Is it possible to set the number of Julia threads when building an executable using PackageCompiler?

module Hello
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
    println(Threads.nthreads())
    return 0
end
end

If I compile the above code using PackageCompiler,

using PackageCompiler
build_executable("hello.jl")

then I get

hello.exe
1

Does this mean, as is suggested, that only a single thread is available to the program? I’ve tried using the cc_flags option, but I’ve had no luck.

1 Like

How about setting the environment variable JULIA_NUM_THREADS=4 before starting the executable?

2 Likes

Wow, yeah, that works. Thank you, can’t believe I didn’t think of it.