diff --git a/Project.toml b/Project.toml index cc34d3de..d361bae9 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ version = "1.2.2" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl index 1d78c437..b2cfabb2 100644 --- a/src/PackageCompiler.jl +++ b/src/PackageCompiler.jl @@ -4,6 +4,7 @@ using Base: active_project using Libdl: Libdl using Pkg: Pkg using UUIDs: UUID, uuid1 +using Logging export create_sysimage, create_app, audit_app, restore_default_sysimage @@ -212,6 +213,12 @@ function create_sysimg_object_file(object_file::String, packages::Vector{String} precompile_code = """ # This @eval prevents symbols from being put into Main @eval Module() begin + + using Logging + # Pass through the user's logging level to the spawned process. + logger = ConsoleLogger(stderr, Logging.$(Logging.min_enabled_level(global_logger()))) + global_logger(logger) + PrecompileStagingArea = Module() for (_pkgid, _mod) in Base.loaded_modules if !(_pkgid.name in ("Main", "Core", "Base")) @@ -226,10 +233,13 @@ function create_sysimg_object_file(object_file::String, packages::Vector{String} # N with a large number seems to work around it. statement = replace(statement, r"Vararg{(.*?), N} where N" => s"Vararg{\1, 100}") try - Base.include_string(PrecompileStagingArea, statement) - catch + success = Base.include_string(PrecompileStagingArea, statement) + if !success + @debug "Precompilation failed: \$statement" + end + catch e # See julia issue #28808 - @debug "failed to execute \$statement" + @debug "Error executing \$statement:\n\$e" end end end # module