21 Star 49 Fork 0

Gitee 极速下载/julia-language

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/JuliaLang/julia
克隆/下载
compileall.jl 1.93 KB
一键复制 编辑 原始数据 按行查看 历史
# This test builds a full system image, so it can take a little while.
# We make it a separate test target here, so that it can run in parallel
# with the rest of the tests.
function precompile_test_harness(@nospecialize(f))
load_path = mktempdir()
try
pushfirst!(LOAD_PATH, load_path)
pushfirst!(DEPOT_PATH, load_path)
f(load_path)
finally
try
rm(load_path, force=true, recursive=true)
catch err
@show err
end
filter!(()(load_path), LOAD_PATH)
filter!(()(load_path), DEPOT_PATH)
end
return nothing
end
precompile_test_harness() do dir
Foo_file = joinpath(dir, "OncePerFoo.jl")
image_file = joinpath(dir, "img.jl")
write(Foo_file,
"""module OncePerFoo
const f = OncePerThread{Nothing}() do
println(Core.stdout, "Running thread init...")
end
f() # Executed during pre-compilation
end # module OncePerFoo
""")
write(image_file,
"""
Base.init_depot_path()
Base.init_load_path()
using OncePerFoo
function main()
OncePerFoo.f()
return 0
end
OncePerFoo.f() # fire init during compilation time
""")
Base.compilecache(Base.PkgId("OncePerFoo"))
new_env = Dict(["JULIA_DEPOT_PATH" => join(DEPOT_PATH, Sys.iswindows() ? ';' : ':'),
"JULIA_LOAD_PATH" => join(LOAD_PATH, Sys.iswindows() ? ';' : ':')])
@test success(pipeline(addenv(`$(Base.julia_cmd()) --compile=all -t1,0 --strip-ir --output-o $(dir)/sys.o.a $(image_file) `, new_env), stderr=stderr, stdout=stdout)) skip=(Sys.WORD_SIZE == 32)
if isfile(joinpath(dir, "sys.o.a"))
Base.Linking.link_image(joinpath(dir, "sys.o.a"), joinpath(dir, "sys.so"))
str = readchomp(`$(Base.julia_cmd()) -t1,0 -J $(dir)/sys.so -e 'Base.scrub_repl_backtrace(nothing); println("loaded"); main()'`)
@test split(str, '\n') == ["loaded", "Running thread init..."]
end
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mirrors/julia-language.git
git@gitee.com:mirrors/julia-language.git
mirrors
julia-language
julia-language
master

搜索帮助