@@ -220,7 +220,8 @@ function rewrite_sysimg_jl_only_needed_stdlibs(stdlibs::Vector{String})
220
220
r" stdlibs = \[ (.*?)\] " s => string (" stdlibs = [" , join (" :" .* stdlibs, " ,\n " ), " ]" ))
221
221
end
222
222
223
- function create_fresh_base_sysimage (stdlibs:: Vector{String} ; cpu_target:: String , sysimage_build_args:: Cmd )
223
+ function create_fresh_base_sysimage (stdlibs:: Vector{String} ; cpu_target:: String ,
224
+ sysimage_build_args:: Cmd , sysimage_build_prefix:: Cmd )
224
225
tmp = mktempdir ()
225
226
sysimg_source_path = Base. find_source_file (" sysimg.jl" )
226
227
base_dir = dirname (sysimg_source_path)
@@ -238,7 +239,7 @@ function create_fresh_base_sysimage(stdlibs::Vector{String}; cpu_target::String,
238
239
TerminalSpinners. @spin spinner begin
239
240
cd (base_dir) do
240
241
# Create corecompiler.ji
241
- cmd = ` $(get_julia_cmd ()) --cpu-target $cpu_target
242
+ cmd = ` $sysimage_build_prefix $ (get_julia_cmd ()) --cpu-target $cpu_target
242
243
--output-ji $tmp_corecompiler_ji $sysimage_build_args
243
244
$compiler_source_path `
244
245
@debug " running $cmd "
@@ -251,7 +252,7 @@ function create_fresh_base_sysimage(stdlibs::Vector{String}; cpu_target::String,
251
252
new_sysimage_source_path = joinpath (tmp, " sysimage_packagecompiler_$(uuid1 ()) .jl" )
252
253
write (new_sysimage_source_path, new_sysimage_content)
253
254
try
254
- cmd = ` $(get_julia_cmd ()) --cpu-target $cpu_target
255
+ cmd = ` $sysimage_build_prefix $ (get_julia_cmd ()) --cpu-target $cpu_target
255
256
--sysimage=$tmp_corecompiler_ji
256
257
$sysimage_build_args --output-ji=$tmp_sys_ji
257
258
$new_sysimage_source_path `
@@ -303,6 +304,7 @@ function create_sysimg_object_file(object_file::String,
303
304
cpu_target:: String ,
304
305
script:: Union{Nothing, String} ,
305
306
sysimage_build_args:: Cmd ,
307
+ sysimage_build_prefix:: Cmd ,
306
308
extra_precompiles:: String ,
307
309
incremental:: Bool )
308
310
julia_code_buffer = IOBuffer ()
@@ -429,7 +431,7 @@ function create_sysimg_object_file(object_file::String,
429
431
write (outputo_file, julia_code)
430
432
# Read the input via stdin to avoid hitting the maximum command line limit
431
433
432
- cmd = ` $(get_julia_cmd ()) --cpu-target=$cpu_target $sysimage_build_args
434
+ cmd = ` $sysimage_build_prefix $ (get_julia_cmd ()) --cpu-target=$cpu_target $sysimage_build_args
433
435
--sysimage=$base_sysimage --project=$project --output-o=$(object_file)
434
436
$outputo_file `
435
437
@debug " running $cmd "
@@ -487,6 +489,9 @@ compiler (can also include extra arguments to the compiler, like `-g`).
487
489
488
490
- `sysimage_build_args::Cmd`: A set of command line options that is used in the Julia process building the sysimage,
489
491
for example `-O1 --check-bounds=yes`.
492
+
493
+ - `sysimage_build_prefix::Cmd`: A set of commands and command line options that will be
494
+ prefixed to the call to Julia for building the sysimage, for example `srun -n 1`.
490
495
"""
491
496
function create_sysimage (packages:: Union{Nothing, Symbol, Vector{String}, Vector{Symbol}} = nothing ;
492
497
sysimage_path:: String ,
@@ -498,6 +503,7 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
498
503
cpu_target:: String = NATIVE_CPU_TARGET,
499
504
script:: Union{Nothing, String} = nothing ,
500
505
sysimage_build_args:: Cmd = ` ` ,
506
+ sysimage_build_prefix:: Cmd = ` ` ,
501
507
include_transitive_dependencies:: Bool = true ,
502
508
# Internal args
503
509
base_sysimage:: Union{Nothing, String} = nothing ,
@@ -545,7 +551,8 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
545
551
error (" cannot specify `base_sysimage` when `incremental=false`" )
546
552
end
547
553
sysimage_stdlibs = filter_stdlibs ? gather_stdlibs_project (ctx) : stdlibs_in_sysimage ()
548
- base_sysimage = create_fresh_base_sysimage (sysimage_stdlibs; cpu_target, sysimage_build_args)
554
+ base_sysimage = create_fresh_base_sysimage (sysimage_stdlibs; cpu_target,
555
+ sysimage_build_args, sysimage_build_prefix)
549
556
else
550
557
base_sysimage = something (base_sysimage, unsafe_string (Base. JLOptions (). image_file))
551
558
end
@@ -603,6 +610,7 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
603
610
cpu_target,
604
611
script,
605
612
sysimage_build_args,
613
+ sysimage_build_prefix,
606
614
extra_precompiles,
607
615
incremental)
608
616
object_files = [object_file]
@@ -788,6 +796,9 @@ compiler (can also include extra arguments to the compiler, like `-g`).
788
796
- `sysimage_build_args::Cmd`: A set of command line options that is used in the Julia process building the sysimage,
789
797
for example `-O1 --check-bounds=yes`.
790
798
799
+ - `sysimage_build_prefix::Cmd`: A set of commands and command line options that will be
800
+ prefixed to the call to Julia for building the sysimage, for example `srun -n 1`.
801
+
791
802
- `script::String`: Path to a file that gets executed in the `--output-o` process.
792
803
"""
793
804
function create_app (package_dir:: String ,
@@ -802,6 +813,7 @@ function create_app(package_dir::String,
802
813
cpu_target:: String = default_app_cpu_target (),
803
814
include_lazy_artifacts:: Bool = false ,
804
815
sysimage_build_args:: Cmd = ` ` ,
816
+ sysimage_build_prefix:: Cmd = ` ` ,
805
817
include_transitive_dependencies:: Bool = true ,
806
818
include_preferences:: Bool = true ,
807
819
script:: Union{Nothing, String} = nothing )
@@ -851,6 +863,7 @@ function create_app(package_dir::String,
851
863
precompile_statements_file,
852
864
cpu_target,
853
865
sysimage_build_args,
866
+ sysimage_build_prefix,
854
867
include_transitive_dependencies,
855
868
extra_precompiles = join (precompiles, " \n " ),
856
869
script)
@@ -986,6 +999,9 @@ compiler (can also include extra arguments to the compiler, like `-g`).
986
999
987
1000
- `sysimage_build_args::Cmd`: A set of command line options that is used in the Julia process building the sysimage,
988
1001
for example `-O1 --check-bounds=yes`.
1002
+
1003
+ - `sysimage_build_prefix::Cmd`: A set of commands and command line options that will be
1004
+ prefixed to the call to Julia for building the sysimage, for example `srun -n 1`.
989
1005
"""
990
1006
function create_library (package_or_project:: String ,
991
1007
dest_dir:: String ;
@@ -1003,6 +1019,7 @@ function create_library(package_or_project::String,
1003
1019
cpu_target:: String = default_app_cpu_target (),
1004
1020
include_lazy_artifacts:: Bool = false ,
1005
1021
sysimage_build_args:: Cmd = ` ` ,
1022
+ sysimage_build_prefix:: Cmd = ` ` ,
1006
1023
include_transitive_dependencies:: Bool = true ,
1007
1024
include_preferences:: Bool = true ,
1008
1025
script:: Union{Nothing,String} = nothing
@@ -1053,7 +1070,8 @@ function create_library(package_or_project::String,
1053
1070
1054
1071
create_sysimage_workaround (ctx, sysimg_path, precompile_execution_file,
1055
1072
precompile_statements_file, incremental, filter_stdlibs, cpu_target;
1056
- sysimage_build_args, include_transitive_dependencies, julia_init_c_file,
1073
+ sysimage_build_args, sysimage_build_prefix,
1074
+ include_transitive_dependencies, julia_init_c_file,
1057
1075
julia_init_h_file, version, soname, script)
1058
1076
1059
1077
if version != = nothing && Sys. isunix ()
@@ -1113,6 +1131,7 @@ function create_sysimage_workaround(
1113
1131
filter_stdlibs:: Bool ,
1114
1132
cpu_target:: String ;
1115
1133
sysimage_build_args:: Cmd ,
1134
+ sysimage_build_prefix:: Cmd ,
1116
1135
include_transitive_dependencies:: Bool ,
1117
1136
julia_init_c_file:: Union{Nothing,String,Vector{String}} ,
1118
1137
julia_init_h_file:: Union{Nothing,String,Vector{String}} ,
@@ -1151,6 +1170,7 @@ function create_sysimage_workaround(
1151
1170
version,
1152
1171
soname,
1153
1172
sysimage_build_args,
1173
+ sysimage_build_prefix,
1154
1174
include_transitive_dependencies)
1155
1175
1156
1176
return
0 commit comments