diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl index 6fa7a565..89b0f565 100644 --- a/src/PackageCompiler.jl +++ b/src/PackageCompiler.jl @@ -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") @@ -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 @@ -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") diff --git a/src/juliaconfig.jl b/src/juliaconfig.jl index 66eb1673..4673b1ff 100644 --- a/src/juliaconfig.jl +++ b/src/juliaconfig.jl @@ -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