@@ -278,11 +278,12 @@ function ensurecompiled(project, packages, sysimage)
278
278
return
279
279
end
280
280
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 )
282
283
tracefile, io = mktemp (precompile_dir; cleanup= false )
283
284
close (io)
284
285
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 `
286
287
# --project is not propagated well with Distributed, so use environment
287
288
splitter = Sys. iswindows () ? ' ;' : ' :'
288
289
@debug " run_precompilation_script: running $cmd " JULIA_LOAD_PATH = " $project$(splitter) @stdlib"
@@ -299,6 +300,7 @@ function create_sysimg_object_file(object_file::String,
299
300
project:: String ,
300
301
base_sysimage:: String ,
301
302
precompile_execution_file:: Vector{String} ,
303
+ precompile_execution_prefix:: Cmd ,
302
304
precompile_statements_file:: Vector{String} ,
303
305
cpu_target:: String ,
304
306
script:: Union{Nothing, String} ,
@@ -326,7 +328,8 @@ function create_sysimg_object_file(object_file::String,
326
328
@debug " running precompilation execution script..."
327
329
precompile_dir = mktempdir (; prefix= " jl_packagecompiler_" , cleanup= false )
328
330
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)
330
333
push! (precompile_files, tracefile)
331
334
end
332
335
append! (precompile_files, abspath .(precompile_statements_file))
@@ -487,11 +490,16 @@ compiler (can also include extra arguments to the compiler, like `-g`).
487
490
488
491
- `sysimage_build_args::Cmd`: A set of command line options that is used in the Julia process building the sysimage,
489
492
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`.
490
497
"""
491
498
function create_sysimage (packages:: Union{Nothing, Symbol, Vector{String}, Vector{Symbol}} = nothing ;
492
499
sysimage_path:: String ,
493
500
project:: String = dirname (active_project ()),
494
501
precompile_execution_file:: Union{String, Vector{String}} = String[],
502
+ precompile_execution_prefix:: Cmd = ` ` ,
495
503
precompile_statements_file:: Union{String, Vector{String}} = String[],
496
504
incremental:: Bool = true ,
497
505
filter_stdlibs:: Bool = false ,
@@ -599,6 +607,7 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
599
607
project,
600
608
base_sysimage,
601
609
precompile_execution_file,
610
+ precompile_execution_prefix,
602
611
precompile_statements_file,
603
612
cpu_target,
604
613
script,
@@ -789,11 +798,16 @@ compiler (can also include extra arguments to the compiler, like `-g`).
789
798
for example `-O1 --check-bounds=yes`.
790
799
791
800
- `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`.
792
805
"""
793
806
function create_app (package_dir:: String ,
794
807
app_dir:: String ;
795
808
executables:: Union{Nothing, Vector{Pair{String, String}}} = nothing ,
796
809
precompile_execution_file:: Union{String, Vector{String}} = String[],
810
+ precompile_execution_prefix:: Cmd = ` ` ,
797
811
precompile_statements_file:: Union{String, Vector{String}} = String[],
798
812
incremental:: Bool = false ,
799
813
filter_stdlibs:: Bool = false ,
@@ -848,6 +862,7 @@ function create_app(package_dir::String,
848
862
incremental,
849
863
filter_stdlibs,
850
864
precompile_execution_file,
865
+ precompile_execution_prefix,
851
866
precompile_statements_file,
852
867
cpu_target,
853
868
sysimage_build_args,
@@ -986,11 +1001,16 @@ compiler (can also include extra arguments to the compiler, like `-g`).
986
1001
987
1002
- `sysimage_build_args::Cmd`: A set of command line options that is used in the Julia process building the sysimage,
988
1003
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`.
989
1008
"""
990
1009
function create_library (package_or_project:: String ,
991
1010
dest_dir:: String ;
992
1011
lib_name= nothing ,
993
1012
precompile_execution_file:: Union{String, Vector{String}} = String[],
1013
+ precompile_execution_prefix:: Cmd = ` ` ,
994
1014
precompile_statements_file:: Union{String, Vector{String}} = String[],
995
1015
incremental:: Bool = false ,
996
1016
filter_stdlibs:: Bool = false ,
@@ -1051,7 +1071,7 @@ function create_library(package_or_project::String,
1051
1071
compat_file = get_library_filename (lib_name; version, compat_level)
1052
1072
soname = (Sys. isunix () && ! Sys. isapple ()) ? compat_file : nothing
1053
1073
1054
- create_sysimage_workaround (ctx, sysimg_path, precompile_execution_file,
1074
+ create_sysimage_workaround (ctx, sysimg_path, precompile_execution_file, precompile_execution_prefix,
1055
1075
precompile_statements_file, incremental, filter_stdlibs, cpu_target;
1056
1076
sysimage_build_args, include_transitive_dependencies, julia_init_c_file,
1057
1077
julia_init_h_file, version, soname, script)
@@ -1108,6 +1128,7 @@ function create_sysimage_workaround(
1108
1128
ctx,
1109
1129
sysimage_path:: String ,
1110
1130
precompile_execution_file:: Union{String, Vector{String}} ,
1131
+ precompile_execution_prefix:: Cmd ,
1111
1132
precompile_statements_file:: Union{String, Vector{String}} ,
1112
1133
incremental:: Bool ,
1113
1134
filter_stdlibs:: Bool ,
@@ -1143,6 +1164,7 @@ function create_sysimage_workaround(
1143
1164
incremental= true ,
1144
1165
script= script,
1145
1166
precompile_execution_file,
1167
+ precompile_execution_prefix,
1146
1168
precompile_statements_file,
1147
1169
cpu_target,
1148
1170
base_sysimage,
0 commit comments