Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow the Compiler.jl stdlib to be installed on older version of Julia #56553

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Compiler/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "Compiler"
uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
version = "0.0.1"
version = "0.0.2"
19 changes: 16 additions & 3 deletions Compiler/src/Compiler.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

if isdefined(Base, :end_base_include) && !isdefined(Base, :Compiler)

# Define a dummy `Compiler` module to make it installable even on Julia versions where
# Compiler.jl is not available as a standard library.
@eval module Compiler
function __init__()
println("""
The `Compiler` standard library is not available for this version of Julia.
Use Julia version `v"1.12.0-DEV.1581"` or later.
""")
end
end

# When generating an incremental precompile file, we first check whether we
# already have a copy of this *exact* code in the system image. If so, we
# simply generates a pkgimage that has the dependency edges we recorded in
# the system image and simply returns that copy of the compiler. If not,
# we proceed to load/precompile this as an ordinary package.
if isdefined(Base, :generating_output) && Base.generating_output(true) &&
elseif (isdefined(Base, :generating_output) && Base.generating_output(true) &&
Base.samefile(joinpath(Sys.BINDIR, Base.DATAROOTDIR, Base._compiler_require_dependencies[1][2]), @eval @__FILE__) &&
!Base.any_includes_stale(
map(Base.compiler_chi, Base._compiler_require_dependencies),
"sysimg", nothing)
"sysimg", nothing))

Base.prepare_compiler_stub_image!()
append!(Base._require_dependencies, map(Base.expand_compiler_path, Base._compiler_require_dependencies))
Expand Down Expand Up @@ -167,7 +180,7 @@ include("optimize.jl")
include("bootstrap.jl")
include("reflection_interface.jl")

if isdefined(Base, :IRShow)
if isdefined(Base, :end_base_include)
aviatesk marked this conversation as resolved.
Show resolved Hide resolved
@eval module IRShow
using ..Compiler: Compiler
# During bootstrap, Base will later include this into its own "IRShow module"
Expand Down
9 changes: 9 additions & 0 deletions Compiler/src/ssair/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1135,3 +1135,12 @@ function Base.show(io::IO, tinf::Timings.Timing)
end

@specialize

const __debuginfo = Dict{Symbol, Any}(
# :full => src -> statementidx_lineinfo_printer(src), # and add variable slot information
:source => src -> statementidx_lineinfo_printer(src),
# :oneliner => src -> statementidx_lineinfo_printer(PartialLineInfoPrinter, src),
:none => src -> lineinfo_disabled,
)
const default_debuginfo = Ref{Symbol}(:none)
debuginfo(sym) = sym === :default ? default_debuginfo[] : sym
9 changes: 0 additions & 9 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2824,15 +2824,6 @@ end
module IRShow
using ..Compiler: Compiler
Base.include(IRShow, Base.strcat(Base.BUILDROOT, "../usr/share/julia/Compiler/src/ssair/show.jl"))

const __debuginfo = Dict{Symbol, Any}(
# :full => src -> statementidx_lineinfo_printer(src), # and add variable slot information
:source => src -> statementidx_lineinfo_printer(src),
# :oneliner => src -> statementidx_lineinfo_printer(PartialLineInfoPrinter, src),
:none => src -> lineinfo_disabled,
)
const default_debuginfo = Ref{Symbol}(:none)
debuginfo(sym) = sym === :default ? default_debuginfo[] : sym
end

function show(io::IO, src::CodeInfo; debuginfo::Symbol=:source)
Expand Down