Skip to content

Commit bf3afcd

Browse files
authored
Fix and test special loading support for Compiler (JuliaLang#56535)
The new `Compiler` package has a special stub that bypasses compilig a separate copy if you have `dev`'ed the version that's already compiled into the sysimg. It wasn't quite working properly in the final version of that PR if a compiler so loaded was a dependency of another precompiled package. Fix that and add a test to make sure it doesn't regress.
1 parent 2e91004 commit bf3afcd

File tree

9 files changed

+54
-3
lines changed

9 files changed

+54
-3
lines changed

src/Compiler.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
# the system image and simply returns that copy of the compiler. If not,
77
# we proceed to load/precompile this as an ordinary package.
88
if isdefined(Base, :generating_output) && Base.generating_output(true) &&
9-
Base.samefile(Base._compiler_require_dependencies[1][2], @eval @__FILE__) &&
9+
Base.samefile(joinpath(Sys.BINDIR, Base.DATAROOTDIR, Base._compiler_require_dependencies[1][2]), @eval @__FILE__) &&
1010
!Base.any_includes_stale(
11-
map(Base.CacheHeaderIncludes, Base._compiler_require_dependencies),
11+
map(Base.compiler_chi, Base._compiler_require_dependencies),
1212
"sysimg", nothing)
1313

1414
Base.prepare_compiler_stub_image!()
15-
append!(Base._require_dependencies, Base._compiler_require_dependencies)
15+
append!(Base._require_dependencies, map(Base.expand_compiler_path, Base._compiler_require_dependencies))
1616
# There isn't much point in precompiling native code - downstream users will
1717
# specialize their own versions of the compiler code and we don't activate
1818
# the compiler by default anyway, so let's save ourselves some disk space.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file is machine-generated - editing it directly is not advised
2+
3+
julia_version = "1.12.0-DEV"
4+
manifest_format = "2.0"
5+
project_hash = "10c2816629fed766649b89eb6670e7001df6ea18"
6+
7+
[[deps.Compiler]]
8+
path = "../.."
9+
uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
10+
version = "0.0.1"
11+
12+
[[deps.CompilerLoadingTest]]
13+
deps = ["Compiler"]
14+
path = "."
15+
uuid = "95defb8a-f82d-44d7-b2c9-37d658f648c1"
16+
version = "0.0.0"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name = "CompilerLoadingTest"
2+
uuid = "95defb8a-f82d-44d7-b2c9-37d658f648c1"
3+
4+
[deps]
5+
Compiler = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
using Test, UUIDs
4+
5+
# This file is loaded as part of special_loading.jl
6+
Base.compilecache(Base.PkgId(UUID(0x95defb8a_f82d_44d7_b2c9_37d658f648c1), "CompilerLoadingTest"))
7+
8+
using CompilerLoadingTest
9+
@test Base.maybe_loaded_precompile(Base.PkgId(UUID(0x807dbc54_b67e_4c79_8afb_eafe4df6f2e1), "Compiler"), Base.module_build_id(Base.Compiler)) !== nothing
10+
11+
using Compiler
12+
@test CompilerLoadingTest.Compiler === Compiler === Base.Compiler
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
module CompilerLoadingTest
4+
using Compiler
5+
end

test/irutils.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
13
using Core.IR
24
using Core.Compiler: IRCode, IncrementalCompact, singleton_type, VarState
35
using Base.Meta: isexpr

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
using Test, Compiler
33

44
for file in readlines(joinpath(@__DIR__, "testgroups"))
5+
file == "special_loading" && continue # Only applicable to Base.Compiler
56
include(file * ".jl")
67
end

test/special_loading.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
mktempdir() do dir
4+
withenv("JULIA_DEPOT_PATH" => dir * (Sys.iswindows() ? ";" : ":"), "JULIA_LOAD_PATH" => nothing) do
5+
cd(joinpath(@__DIR__, "CompilerLoadingTest")) do
6+
@test success(pipeline(`$(Base.julia_cmd()[1]) --startup-file=no --project=. compiler_loading_test.jl`; stdout, stderr))
7+
end
8+
end
9+
end

test/testgroups

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ newinterp
1414
ssair
1515
tarjan
1616
validation
17+
special_loading

0 commit comments

Comments
 (0)