Skip to content

Audit sysimage for relocatability #698

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/PackageCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@
compat_level::String="major",
extra_precompiles::String = "",
import_into_main::Bool=true,
audit_relocatability::Bool = true
)
# We call this at the very beginning to make sure that the user has a compiler available. Therefore, if no compiler
# is found, we throw an error immediately, instead of making the user wait a while before the error is thrown.
Expand Down Expand Up @@ -697,6 +698,13 @@
end
end

if audit_relocatability
@info "Auditing sysimage relocatability"
if audit_sysimage_relocatability(sysimage_path)
@info "No issues found"
end
end

return nothing
end

Expand Down Expand Up @@ -1599,6 +1607,25 @@
return
end

function audit_sysimage_relocatability(sysimg_path::String; paths::Vector{String} = [homedir(), DEPOT_PATH...])

none_found = true
sysimg_contents = open(io -> String(read(io)), sysimg_path, read=true)

for path in paths
found = String[]
for m in eachmatch(Regex("\\Q$(path)\\E[^\0]+"), sysimg_contents)
push!(found, "[$(m.offset)] $(m.match)")
end

Check warning on line 1619 in src/PackageCompiler.jl

View check run for this annotation

Codecov / codecov/patch

src/PackageCompiler.jl#L1619

Added line #L1619 was not covered by tests
if !isempty(found)
@warn """absolute path `$path` found in $(length(found)) places:\n$(join(found, "\n"))"""
none_found = false
end
end

Check warning on line 1624 in src/PackageCompiler.jl

View check run for this annotation

Codecov / codecov/patch

src/PackageCompiler.jl#L1624

Added line #L1624 was not covered by tests

return none_found
end

function bundle_cert(dest_dir)
cert_path = joinpath(Sys.BINDIR, "..", "share", "julia", "cert.pem")
share_path = joinpath(dest_dir, "share", "julia")
Expand Down
3 changes: 3 additions & 0 deletions test/precompile_execution.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using Example

Example.domath(5)

# intentionally put an abspath in to test the relocatability audit
test_abspath = homedir()
Loading