diff --git a/src/JET.jl b/src/JET.jl index dc48807fb..ace47cafe 100644 --- a/src/JET.jl +++ b/src/JET.jl @@ -92,7 +92,7 @@ using LoweredCodeUtils: using JuliaInterpreter: @lookup, _INACTIVE_EXCEPTION, bypass_builtins, collect_args, #=finish!,=# - is_quotenode_egal, is_return, maybe_evaluate_builtin, moduleof + is_quotenode_egal, maybe_evaluate_builtin, moduleof using MacroTools: @capture, MacroTools, normalise, striplines @@ -1259,6 +1259,22 @@ using PrecompileTools result = @report_opt rand(String) show(IOContext(devnull, :color=>true), result) end + @static VERSION ≥ v"1.11.0-DEV.1255" && let + # register an initialization callback that fixes up `max_world` which is overridden + # to `one(UInt) == WORLD_AGE_REVALIDATION_SENTINEL` by staticdata.c + # otherwise using cached analysis results would result in world age assertion error + function override_precompiled_cache() + for precache in (JET_ANALYZER_CACHE, OPT_ANALYZER_CACHE), + (_, cache) in precache, + (mi, codeinst) in cache.cache + if codeinst.max_world == one(UInt) # == WORLD_AGE_REVALIDATION_SENTINEL + codeinst.max_world = typemax(UInt) + end + end + end + override_precompiled_cache() # to precompile this callback itself + push_inithook!(override_precompiled_cache) + end end end # module JET diff --git a/src/analyzers/jetanalyzer.jl b/src/analyzers/jetanalyzer.jl index db6a17c37..38c1f9d4c 100644 --- a/src/analyzers/jetanalyzer.jl +++ b/src/analyzers/jetanalyzer.jl @@ -64,7 +64,7 @@ struct JETAnalyzer{RP<:ReportPass} <: AbstractAnalyzer end function JETAnalyzer(state::AnalyzerState, report_pass::ReportPass, config::JETAnalyzerConfig) - if (@ccall jl_generating_output()::Cint) != 0 + if ((@static VERSION < v"1.11.0-DEV.1255" && true) && !iszero(@ccall jl_generating_output()::Cint)) # XXX Avoid storing analysis results into a cache that persists across the # precompilation, as pkgimage currently doesn't support serializing # externally created `CodeInstance`. Otherwise, `CodeInstance`s created by diff --git a/src/analyzers/optanalyzer.jl b/src/analyzers/optanalyzer.jl index ddd94c301..91d9ca396 100644 --- a/src/analyzers/optanalyzer.jl +++ b/src/analyzers/optanalyzer.jl @@ -181,7 +181,7 @@ struct OptAnalyzer{RP<:ReportPass,FF} <: AbstractAnalyzer function_filter::FF, skip_noncompileable_calls::Bool, skip_unoptimized_throw_blocks::Bool) where {RP<:ReportPass,FF} - if (@ccall jl_generating_output()::Cint) != 0 + if ((@static VERSION < v"1.11.0-DEV.1255" && true) && !iszero(@ccall jl_generating_output()::Cint)) # XXX Avoid storing analysis results into a cache that persists across the # precompilation, as pkgimage currently doesn't support serializing # externally created `CodeInstance`. Otherwise, `CodeInstance`s created by