JuliaLang / PackageCompiler.jl

Compile your Julia Package
https://julialang.github.io/PackageCompiler.jl/dev/
MIT License
1.43k stars 193 forks source link

Channels don't seem to compile #52

Closed ranjanan closed 4 years ago

ranjanan commented 6 years ago

The error I got was:

Julia program file:
  "/Users/ranjan/graph/static/buzz.jl"
C program file:
  "/Users/ranjan/.julia/v0.6/PackageCompiler/examples/program.c"
Build directory:
  "/Users/ranjan/graph/static/build"
ERROR: LoadError: UndefVarError: uv_eventloop not defined
Stacktrace:
 [1] enq_work(::Task) at ./event.jl:83
 [2] async_run_thunk(::Function) at ./task.jl:323
 [3] include_from_node1(::String) at ./loading.jl:576
 [4] include(::String) at ./sysimg.jl:14
while loading /Users/ranjan/graph/static/buzz.jl, in expression starting on line 3
ERROR: failed process: Process(`/Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia -Ccore2 -J/Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib --compile=yes --depwarn=yes --startup-file=no --output-o /Users/ranjan/graph/static/build/buzz.o -e 'empty!(Base.LOAD_CACHE_PATH) # reset / remove any builtin paths
        push!(Base.LOAD_CACHE_PATH, abspath("/Users/ranjan/graph/static/build")) # enable usage of precompiled files
        include("/Users/ranjan/graph/static/buzz.jl") # include Julia program file
        empty!(Base.LOAD_CACHE_PATH) # reset / remove build-system-relative paths'`, ProcessExited(1)) [1]
Stacktrace:
 [1] pipeline_error(::Base.Process) at ./process.jl:682
 [2] run(::Cmd) at ./process.jl:651
 [3] build_object(::String, ::String, ::String, ::Bool, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void) at /Users/ranjan/.julia/v0.6/PackageCompiler/src/static_julia.jl:221
 [4] #static_julia#1(::String, ::String, ::String, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::String, ::Void, ::PackageCompiler.#static_julia, ::String) at /Users/ranjan/.julia/v0.6/PackageCompiler/src/static_julia.jl:127
 [5] (::PackageCompiler.#kw##static_julia)(::Array{Any,1}, ::PackageCompiler.#static_julia, ::String) at ./<missing>:0
 [6] build_executable(::String) at /Users/ranjan/.julia/v0.6/PackageCompiler/src/api.jl:84

Here's a minimum reproducible script:

const ch = Channel{Any}(32)
 @async ch

 Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
     return 0
 end
ranjanan commented 6 years ago

Ref: https://github.com/JuliaGizmos/Tachyons.jl/issues/1

NHDaly commented 6 years ago

It looks like uv_eventloop is defined here, in reinit_stdio: https://github.com/JuliaLang/julia/blob/28e79562f484b8adca5581f9c11233b66c89a9a6/base/libuv.jl#L103

And reinit_stdio is normally called from __init__, here: https://github.com/JuliaLang/julia/blob/2233ec47d67753d8c219633cdfa36b8e03ef2332/base/sysimg.jl#L486

Could this be related to the issues in #47? I tried adding that big Sys.__init__(); Base.early_init() block, but that didn't fix anything..

dhazeghi commented 5 years ago

I hit this recently. Workaround seems to be to make the global variable non-const and initialize in a function. Still somewhat annoying though.