@@ -278,11 +278,12 @@ function ensurecompiled(project, packages, sysimage)
278278 return
279279end
280280
281- function run_precompilation_script (project:: String , sysimg:: String , precompile_file:: Union{String, Nothing} , precompile_dir:: String )
281+ function run_precompilation_script (project:: String , sysimg:: String , precompile_prefix:: Cmd ,
282+ precompile_file:: Union{String, Nothing} , precompile_dir:: String )
282283 tracefile, io = mktemp (precompile_dir; cleanup= false )
283284 close (io)
284285 arg = precompile_file === nothing ? ` -e ''` : ` $precompile_file `
285- cmd = ` $(get_julia_cmd ()) --sysimage=$(sysimg) --compile=all --trace-compile=$tracefile $arg `
286+ cmd = ` $precompile_prefix $ (get_julia_cmd ()) --sysimage=$(sysimg) --compile=all --trace-compile=$tracefile $arg `
286287 # --project is not propagated well with Distributed, so use environment
287288 splitter = Sys. iswindows () ? ' ;' : ' :'
288289 @debug " run_precompilation_script: running $cmd " JULIA_LOAD_PATH = " $project$(splitter) @stdlib"
@@ -299,6 +300,7 @@ function create_sysimg_object_file(object_file::String,
299300 project:: String ,
300301 base_sysimage:: String ,
301302 precompile_execution_file:: Vector{String} ,
303+ precompile_execution_prefix:: Cmd ,
302304 precompile_statements_file:: Vector{String} ,
303305 cpu_target:: String ,
304306 script:: Union{Nothing, String} ,
@@ -326,7 +328,8 @@ function create_sysimg_object_file(object_file::String,
326328 @debug " running precompilation execution script..."
327329 precompile_dir = mktempdir (; prefix= " jl_packagecompiler_" , cleanup= false )
328330 for file in (isempty (precompile_execution_file) ? (nothing ,) : precompile_execution_file)
329- tracefile = run_precompilation_script (project, base_sysimage, file, precompile_dir)
331+ tracefile = run_precompilation_script (project, base_sysimage, precompile_execution_prefix,
332+ file, precompile_dir)
330333 push! (precompile_files, tracefile)
331334 end
332335 append! (precompile_files, abspath .(precompile_statements_file))
@@ -487,11 +490,16 @@ compiler (can also include extra arguments to the compiler, like `-g`).
487490
488491- `sysimage_build_args::Cmd`: A set of command line options that is used in the Julia process building the sysimage,
489492 for example `-O1 --check-bounds=yes`.
493+
494+ - `precompile_execution_prefix::Cmd`: A set of commands and command line options that will be
495+ prefixed to the call to Julia when executing files specified by `precompile_execution_file`,
496+ for example `srun`.
490497"""
491498function create_sysimage (packages:: Union{Nothing, Symbol, Vector{String}, Vector{Symbol}} = nothing ;
492499 sysimage_path:: String ,
493500 project:: String = dirname (active_project ()),
494501 precompile_execution_file:: Union{String, Vector{String}} = String[],
502+ precompile_execution_prefix:: Cmd = ` ` ,
495503 precompile_statements_file:: Union{String, Vector{String}} = String[],
496504 incremental:: Bool = true ,
497505 filter_stdlibs:: Bool = false ,
@@ -599,6 +607,7 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
599607 project,
600608 base_sysimage,
601609 precompile_execution_file,
610+ precompile_execution_prefix,
602611 precompile_statements_file,
603612 cpu_target,
604613 script,
@@ -789,11 +798,16 @@ compiler (can also include extra arguments to the compiler, like `-g`).
789798 for example `-O1 --check-bounds=yes`.
790799
791800- `script::String`: Path to a file that gets executed in the `--output-o` process.
801+
802+ - `precompile_execution_prefix::Cmd`: A set of commands and command line options that will be
803+ prefixed to the call to Julia when executing files specified by `precompile_execution_file`,
804+ for example `srun`.
792805"""
793806function create_app (package_dir:: String ,
794807 app_dir:: String ;
795808 executables:: Union{Nothing, Vector{Pair{String, String}}} = nothing ,
796809 precompile_execution_file:: Union{String, Vector{String}} = String[],
810+ precompile_execution_prefix:: Cmd = ` ` ,
797811 precompile_statements_file:: Union{String, Vector{String}} = String[],
798812 incremental:: Bool = false ,
799813 filter_stdlibs:: Bool = false ,
@@ -848,6 +862,7 @@ function create_app(package_dir::String,
848862 incremental,
849863 filter_stdlibs,
850864 precompile_execution_file,
865+ precompile_execution_prefix,
851866 precompile_statements_file,
852867 cpu_target,
853868 sysimage_build_args,
@@ -986,11 +1001,16 @@ compiler (can also include extra arguments to the compiler, like `-g`).
9861001
9871002- `sysimage_build_args::Cmd`: A set of command line options that is used in the Julia process building the sysimage,
9881003 for example `-O1 --check-bounds=yes`.
1004+
1005+ - `precompile_execution_prefix::Cmd`: A set of commands and command line options that will be
1006+ prefixed to the call to Julia when executing files specified by `precompile_execution_file`,
1007+ for example `srun`.
9891008"""
9901009function create_library (package_or_project:: String ,
9911010 dest_dir:: String ;
9921011 lib_name= nothing ,
9931012 precompile_execution_file:: Union{String, Vector{String}} = String[],
1013+ precompile_execution_prefix:: Cmd = ` ` ,
9941014 precompile_statements_file:: Union{String, Vector{String}} = String[],
9951015 incremental:: Bool = false ,
9961016 filter_stdlibs:: Bool = false ,
@@ -1108,6 +1128,7 @@ function create_sysimage_workaround(
11081128 ctx,
11091129 sysimage_path:: String ,
11101130 precompile_execution_file:: Union{String, Vector{String}} ,
1131+ precompile_execution_prefix:: Cmd ,
11111132 precompile_statements_file:: Union{String, Vector{String}} ,
11121133 incremental:: Bool ,
11131134 filter_stdlibs:: Bool ,
@@ -1143,6 +1164,7 @@ function create_sysimage_workaround(
11431164 incremental= true ,
11441165 script= script,
11451166 precompile_execution_file,
1167+ precompile_execution_prefix,
11461168 precompile_statements_file,
11471169 cpu_target,
11481170 base_sysimage,
0 commit comments