Skip to content

Commit e223b8a

Browse files
committed
restore DEPOT_PATH etc after precompilation workload ran
1 parent 3cc4fdc commit e223b8a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

base/loading.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,10 +2303,18 @@ function include_package_for_output(pkg::PkgId, input::String, depot_path::Vecto
23032303
catch ex
23042304
precompilableerror(ex) || rethrow()
23052305
@debug "Aborting `create_expr_cache'" exception=(ErrorException("Declaration of __precompile__(false) not allowed"), catch_backtrace())
2306-
exit(125) # we define status = 125 means PrecompileableError
2306+
exit(125) # we define status = 125 means PrecompilableError
23072307
finally
23082308
Core.Compiler.track_newly_inferred.x = false
23092309
end
2310+
2311+
# restore some globals in case they were altered in the precompilation workload
2312+
append!(empty!(Base.DEPOT_PATH), depot_path)
2313+
append!(empty!(Base.DL_LOAD_PATH), dl_load_path)
2314+
append!(empty!(Base.LOAD_PATH), load_path)
2315+
ENV["JULIA_LOAD_PATH"] = join(load_path, Sys.iswindows() ? ';' : ':')
2316+
set_active_project(nothing)
2317+
23102318
end
23112319

23122320
const PRECOMPILE_TRACE_COMPILE = Ref{String}()

doc/src/manual/modules.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ code to help the user avoid other wrong-behavior situations:
578578
2. `global const` statements from local scope after `__init__()` has been started (see issue #12010
579579
for plans to add an error for this)
580580
3. Replacing a module is a runtime error while doing an incremental precompile.
581+
4. Any precompilation workload must restore the global variables `DEPOT_PATH, LOAD_PATH, ENV, Base.active_project()`
582+
to their initial state at the end of execution.
581583

582584
A few other points to be aware of:
583585

0 commit comments

Comments
 (0)