diff --git a/Compiler/src/Compiler.jl b/Compiler/src/Compiler.jl index d454a4853a228c..92ed42b2881e54 100644 --- a/Compiler/src/Compiler.jl +++ b/Compiler/src/Compiler.jl @@ -1,15 +1,26 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +if !isdefined(Base, :__Compiler_as_stdlib_available__) + +@eval baremodule 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)) diff --git a/base/Base_compiler.jl b/base/Base_compiler.jl index b2633c25eef3f3..741f9deb7ac6d6 100644 --- a/base/Base_compiler.jl +++ b/base/Base_compiler.jl @@ -288,6 +288,14 @@ process_sysimg_args!() function isready end +""" + Base.__Compiler_as_stdlib_available__ + +This is a token for switching the definition of `Compiler` to make it installable even on +Julia versions where Compiler.jl is not available as a standard library. +""" +const __Compiler_as_stdlib_available__ = true + include(strcat(BUILDROOT, "../usr/share/julia/Compiler/src/Compiler.jl")) const _return_type = Compiler.return_type