-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Make precompile files relocatable #49866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
64fc754
replace depot path with @depot in .ji files
fatteneder 95dbbf7
add unit test
fatteneder 8ecb714
write src file size and hash to .ji and use that for is_stale check w…
fatteneder f65a305
refactor depot path helpers
fatteneder 0269244
disable mtime check for stale_cachefile
fatteneder 2724541
fix depot helpers
fatteneder 259efcd
evict mtime from precompile files
fatteneder 081f467
only forward depot aliases to precompilers
fatteneder 80b1204
rework depot path logic so that relocation only works when caches and
fatteneder 9bd0c22
gitignore relocatedepot test artifacts
fatteneder a51dbd6
rework depot path resolution logic, take 2
fatteneder 0aabc29
address review comments
fatteneder 0efd622
clean up
fatteneder 6ab1ef3
only consider srctext files when resolving depot path
fatteneder 01989ba
add RelocationTestPkg for unit tests
fatteneder 3047c27
include_dependency should also track filesize of directories and syml…
fatteneder 5bf5813
refine debug logs when parsing cache header
fatteneder 1d45155
fixup stale cache file debug log
fatteneder 39cc034
throw when we can't find a depot
fatteneder edcc5d1
track mtime only for include_dependency
fatteneder 4e705a7
update docs
fatteneder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
/ccalltest | ||
/ccalltest.s | ||
/libccalltest.* | ||
/relocatedepot | ||
/RelocationTestPkg2/src/foo.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name = "RelocationTestPkg1" | ||
uuid = "854e1adb-5a97-46bf-a391-1cfe05ac726d" | ||
authors = ["flo "] | ||
version = "0.1.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module RelocationTestPkg1 | ||
|
||
greet() = print("Hello World!") | ||
|
||
end # module RelocationTestPkg1 |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name = "RelocationTestPkg2" | ||
uuid = "8d933983-b090-4b0b-a37e-c34793f459d1" | ||
authors = ["flo "] | ||
version = "0.1.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module RelocationTestPkg2 | ||
|
||
include_dependency("foo.txt") | ||
greet() = print("Hello World!") | ||
|
||
end # module RelocationTestPkg2 |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using Test | ||
using Logging | ||
|
||
|
||
include("testenv.jl") | ||
|
||
|
||
function test_harness(@nospecialize(fn)) | ||
load_path = copy(LOAD_PATH) | ||
depot_path = copy(DEPOT_PATH) | ||
try | ||
fn() | ||
finally | ||
copy!(LOAD_PATH, load_path) | ||
copy!(DEPOT_PATH, depot_path) | ||
end | ||
end | ||
|
||
|
||
if !test_relocated_depot | ||
|
||
@testset "precompile RelocationTestPkg1" begin | ||
pkgname = "RelocationTestPkg1" | ||
test_harness() do | ||
push!(LOAD_PATH, @__DIR__) | ||
push!(DEPOT_PATH, @__DIR__) | ||
pkg = Base.identify_package(pkgname) | ||
cachefiles = Base.find_all_in_cache_path(pkg) | ||
rm.(cachefiles, force=true) | ||
@test Base.isprecompiled(pkg) == false | ||
Base.require(pkg) # precompile | ||
@test Base.isprecompiled(pkg, ignore_loaded=true) == true | ||
end | ||
end | ||
|
||
@testset "precompile RelocationTestPkg2 (contains include_dependency)" begin | ||
pkgname = "RelocationTestPkg2" | ||
test_harness() do | ||
push!(LOAD_PATH, @__DIR__) | ||
push!(DEPOT_PATH, @__DIR__) | ||
pkg = Base.identify_package(pkgname) | ||
cachefiles = Base.find_all_in_cache_path(pkg) | ||
rm.(cachefiles, force=true) | ||
@test Base.isprecompiled(pkg) == false | ||
touch(joinpath(@__DIR__, pkgname, "src", "foo.txt")) | ||
Base.require(pkg) # precompile | ||
@info "SERS OIDA" | ||
@test Base.isprecompiled(pkg, ignore_loaded=true) == true | ||
end | ||
end | ||
|
||
else | ||
|
||
# must come before any of the load tests, because the will recompile and generate new cache files | ||
@testset "attempt loading precompiled pkgs when depot is missing" begin | ||
test_harness() do | ||
empty!(LOAD_PATH) | ||
push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) | ||
for pkgname in ("RelocationTestPkg1", "RelocationTestPkg2") | ||
pkg = Base.identify_package(pkgname) | ||
cachefile = only(Base.find_all_in_cache_path(pkg)) | ||
@info cachefile | ||
@test_throws ArgumentError(""" | ||
Failed to determine depot from srctext files in cache file $cachefile. | ||
- Make sure you have adjusted DEPOT_PATH in case you relocated depots.""") Base.isprecompiled(pkg) | ||
end | ||
end | ||
end | ||
|
||
@testset "load stdlib from test/relocatedepot" begin | ||
test_harness() do | ||
push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) | ||
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) | ||
# stdlib should be already precompiled | ||
pkg = Base.identify_package("DelimitedFiles") | ||
@test Base.isprecompiled(pkg) == true | ||
end | ||
end | ||
|
||
@testset "load RelocationTestPkg1 from test/relocatedepot" begin | ||
pkgname = "RelocationTestPkg1" | ||
test_harness() do | ||
push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) | ||
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) | ||
pkg = Base.identify_package(pkgname) | ||
@test Base.isprecompiled(pkg) == true | ||
Base.require(pkg) # re-precompile | ||
@test Base.isprecompiled(pkg) == true | ||
end | ||
end | ||
|
||
@testset "load RelocationTestPkg2 (contains include_dependency) from test/relocatedepot" begin | ||
pkgname = "RelocationTestPkg2" | ||
test_harness() do | ||
push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) | ||
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) | ||
pkg = Base.identify_package(pkgname) | ||
@test Base.isprecompiled(pkg) == false # moving depot changes mtime of include_dependency | ||
Base.require(pkg) # re-precompile | ||
@test Base.isprecompiled(pkg) == true | ||
end | ||
end | ||
|
||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.