From 9032926c0641e2a62fbe4ebc91ee81d763db7308 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Tue, 20 Jun 2023 10:05:58 -0700 Subject: [PATCH] Throw precompilation error if dependency load failure during incremental precompilation In rare cases, if we fail to load a dependency during precompilation, we can fall-through to the "load locally" fallthrough in `_require()`. However, if this happens during incremental precompilation, this ends up emitting `.ji` files that have multiple modules embedded within, which can cause massive precompilation issues further down the chain, as dependencies which try to load our `.ji` file themselves get corrupted. This catches the error at the source, refusing to generate such a `.ji` file in the first place. --- base/loading.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/loading.jl b/base/loading.jl index ae0681608844e..56c40af68479f 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1919,7 +1919,7 @@ function _require(pkg::PkgId, env=nothing) else @warn "The call to compilecache failed to create a usable precompiled cache file for $pkg" exception=m end - # fall-through to loading the file locally + # fall-through to loading the file locally if not incremental else cachefile, ocachefile = cachefile::Tuple{String, Union{Nothing, String}} m = _tryrequire_from_serialized(pkg, cachefile, ocachefile) @@ -1929,6 +1929,10 @@ function _require(pkg::PkgId, env=nothing) return m end end + if JLOptions().incremental != 0 + # during incremental precompilation, this should be fail-fast + throw(PrecompilableError()) + end end end