@@ -918,7 +918,6 @@ function _require(pkg::PkgId)
918
918
try
919
919
toplevel_load[] = false
920
920
# perform the search operation to select the module file require intends to load
921
- name = pkg. name
922
921
path = locate_package (pkg)
923
922
if path === nothing
924
923
throw (ArgumentError ("""
@@ -939,8 +938,8 @@ function _require(pkg::PkgId)
939
938
# but it was not handled by the precompile loader, complain
940
939
for (concrete_pkg, concrete_build_id) in _concrete_dependencies
941
940
if pkg == concrete_pkg
942
- @warn """ Module $name with build ID $concrete_build_id is missing from the cache.
943
- This may mean module $name does not support precompilation but is imported by a module that does."""
941
+ @warn """ Module $(pkg . name) with build ID $concrete_build_id is missing from the cache.
942
+ This may mean $pkg does not support precompilation but is imported by a module that does."""
944
943
if JLOptions (). incremental != 0
945
944
# during incremental precompilation, this should be fail-fast
946
945
throw (PrecompilableError ())
@@ -952,14 +951,19 @@ function _require(pkg::PkgId)
952
951
if (0 == ccall (:jl_generating_output , Cint, ())) || (JLOptions (). incremental != 0 )
953
952
# spawn off a new incremental pre-compile task for recursive `require` calls
954
953
# or if the require search declared it was pre-compiled before (and therefore is expected to still be pre-compilable)
955
- cachefile = compilecache (pkg)
956
- m = _require_from_serialized (cachefile)
957
- if isa (m, Exception)
958
- if ! precompilableerror (m)
959
- @warn " The call to compilecache failed to create a usable precompiled cache file for module $name " exception= m
954
+ cachefile = compilecache (pkg, path)
955
+ if isa (cachefile, Exception)
956
+ if ! precompilableerror (cachefile)
957
+ @warn " The call to compilecache failed to create a usable precompiled cache file for $pkg " exception= m
960
958
end
959
+ # fall-through to loading the file locally
961
960
else
962
- return
961
+ m = _require_from_serialized (cachefile)
962
+ if isa (m, Exception)
963
+ @warn " The call to compilecache failed to create a usable precompiled cache file for $pkg " exception= m
964
+ else
965
+ return
966
+ end
963
967
end
964
968
end
965
969
end
@@ -1108,18 +1112,18 @@ function create_expr_cache(input::String, output::String, concrete_deps::typeof(
1108
1112
in = io. in
1109
1113
try
1110
1114
write (in, """
1111
- begin
1112
- $(Base. load_path_setup_code ())
1113
- Base._track_dependencies[] = true
1114
- empty!(Base._concrete_dependencies)
1115
- """ )
1115
+ begin
1116
+ $(Base. load_path_setup_code ())
1117
+ Base._track_dependencies[] = true
1118
+ Base. empty!(Base._concrete_dependencies)
1119
+ """ )
1116
1120
for (pkg, build_id) in concrete_deps
1117
1121
pkg_str = if pkg. uuid === nothing
1118
1122
" Base.PkgId($(repr (pkg. name)) )"
1119
1123
else
1120
1124
" Base.PkgId(Base.UUID(\" $(pkg. uuid) \" ), $(repr (pkg. name)) )"
1121
1125
end
1122
- write (in, " push!(Base._concrete_dependencies, $pkg_str => $(repr (build_id)) )\n " )
1126
+ write (in, " Base. push!(Base._concrete_dependencies, $pkg_str => $(repr (build_id)) )\n " )
1123
1127
end
1124
1128
write (io, " end\0 " )
1125
1129
uuid_tuple = uuid === nothing ? (0 , 0 ) : convert (NTuple{2 , UInt64}, uuid)
@@ -1128,7 +1132,14 @@ function create_expr_cache(input::String, output::String, concrete_deps::typeof(
1128
1132
if source != = nothing
1129
1133
write (in, " task_local_storage()[:SOURCE_PATH] = $(repr (source)) \0 " )
1130
1134
end
1131
- write (in, " Base.include(Base.__toplevel__, $(repr (abspath (input))) )\0 " )
1135
+ write (in, """
1136
+ try
1137
+ Base.include(Base.__toplevel__, $(repr (abspath (input))) )
1138
+ catch ex
1139
+ Base.precompilableerror(ex) || Base.rethrow(ex)
1140
+ Base.@debug "Aborting `createexprcache'" exception=(Base.ErrorException("Declaration of __precompile__(false) not allowed"), Base.catch_backtrace())
1141
+ Base.exit(125) # we define status = 125 means PrecompileableError
1142
+ end\0 """ )
1132
1143
# TODO : cleanup is probably unnecessary here
1133
1144
if source != = nothing
1134
1145
write (in, " delete!(task_local_storage(), :SOURCE_PATH)\0 " )
@@ -1152,10 +1163,11 @@ This can be used to reduce package load times. Cache files are stored in
1152
1163
for important notes.
1153
1164
"""
1154
1165
function compilecache (pkg:: PkgId )
1155
- # decide where to get the source file from
1156
- name = pkg. name
1157
1166
path = locate_package (pkg)
1158
1167
path === nothing && throw (ArgumentError (" $pkg not found during precompilation" ))
1168
+ return compilecache (pkg, path)
1169
+ end
1170
+ function compilecache (pkg:: PkgId , path:: String )
1159
1171
# decide where to put the resulting cache file
1160
1172
cachefile = abspath (DEPOT_PATH [1 ], cache_file_entry (pkg))
1161
1173
cachepath = dirname (cachefile)
@@ -1170,17 +1182,20 @@ function compilecache(pkg::PkgId)
1170
1182
# run the expression and cache the result
1171
1183
verbosity = isinteractive () ? CoreLogging. Info : CoreLogging. Debug
1172
1184
if isfile (cachefile)
1173
- @logmsg verbosity " Recompiling stale cache file $cachefile for module $name "
1185
+ @logmsg verbosity " Recompiling stale cache file $cachefile for $pkg "
1174
1186
else
1175
- @logmsg verbosity " Precompiling module $name "
1187
+ @logmsg verbosity " Precompiling $pkg "
1176
1188
end
1177
- if success (create_expr_cache (path, cachefile, concrete_deps, pkg. uuid))
1189
+ p = create_expr_cache (path, cachefile, concrete_deps, pkg. uuid)
1190
+ if success (p)
1178
1191
# append checksum to the end of the .ji file:
1179
1192
open (cachefile, " a+" ) do f
1180
1193
write (f, _crc32c (seekstart (f)))
1181
1194
end
1195
+ elseif p. exitcode == 125
1196
+ return PrecompilableError ()
1182
1197
else
1183
- error (" Failed to precompile $name to $cachefile ." )
1198
+ error (" Failed to precompile $pkg to $cachefile ." )
1184
1199
end
1185
1200
return cachefile
1186
1201
end
0 commit comments