Skip to content

Commit 61a6f40

Browse files
Fix 1.9 (#757)
Co-authored-by: Kristoffer Carlsson <[email protected]> Closes #755
1 parent 28cb6cb commit 61a6f40

3 files changed

Lines changed: 61 additions & 14 deletions

File tree

.github/workflows/test.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,28 @@ jobs:
3131
- ubuntu-latest
3232
- macOS-latest
3333
- windows-latest
34+
coverage:
35+
- 'true'
36+
- 'false' # needed for 1.9+ to test from a session using pkgimages
3437
exclude:
3538
- os: macOS-latest
3639
julia-arch: x86
40+
- julia-version: '1.6'
41+
coverage: 'false'
42+
- julia-version: '1.7'
43+
coverage: 'false'
44+
- julia-version: '1.8'
45+
coverage: 'false'
3746
steps:
38-
- uses: actions/checkout@v2
47+
- uses: actions/checkout@v3
3948
- uses: julia-actions/setup-julia@latest
4049
with:
4150
version: ${{ matrix.julia-version }}
51+
- uses: julia-actions/cache@v1
4252
- uses: julia-actions/julia-runtest@latest
53+
with:
54+
coverage: ${{ matrix.coverage }}
4355
- uses: julia-actions/julia-processcoverage@latest
44-
- uses: codecov/codecov-action@v1
56+
- uses: codecov/codecov-action@v3
4557
with:
4658
file: lcov.info

src/PackageCompiler.jl

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ end
194194
function 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
198202
end
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

test/runtests.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ end
6262
filter_stdlibs = (false,)
6363
end
6464
@testset for filter in filter_stdlibs
65+
@info "starting: create_app testset" incremental filter
6566
tmp_app_source_dir = joinpath(tmp, "MyApp")
6667
cp(app_source_dir, tmp_app_source_dir)
68+
try
6769
create_app(tmp_app_source_dir, app_compiled_dir; incremental=incremental, force=true, filter_stdlibs=filter, include_lazy_artifacts=true,
6870
precompile_execution_file=joinpath(app_source_dir, "precompile_app.jl"),
6971
executables=["MyApp" => "julia_main",
@@ -72,11 +74,13 @@ end
7274
"Error" => "erroring",
7375
"Undefined" => "undefined",
7476
])
77+
finally
7578
rm(tmp_app_source_dir; recursive=true)
7679
# Get rid of some local state
77-
rm(joinpath(new_depot, "packages"); recursive=true)
78-
rm(joinpath(new_depot, "compiled"); recursive=true)
79-
rm(joinpath(new_depot, "artifacts"); recursive=true)
80+
rm(joinpath(new_depot, "packages"); recursive=true, force=true)
81+
rm(joinpath(new_depot, "compiled"); recursive=true, force=true)
82+
rm(joinpath(new_depot, "artifacts"); recursive=true, force=true)
83+
end # try
8084
app_path(app_name) = abspath(app_compiled_dir, "bin", app_name * (Sys.iswindows() ? ".exe" : ""))
8185
app_output = read(`$(app_path("MyApp")) I get --args --julia-args --threads=3 --check-bounds=yes -O1`, String)
8286

@@ -138,6 +142,7 @@ end
138142
str = String(take!(io))
139143
@test all(occursin(str), ["UndefVarError:", "undefined", "not defined"])
140144
@test p.exitcode == 1
145+
@info "done: create_app testset" incremental filter
141146
end
142147
end
143148
end # testset

0 commit comments

Comments
 (0)