@@ -296,7 +296,8 @@ function create_fresh_base_sysimage(; cpu_target::String, sysimage_build_args::C
296296 @static if VERSION >= v " 1.12.0-DEV.1617"
297297 compiler_source_path = joinpath (base_dir, " Base_compiler.jl" )
298298 buildroot = " "
299- dataroot = relpath (joinpath (Sys. BINDIR, Base. DATAROOTDIR), base_dir) * " /"
299+ # Use realpath to handle symlinked directories (common in local Julia builds)
300+ dataroot = relpath (realpath (joinpath (Sys. BINDIR, Base. DATAROOTDIR)), realpath (base_dir)) * " /"
300301 compiler_args = ` --buildroot $buildroot --dataroot $dataroot ` # build path
301302 else
302303 compiler_source_path = joinpath (base_dir, " compiler" , " compiler.jl" )
@@ -948,6 +949,7 @@ function create_app(package_dir::String,
948949 include_preferences && bundle_preferences (ctx, app_dir)
949950 bundle_cert (app_dir)
950951
952+ # Sysimage always goes in lib/julia/ (this is hardcoded in the Julia binary)
951953 sysimage_path = joinpath (app_dir, " lib" , " julia" , " sys." * Libdl. dlext)
952954
953955 package_name = ctx. env. pkg. name
@@ -1367,13 +1369,18 @@ function bundle_julia_libraries(dest_dir, stdlibs)
13671369 app_libjulia_dir = Sys. isunix () ? joinpath (app_lib_dir, " julia" ) : app_lib_dir
13681370 lib_dir = julia_libdir ()
13691371 libjulia_dir = Sys. isunix () ? joinpath (lib_dir, " julia" ) : lib_dir
1370- # File structure is slightly different on locally built julias:
1371- if ! isempty (glob (glob_pattern_lib (" libLLVM" ), lib_dir))
1372+ # File structure is different on locally built julias:
1373+ # libraries are in lib/ directly instead of lib/julia/, and the DEP_LIBS
1374+ # embedded in libjulia.so reflect this. We must copy libraries to the same
1375+ # relative location to match the binary's expectations.
1376+ if is_local_julia_build ()
13721377 libjulia_dir = lib_dir
1378+ app_libjulia_dir = app_lib_dir
13731379 end
13741380
13751381 mkpath (app_lib_dir)
1376- Sys. isunix () && mkpath (app_libjulia_dir)
1382+ # Always create lib/julia/ for the sysimage (even for local builds where libraries go to lib/)
1383+ Sys. isunix () && mkpath (joinpath (app_lib_dir, " julia" ))
13771384
13781385 tot_libsize = 0
13791386 printstyled (" PackageCompiler: bundled libraries:\n " )
0 commit comments