brenhinkeller / StaticTools.jl

Enabling StaticCompiler.jl-based compilation of (some) Julia code to standalone native binaries by avoiding GC allocations and llvmcall-ing all the things!
MIT License
167 stars 12 forks source link

Doesn't work in 1.9 #7

Closed PallHaraldsson closed 2 years ago

PallHaraldsson commented 2 years ago

I understand if you want to NOT restrict in compat (and am I for sure doing it right?), for those trying to debug (would master still work for them?), I'm thinking of blocking 1.9, in case unreliable, would not always get segfault.

Despite you stating "1.8+" your example in README didn't work for me, in my rather recent:

Version 1.9.0-DEV.432 (2022-04-25)

~/julia-1.9-DEV-65b9be4086/bin/julia 

julia> filepath = compile_executable(print_args, (Int64, Ptr{Ptr{UInt8}}), "./")

signal (11): Segmentation fault
in expression starting at REPL[4]:1
pthread_mutex_lock at /lib/x86_64-linux-gnu/libpthread.so.0 (unknown line)
jl_system_image_data at /home/pharaldsson_sym/julia-1.9-DEV-65b9be4086/lib/julia/sys.so (unknown line)
Allocations: 4534290 (Pool: 4529666; Big: 4624); GC: 6
Segmentation fault (core dumped)

I thought it might be helpful to know on the first try I got much longer segfault:
signal (11): Segmentation fault
in expression starting at REPL[26]:1
__atomic_add at /usr/local/include/c++/7.3.0/ext/atomicity.h:53 [inlined]
__atomic_add_dispatch at /usr/local/include/c++/7.3.0/ext/atomicity.h:96 [inlined]
_M_add_ref_copy at /usr/local/include/c++/7.3.0/bits/shared_ptr_base.h:138 [inlined]
__shared_count at /usr/local/include/c++/7.3.0/bits/shared_ptr_base.h:691 [inlined]
__shared_ptr at /usr/local/include/c++/7.3.0/bits/shared_ptr_base.h:1121
shared_ptr at /usr/local/include/c++/7.3.0/bits/shared_ptr.h:119 [inlined]
ThreadSafeContext at /buildworker/worker/package_linux64/build/usr/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h:29 [inlined]
getContext at /buildworker/worker/package_linux64/build/usr/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h:153 [inlined]
jl_create_native_impl at /buildworker/worker/package_linux64/build/src/aotcompile.cpp:268
compile_method_instance at /home/pharaldsson_sym/.julia/packages/GPUCompiler/I9fZc/src/jlgen.jl:361
macro expansion at /home/pharaldsson_sym/.julia/packages/TimerOutputs/2IJ7m/src/TimerOutput.jl:252 [inlined]
irgen at /home/pharaldsson_sym/.julia/packages/GPUCompiler/I9fZc/src/irgen.jl:4
macro expansion at /home/pharaldsson_sym/.julia/packages/GPUCompiler/I9fZc/src/driver.jl:149 [inlined]
macro expansion at /home/pharaldsson_sym/.julia/packages/TimerOutputs/2IJ7m/src/TimerOutput.jl:252 [inlined]
macro expansion at /home/pharaldsson_sym/.julia/packages/GPUCompiler/I9fZc/src/driver.jl:148 [inlined]
#emit_llvm#110 at /home/pharaldsson_sym/.julia/packages/GPUCompiler/I9fZc/src/utils.jl:64
unknown function (ip: 0x7f7904b4ad65)
unknown function (ip: 0x7f7904b0b3e9)
unknown function (ip: 0x7f7904b0b3c8)
emit_llvm##kw at /home/pharaldsson_sym/.julia/packages/GPUCompiler/I9fZc/src/utils.jl:62 [inlined]
#codegen#108 at /home/pharaldsson_sym/.julia/packages/GPUCompiler/I9fZc/src/driver.jl:58
codegen##kw at /home/pharaldsson_sym/.julia/packages/GPUCompiler/I9fZc/src/driver.jl:49 [inlined]
#generate_executable#25 at /home/pharaldsson_sym/.julia/packages/StaticCompiler/S1AWw/src/StaticCompiler.jl:355
generate_executable at /home/pharaldsson_sym/.julia/packages/StaticCompiler/S1AWw/src/StaticCompiler.jl:351 [inlined]
#compile_executable#20 at /home/pharaldsson_sym/.julia/packages/StaticCompiler/S1AWw/src/StaticCompiler.jl:241
compile_executable at /home/pharaldsson_sym/.julia/packages/StaticCompiler/S1AWw/src/StaticCompiler.jl:232 [inlined]
compile_executable at /home/pharaldsson_sym/.julia/packages/StaticCompiler/S1AWw/src/StaticCompiler.jl:232
unknown function (ip: 0x7f7904b21898)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2392 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2574
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1838 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:126
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:215
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:166 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:612
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:750
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:912
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:856
ijl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:151
repl_backend_loop at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:246
start_repl_backend at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:231
#run_repl#47 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:368
run_repl at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:355
jfptr_run_repl_64703.clone_1 at /home/pharaldsson_sym/julia-1.9-DEV-65b9be4086/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2392 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2574
#961 at ./client.jl:419
jfptr_YY.961_26879.clone_1 at /home/pharaldsson_sym/julia-1.9-DEV-65b9be4086/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2392 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2574
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1838 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:774
#invokelatest#2 at ./essentials.jl:796 [inlined]
invokelatest at ./essentials.jl:794 [inlined]
run_main_repl at ./client.jl:404
exec_options at ./client.jl:318
_start at ./client.jl:518
jfptr__start_31460.clone_1 at /home/pharaldsson_sym/julia-1.9-DEV-65b9be4086/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2392 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2574
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1838 [inlined]
true_main at /buildworker/worker/package_linux64/build/src/jlapi.c:566
jl_repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:710
main at /buildworker/worker/package_linux64/build/cli/loader_exe.c:59
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /home/pharaldsson_sym/julia-1.9-DEV-65b9be4086/bin/julia (unknown line)
Allocations: 26846096 (Pool: 26790558; Big: 55538); GC: 50
Segmentation fault (core dumped)
brenhinkeller commented 2 years ago

There are problems on 1.9 currently for a lot of packages -- including StaticCompiler itself as well intermittently on widely used packages like LoopVectorization.jl.

If we restrict the version in the compat though, then CI won't work on nightly, and we won't be able to track progress there.

I'm hoping some of these problems will get sorted out before they branch off 1.9.

brenhinkeller commented 2 years ago

Following #12, we can actually support 1.9 now as far as StaticTools is concerned! Though note that StaticCompiler itself doesn't run on 1.9 yet so probably don't upgrade just yet :).