Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
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 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
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 @@ function bundle_headers(dest_dir, header_files)
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
if !isempty(found)
@warn """absolute path `$path` found in $(length(found)) places:\n$(join(found, "\n"))"""
none_found = false
end
end

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