Skip to content
Merged
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
15 changes: 11 additions & 4 deletions src/PackageCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ function create_fresh_base_sysimage(; cpu_target::String, sysimage_build_args::C
@static if VERSION >= v"1.12.0-DEV.1617"
compiler_source_path = joinpath(base_dir, "Base_compiler.jl")
buildroot = ""
dataroot = relpath(joinpath(Sys.BINDIR, Base.DATAROOTDIR), base_dir) * "/"
# Use realpath to handle symlinked directories (common in local Julia builds)
dataroot = relpath(realpath(joinpath(Sys.BINDIR, Base.DATAROOTDIR)), realpath(base_dir)) * "/"
compiler_args = `--buildroot $buildroot --dataroot $dataroot` # build path
else
compiler_source_path = joinpath(base_dir, "compiler", "compiler.jl")
Expand Down Expand Up @@ -948,6 +949,7 @@ function create_app(package_dir::String,
include_preferences && bundle_preferences(ctx, app_dir)
bundle_cert(app_dir)

# Sysimage always goes in lib/julia/ (this is hardcoded in the Julia binary)
sysimage_path = joinpath(app_dir, "lib", "julia", "sys." * Libdl.dlext)

package_name = ctx.env.pkg.name
Expand Down Expand Up @@ -1367,13 +1369,18 @@ function bundle_julia_libraries(dest_dir, stdlibs)
app_libjulia_dir = Sys.isunix() ? joinpath(app_lib_dir, "julia") : app_lib_dir
lib_dir = julia_libdir()
libjulia_dir = Sys.isunix() ? joinpath(lib_dir, "julia") : lib_dir
# File structure is slightly different on locally built julias:
if !isempty(glob(glob_pattern_lib("libLLVM"), lib_dir))
# File structure is different on locally built julias:
# libraries are in lib/ directly instead of lib/julia/, and the DEP_LIBS
# embedded in libjulia.so reflect this. We must copy libraries to the same
# relative location to match the binary's expectations.
if is_local_julia_build()
libjulia_dir = lib_dir
app_libjulia_dir = app_lib_dir
end

mkpath(app_lib_dir)
Sys.isunix() && mkpath(app_libjulia_dir)
# Always create lib/julia/ for the sysimage (even for local builds where libraries go to lib/)
Sys.isunix() && mkpath(joinpath(app_lib_dir, "julia"))

tot_libsize = 0
printstyled("PackageCompiler: bundled libraries:\n")
Expand Down
7 changes: 7 additions & 0 deletions src/juliaconfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ function julia_libdir()
return dirname(abspath(Libdl.dlpath(libname)))
end

# Detect if Julia is a local build (libraries in lib/ directly instead of lib/julia/)
function is_local_julia_build()
lib_dir = julia_libdir()
# In local builds, libLLVM is directly in lib/, not in lib/julia/
return any(startswith(f, "libLLVM") for f in readdir(lib_dir))
end

function julia_private_libdir()
if Base.DARWIN_FRAMEWORK # taken from Libdl tests
if isdebugbuild() != 0
Expand Down
Loading