@@ -1524,7 +1524,21 @@ function CacheFlags(f::UInt8)
1524
1524
CacheFlags (use_pkgimages, debug_level, check_bounds, inline, opt_level)
1525
1525
end
1526
1526
CacheFlags (f:: Int ) = CacheFlags (UInt8 (f))
1527
- CacheFlags () = CacheFlags (ccall (:jl_cache_flags , UInt8, ()))
1527
+ function CacheFlags (cf:: CacheFlags = CacheFlags (ccall (:jl_cache_flags , UInt8, ()));
1528
+ use_pkgimages:: Union{Nothing,Bool} = nothing ,
1529
+ debug_level:: Union{Nothing,Int} = nothing ,
1530
+ check_bounds:: Union{Nothing,Int} = nothing ,
1531
+ inline:: Union{Nothing,Bool} = nothing ,
1532
+ opt_level:: Union{Nothing,Int} = nothing
1533
+ )
1534
+ return CacheFlags (
1535
+ use_pkgimages === nothing ? cf. use_pkgimages : use_pkgimages,
1536
+ debug_level === nothing ? cf. debug_level : debug_level,
1537
+ check_bounds === nothing ? cf. check_bounds : check_bounds,
1538
+ inline === nothing ? cf. inline : inline,
1539
+ opt_level === nothing ? cf. opt_level : opt_level
1540
+ )
1541
+ end
1528
1542
1529
1543
function _cacheflag_to_uint8 (cf:: CacheFlags ):: UInt8
1530
1544
f = UInt8 (0 )
@@ -2768,7 +2782,7 @@ function compilecache_dir(pkg::PkgId)
2768
2782
return joinpath (DEPOT_PATH [1 ], entrypath)
2769
2783
end
2770
2784
2771
- function compilecache_path (pkg:: PkgId , prefs_hash:: UInt64 ; project:: String = something (Base. active_project (), " " )):: String
2785
+ function compilecache_path (pkg:: PkgId , prefs_hash:: UInt64 ; flags :: CacheFlags = CacheFlags (), project:: String = something (Base. active_project (), " " )):: String
2772
2786
entrypath, entryfile = cache_file_entry (pkg)
2773
2787
cachepath = joinpath (DEPOT_PATH [1 ], entrypath)
2774
2788
isdir (cachepath) || mkpath (cachepath)
@@ -2778,7 +2792,7 @@ function compilecache_path(pkg::PkgId, prefs_hash::UInt64; project::String=somet
2778
2792
crc = _crc32c (project)
2779
2793
crc = _crc32c (unsafe_string (JLOptions (). image_file), crc)
2780
2794
crc = _crc32c (unsafe_string (JLOptions (). julia_bin), crc)
2781
- crc = _crc32c (ccall ( :jl_cache_flags , UInt8, () ), crc)
2795
+ crc = _crc32c (_cacheflag_to_uint8 (flags ), crc)
2782
2796
2783
2797
cpu_target = get (ENV , " JULIA_CPU_TARGET" , nothing )
2784
2798
if cpu_target === nothing
@@ -2810,7 +2824,8 @@ end
2810
2824
const MAX_NUM_PRECOMPILE_FILES = Ref (10 )
2811
2825
2812
2826
function compilecache (pkg:: PkgId , path:: String , internal_stderr:: IO = stderr , internal_stdout:: IO = stdout ,
2813
- keep_loaded_modules:: Bool = true ; flags:: Cmd = ` ` , reasons:: Union{Dict{String,Int},Nothing} = Dict {String,Int} ())
2827
+ keep_loaded_modules:: Bool = true ; flags:: Cmd = ` ` , cacheflags:: CacheFlags = CacheFlags (),
2828
+ reasons:: Union{Dict{String,Int},Nothing} = Dict {String,Int} ())
2814
2829
2815
2830
@nospecialize internal_stderr internal_stdout
2816
2831
# decide where to put the resulting cache file
@@ -2859,7 +2874,7 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
2859
2874
# Read preferences hash back from .ji file (we can't precompute because
2860
2875
# we don't actually know what the list of compile-time preferences are without compiling)
2861
2876
prefs_hash = preferences_hash (tmppath)
2862
- cachefile = compilecache_path (pkg, prefs_hash)
2877
+ cachefile = compilecache_path (pkg, prefs_hash; flags = cacheflags )
2863
2878
ocachefile = cache_objects ? ocachefile_from_cachefile (cachefile) : nothing
2864
2879
2865
2880
# append checksum for so to the end of the .ji file:
@@ -3408,7 +3423,7 @@ global parse_pidfile_hook
3408
3423
# The preferences hash is only known after precompilation so just assume no preferences.
3409
3424
# Also ignore the active project, which means that if all other conditions are equal,
3410
3425
# the same package cannot be precompiled from different projects and/or different preferences at the same time.
3411
- compilecache_pidfile_path (pkg:: PkgId ) = compilecache_path (pkg, UInt64 (0 ); project= " " ) * " .pidfile"
3426
+ compilecache_pidfile_path (pkg:: PkgId ; flags :: CacheFlags = CacheFlags ()) = compilecache_path (pkg, UInt64 (0 ); project= " " , flags ) * " .pidfile"
3412
3427
3413
3428
const compilecache_pidlock_stale_age = 10
3414
3429
@@ -3536,12 +3551,16 @@ end
3536
3551
M = root_module (req_key)
3537
3552
if PkgId (M) == req_key && module_build_id (M) === req_build_id
3538
3553
depmods[i] = M
3554
+ elseif M == Core
3555
+ @debug " Rejecting cache file $cachefile because it was made with a different julia version"
3556
+ record_reason (reasons, " wrong julia version" )
3557
+ return true # Won't be able to fulfill dependency
3539
3558
elseif ignore_loaded || ! stalecheck
3540
3559
# Used by Pkg.precompile given that there it's ok to precompile different versions of loaded packages
3541
3560
@goto locate_branch
3542
3561
else
3543
3562
@debug " Rejecting cache file $cachefile because module $req_key is already loaded and incompatible."
3544
- record_reason (reasons, req_key == PkgId (Core) ? " wrong julia version " : " wrong dep version loaded" )
3563
+ record_reason (reasons, " wrong dep version loaded" )
3545
3564
return true # Won't be able to fulfill dependency
3546
3565
end
3547
3566
else
0 commit comments