@@ -93,8 +93,72 @@ function source_path(ctx, pkg)
9393end
9494
9595const _STDLIBS = readdir (Sys. STDLIB)
96- sysimage_modules () = map (x-> x. name, Base. _sysimage_modules)
97- stdlibs_in_sysimage () = intersect (_STDLIBS, sysimage_modules ())
96+
97+ # Hardcoded list of stdlibs in the default sysimage for each Julia version
98+ function default_sysimage_stdlibs ()
99+ if VERSION < v " 1.11"
100+ # Julia 1.10
101+ return [
102+ Base. PkgId (Base. UUID (" 29816b5a-b9ab-546f-933c-edad1886dfa8" ), " LibSSH2_jll" ),
103+ Base. PkgId (Base. UUID (" 4536629a-c528-5b80-bd46-f80d51c5b363" ), " OpenBLAS_jll" ),
104+ Base. PkgId (Base. UUID (" 8e850ede-7688-5339-a07c-302acd2aaf8d" ), " nghttp2_jll" ),
105+ Base. PkgId (Base. UUID (" 9e88b42a-f829-5b0c-bbe9-9e923198166b" ), " Serialization" ),
106+ Base. PkgId (Base. UUID (" e37daf67-58a4-590a-8e99-b0245dd2ffc5" ), " LibGit2_jll" ),
107+ Base. PkgId (Base. UUID (" 8f399da3-3557-5675-b5ff-fb832c97cbdb" ), " Libdl" ),
108+ Base. PkgId (Base. UUID (" ea8e919c-243c-51af-8825-aaa63cd721ce" ), " SHA" ),
109+ Base. PkgId (Base. UUID (" f43a241f-c20a-4ad4-852c-f6b1247861c6" ), " Downloads" ),
110+ Base. PkgId (Base. UUID (" 44cfe95a-1eb2-52ea-b672-e2afdf69b78f" ), " Pkg" ),
111+ Base. PkgId (Base. UUID (" 7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" ), " FileWatching" ),
112+ Base. PkgId (Base. UUID (" 56f22d72-fd6d-98f1-02f0-08ddc0907c33" ), " Artifacts" ),
113+ Base. PkgId (Base. UUID (" 2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" ), " Base64" ),
114+ Base. PkgId (Base. UUID (" ade2ca70-3891-5945-98fb-dc099432e06a" ), " Dates" ),
115+ Base. PkgId (Base. UUID (" b77e0a4c-d291-57a0-90e8-8db25a27a240" ), " InteractiveUtils" ),
116+ Base. PkgId (Base. UUID (" 8e850b90-86db-534c-a0d3-1478176c7d93" ), " libblastrampoline_jll" ),
117+ Base. PkgId (Base. UUID (" d6f4376e-aef5-505a-96c1-9c027394607a" ), " Markdown" ),
118+ Base. PkgId (Base. UUID (" 3f19e933-33d8-53b3-aaab-bd5110c3b7a0" ), " p7zip_jll" ),
119+ Base. PkgId (Base. UUID (" 4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" ), " Unicode" ),
120+ Base. PkgId (Base. UUID (" cf7118a7-6976-5b1a-9a39-7adc72f591a4" ), " UUIDs" ),
121+ Base. PkgId (Base. UUID (" 14a3606d-f60d-562e-9121-12d972cd8159" ), " MozillaCACerts_jll" ),
122+ Base. PkgId (Base. UUID (" deac9b47-8bc7-5906-a0fe-35ac56dc84c0" ), " LibCURL_jll" ),
123+ Base. PkgId (Base. UUID (" fa267f1f-6049-4f14-aa54-33bafae1ed76" ), " TOML" ),
124+ Base. PkgId (Base. UUID (" 8bf52ea8-c179-5cab-976a-9e18b702a9bc" ), " CRC32c" ),
125+ Base. PkgId (Base. UUID (" 56ddb016-857b-54e1-b83d-db4d58db5568" ), " Logging" ),
126+ Base. PkgId (Base. UUID (" 3fa0cd96-eef1-5676-8a61-b3b8758bbffb" ), " REPL" ),
127+ Base. PkgId (Base. UUID (" c8ffd9c3-330d-5841-b78e-0817d7145fa1" ), " MbedTLS_jll" ),
128+ Base. PkgId (Base. UUID (" b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" ), " LibCURL" ),
129+ Base. PkgId (Base. UUID (" ca575930-c2e3-43a9-ace4-1e988b2c1908" ), " NetworkOptions" ),
130+ Base. PkgId (Base. UUID (" a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" ), " Tar" ),
131+ Base. PkgId (Base. UUID (" 76f85450-5226-5b5a-8eaa-529ad045b433" ), " LibGit2" ),
132+ Base. PkgId (Base. UUID (" a63ad114-7e13-5084-954f-fe012c677804" ), " Mmap" ),
133+ Base. PkgId (Base. UUID (" 37e2e46d-f89d-539d-b4ee-838fcccc9c8e" ), " LinearAlgebra" ),
134+ Base. PkgId (Base. UUID (" 9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ), " Random" ),
135+ Base. PkgId (Base. UUID (" 6462fe0b-24de-5631-8697-dd941f90decc" ), " Sockets" ),
136+ Base. PkgId (Base. UUID (" 9fa8497b-333b-5362-9e8d-4d0656e87820" ), " Future" ),
137+ Base. PkgId (Base. UUID (" de0858da-6303-5e67-8744-51eddeeeb8d7" ), " Printf" ),
138+ Base. PkgId (Base. UUID (" 0dad84c5-d112-42e6-8d28-ef12dabb789f" ), " ArgTools" ),
139+ ]
140+ else
141+ # Julia 1.11, 1.12, 1.13+
142+ stdlibs = [
143+ Base. PkgId (Base. UUID (" 4536629a-c528-5b80-bd46-f80d51c5b363" ), " OpenBLAS_jll" ),
144+ Base. PkgId (Base. UUID (" 8f399da3-3557-5675-b5ff-fb832c97cbdb" ), " Libdl" ),
145+ Base. PkgId (Base. UUID (" ea8e919c-243c-51af-8825-aaa63cd721ce" ), " SHA" ),
146+ Base. PkgId (Base. UUID (" 7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" ), " FileWatching" ),
147+ Base. PkgId (Base. UUID (" 56f22d72-fd6d-98f1-02f0-08ddc0907c33" ), " Artifacts" ),
148+ Base. PkgId (Base. UUID (" 8e850b90-86db-534c-a0d3-1478176c7d93" ), " libblastrampoline_jll" ),
149+ Base. PkgId (Base. UUID (" 37e2e46d-f89d-539d-b4ee-838fcccc9c8e" ), " LinearAlgebra" ),
150+ Base. PkgId (Base. UUID (" 9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ), " Random" ),
151+ Base. PkgId (Base. UUID (" 6462fe0b-24de-5631-8697-dd941f90decc" ), " Sockets" ),
152+ ]
153+ # Julia 1.13+ adds CompilerSupportLibraries_jll as a transitive dependency of OpenBLAS_jll
154+ if VERSION >= v " 1.13-"
155+ push! (stdlibs, Base. PkgId (Base. UUID (" e66e0078-7015-5450-92f7-15fbd957f2ae" ), " CompilerSupportLibraries_jll" ))
156+ end
157+ return stdlibs
158+ end
159+ end
160+
161+ stdlibs_in_default_sysimage () = default_sysimage_stdlibs ()
98162
99163# TODO : Also check UUIDs for stdlibs, not only names<
100164function gather_stdlibs_project (ctx)
@@ -207,16 +271,15 @@ function get_julia_cmd()
207271end
208272
209273
210- function rewrite_sysimg_jl_only_needed_stdlibs (stdlibs :: Vector{String} )
274+ function rewrite_sysimg_jl_only_needed_stdlibs ()
211275 sysimg_source_path = Base. find_source_file (" sysimg.jl" )
212276 sysimg_content = read (sysimg_source_path, String)
213- # replaces the hardcoded list of stdlibs in sysimg.jl with
214- # the stdlibs that is given as argument
215- return replace (sysimg_content,
216- r" stdlibs = \[ (.*?)\] " s => string (" stdlibs = [" , join (" :" .* stdlibs, " ,\n " ), " ]" ))
277+ # replaces the hardcoded list of stdlibs in sysimg.jl with an empty list
278+ # TODO : Use the mechanism in https://github.com/JuliaLang/PackageCompiler.jl/pull/997
279+ return replace (sysimg_content, r" stdlibs = \[ (.*?)\] " s => " stdlibs = []" )
217280end
218281
219- function create_fresh_base_sysimage (stdlibs :: Vector{String} ; cpu_target:: String , sysimage_build_args:: Cmd )
282+ function create_fresh_base_sysimage (; cpu_target:: String , sysimage_build_args:: Cmd )
220283 tmp = mktempdir ()
221284 sysimg_source_path = Base. find_source_file (" sysimg.jl" )
222285 base_dir = dirname (sysimg_source_path)
@@ -267,16 +330,15 @@ function create_fresh_base_sysimage(stdlibs::Vector{String}; cpu_target::String,
267330 spinner = TerminalSpinners. Spinner (msg = " PackageCompiler: compiling fresh sysimage (incremental=false)" )
268331 TerminalSpinners. @spin spinner begin
269332 # Use the compiler sysimage to create sys.ji
270- new_sysimage_content = rewrite_sysimg_jl_only_needed_stdlibs (stdlibs )
333+ new_sysimage_content = rewrite_sysimg_jl_only_needed_stdlibs ()
271334 new_sysimage_content *= " \n empty!(Base.atexit_hooks)\n "
272335 new_sysimage_source_path = joinpath (tmp, " sysimage_packagecompiler_$(uuid1 ()) .jl" )
273336 write (new_sysimage_source_path, new_sysimage_content)
274337 try
275338 cmd = addenv (` $(get_julia_cmd ()) --cpu-target $cpu_target
276339 --sysimage=$tmp_corecompiler_sl
277340 $sysimage_build_args --output-o=$tmp_sys_o
278- $new_sysimage_source_path $compiler_args ` ,
279- " JULIA_LOAD_PATH" => " @stdlib" )
341+ $new_sysimage_source_path $compiler_args ` )
280342 @debug " running $cmd "
281343
282344 read (cmd)
@@ -595,8 +657,7 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
595657 if base_sysimage != = nothing
596658 error (" cannot specify `base_sysimage` when `incremental=false`" )
597659 end
598- sysimage_stdlibs = filter_stdlibs ? String[] : stdlibs_in_sysimage ()
599- base_sysimage = create_fresh_base_sysimage (sysimage_stdlibs; cpu_target, sysimage_build_args)
660+ base_sysimage = create_fresh_base_sysimage (; cpu_target, sysimage_build_args)
600661 else
601662 base_sysimage = something (base_sysimage, unsafe_string (Base. JLOptions (). image_file))
602663 end
@@ -643,6 +704,11 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
643704 end
644705 end
645706
707+ # Add stdlibs to packages_sysimg when building from fresh base sysimage
708+ if ! incremental && ! filter_stdlibs
709+ union! (packages_sysimg, stdlibs_in_default_sysimage ())
710+ end
711+
646712 # Create the sysimage
647713 object_file = tempname () * " -o.a"
648714 # This naming convention (`-o.a`) is necessary to make the sysimage
@@ -872,7 +938,7 @@ function create_app(package_dir::String,
872938 try_rm_dir (app_dir; force)
873939 stdlibs = gather_stdlibs_project (ctx)
874940 if ! filter_stdlibs
875- stdlibs = unique (vcat (stdlibs, stdlibs_in_sysimage ( )))
941+ stdlibs = unique (vcat (stdlibs, map (pkg -> pkg . name, stdlibs_in_default_sysimage () )))
876942 end
877943 bundle_julia_libraries (app_dir, stdlibs)
878944 bundle_julia_libexec (ctx, app_dir)
@@ -1089,7 +1155,7 @@ function create_library(package_or_project::String,
10891155 mkpath (dest_dir)
10901156 stdlibs = gather_stdlibs_project (ctx)
10911157 if ! filter_stdlibs
1092- stdlibs = unique (vcat (stdlibs, stdlibs_in_sysimage ( )))
1158+ stdlibs = unique (vcat (stdlibs, map (pkg -> pkg . name, stdlibs_in_default_sysimage () )))
10931159 end
10941160 bundle_julia_libraries (dest_dir, stdlibs)
10951161 bundle_julia_libexec (ctx, dest_dir)
0 commit comments