194194function get_julia_cmd ()
195195 julia_path = joinpath (Sys. BINDIR, Base. julia_exename ())
196196 color = Base. have_color === nothing ? " auto" : Base. have_color ? " yes" : " no"
197- return ` $julia_path --color=$color --startup-file=no`
197+ if isdefined (Base, :Linking ) # pkgimage support feature flag
198+ ` $julia_path --color=$color --startup-file=no --pkgimages=no`
199+ else
200+ ` $julia_path --color=$color --startup-file=no`
201+ end
198202end
199203
200204
@@ -219,9 +223,16 @@ function create_fresh_base_sysimage(stdlibs::Vector{String}; cpu_target::String)
219223 TerminalSpinners. @spin spinner begin
220224 cd (base_dir) do
221225 # Create corecompiler.ji
222- cmd = ` $(get_julia_cmd ()) --cpu-target $cpu_target --output-ji $tmp_corecompiler_ji
223- -g0 -O0 $compiler_source_path `
224- @debug " running $cmd "
226+ cmd = if isdefined (Base, :Linking ) # pkgimages feature flag
227+ cmd = ` $(get_julia_cmd ()) --output-ji $tmp_corecompiler_ji -g0 -O0 $compiler_source_path `
228+ @debug " running $cmd " JULIA_CPU_TARGET = cpu_target
229+ addenv (cmd, " JULIA_CPU_TARGET" => cpu_target)
230+ else
231+ cmd = ` $(get_julia_cmd ()) --cpu-target $cpu_target --output-ji $tmp_corecompiler_ji
232+ -g0 -O0 $compiler_source_path `
233+ @debug " running $cmd "
234+ cmd
235+ end
225236 read (cmd)
226237
227238 # Use that to create sys.ji
@@ -230,10 +241,18 @@ function create_fresh_base_sysimage(stdlibs::Vector{String}; cpu_target::String)
230241 new_sysimage_source_path = joinpath (tmp, " sysimage_packagecompiler_$(uuid1 ()) .jl" )
231242 write (new_sysimage_source_path, new_sysimage_content)
232243 try
233- cmd = ` $(get_julia_cmd ()) --cpu-target $cpu_target
244+ cmd = if isdefined (Base, :Linking ) # pkgimages feature flag
245+ cmd = ` $(get_julia_cmd ()) --sysimage=$tmp_corecompiler_ji
246+ -g1 -O0 --output-ji=$tmp_sys_ji $new_sysimage_source_path `
247+ @debug " running $cmd " JULIA_CPU_TARGET = cpu_target
248+ addenv (cmd, " JULIA_CPU_TARGET" => cpu_target)
249+ else
250+ cmd = ` $(get_julia_cmd ()) --cpu-target $cpu_target
234251 --sysimage=$tmp_corecompiler_ji
235252 -g1 -O0 --output-ji=$tmp_sys_ji $new_sysimage_source_path `
236- @debug " running $cmd "
253+ @debug " running $cmd "
254+ cmd
255+ end
237256 read (cmd)
238257 finally
239258 rm (new_sysimage_source_path; force= true )
@@ -249,6 +268,7 @@ function ensurecompiled(project, packages, sysimage)
249268 # TODO : Only precompile `packages` (should be available in Pkg 1.8)
250269 cmd = ` $(get_julia_cmd ()) --sysimage=$sysimage -e 'using Pkg; Pkg.precompile()'`
251270 splitter = Sys. iswindows () ? ' ;' : ' :'
271+ @debug " ensurecompiled: running $cmd " JULIA_LOAD_PATH = " $project$(splitter) @stdlib"
252272 cmd = addenv (cmd, " JULIA_LOAD_PATH" => " $project$(splitter) @stdlib" )
253273 run (cmd)
254274 return
@@ -261,6 +281,7 @@ function run_precompilation_script(project::String, sysimg::String, precompile_f
261281 cmd = ` $(get_julia_cmd ()) --sysimage=$(sysimg) --compile=all --trace-compile=$tracefile $arg `
262282 # --project is not propagated well with Distributed, so use environment
263283 splitter = Sys. iswindows () ? ' ;' : ' :'
284+ @debug " run_precompilation_script: running $cmd " JULIA_LOAD_PATH = " $project$(splitter) @stdlib"
264285 cmd = addenv (cmd, " JULIA_LOAD_PATH" => " $project$(splitter) @stdlib" )
265286 precompile_file === nothing || @info " PackageCompiler: Executing $(abspath (precompile_file)) => $(tracefile) "
266287 run (cmd) # `Run` this command so that we'll display stdout from the user's script.
@@ -378,9 +399,17 @@ function create_sysimg_object_file(object_file::String,
378399 write (outputo_file, julia_code)
379400 # Read the input via stdin to avoid hitting the maximum command line limit
380401
381- cmd = ` $(get_julia_cmd ()) --cpu-target=$cpu_target -O3 $sysimage_build_args
382- --sysimage=$base_sysimage --project=$project --output-o=$(object_file) $outputo_file `
383- @debug " running $cmd "
402+ cmd = if isdefined (Base, :Linking ) # pkgimages feature flag
403+ cmd = ` $(get_julia_cmd ()) -O3 $sysimage_build_args
404+ --sysimage=$base_sysimage --project=$project --output-o=$(object_file) $outputo_file `
405+ @debug " running $cmd " JULIA_CPU_TARGET = cpu_target
406+ addenv (cmd, " JULIA_CPU_TARGET" => cpu_target)
407+ else
408+ cmd = ` $(get_julia_cmd ()) --cpu-target=$cpu_target -O3 $sysimage_build_args
409+ --sysimage=$base_sysimage --project=$project --output-o=$(object_file) $outputo_file `
410+ @debug " running $cmd "
411+ cmd
412+ end
384413 non = incremental ? " " : " non"
385414 spinner = TerminalSpinners. Spinner (msg = " PackageCompiler: compiling $(non) incremental system image" )
386415 @monitor_oom TerminalSpinners. @spin spinner run (cmd)
@@ -560,6 +589,7 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
560589 cd (dirname (abspath (sysimage_path))) do
561590 sysimage_file = basename (sysimage_path)
562591 cmd = ` install_name_tool -id @rpath/$(sysimage_file) $sysimage_file `
592+ @debug " running $cmd "
563593 run (cmd)
564594 end
565595 end
0 commit comments