sys-bio / roadrunner

libRoadRunner: A high-performance SBML simulator
http://libroadrunner.org/
Other
39 stars 25 forks source link

Julia binding on Mac-linker errors #904

Open SunnyXu opened 3 years ago

SunnyXu commented 3 years ago

I am trying to use the RoadRunner binary file (libroadrunner_c_api.dylib) for Julia binding in the Mac system, there are errors showing as below. I am afraid it is from the LLVM of RoadRunner. I have tried the Antimony binary file (libantimony.dylib), it works well on Mac. In addition, roadrunner_c_api.dll (windows) and libroadrunner_c_api.so (linux) from the recent release work well with Julia too. The errors are attached below. Please use the attached package (https://drive.google.com/drive/folders/1gOWJXo94n5HtcERpoqUTWEgGKYuf-PFx) to reproduce the errors. Just put everything in a folder, add libroadrunner_c_api.dylib and run sbml_test.jl file in Julia.

In the previous conversation with Ciaran, it seems to be linker errors - the C api binary is looking for missing symbols in its symbol table, for example "ZN6rrllvm18LLVMModelGenerator11createModelERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEj " translates to "LLBMModelGenerator::createModel" which is in the core roadrunner library. We need to make sure that libroadrunner_c_api.dylib can find roadrunner.dylib. I have only include libroadrunner_c_api.dylib so far while have not include roadrunner.dylib or other files in the core roadrunner library. Please note that I only need one binary file for windows/linux systems.

Please let me know if you could help fix it. Thanks in advance. Sincerely, Jin

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.3 (2021-09-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> include("//Users//XU//Desktop//mac//sbml_test.jl")

signal (11): Segmentation fault: 11
in expression starting at /Users/XU/Desktop/mac/sbml_test.jl:12
_ZN4llvm14DomTreeBuilder11SemiNCAInfoINS_17DominatorTreeBaseINS_10BasicBlockELb0EEEE20CalculateFromScratchERS4_PNS5_15BatchUpdateInfoE at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libLLVM.dylib (unknown line)
_ZN12_GLOBAL__N_18Verifier6verifyERKN4llvm8FunctionE at /Users/XU/Desktop/mac/libroadrunner_c_api.dylib (unknown line)
_ZN4llvm14verifyFunctionERKNS_8FunctionEPNS_11raw_ostreamE at /Users/XU/Desktop/mac/libroadrunner_c_api.dylib (unknown line)
_ZN6rrllvm11CodeGenBaseIPFvPNS_13LLVMModelDataEmEE14verifyFunctionEv at /Users/XU/Desktop/mac/libroadrunner_c_api.dylib (unknown line)
_ZN6rrllvm28EvalInitialConditionsCodeGen7codeGenEv at /Users/XU/Desktop/mac/libroadrunner_c_api.dylib (unknown line)
_ZN6rrllvm18LLVMModelGenerator11createModelERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEj at /Users/XU/Desktop/mac/libroadrunner_c_api.dylib (unknown line)
_ZN2rr22ExecutableModelFactory11createModelERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPKNS_10DictionaryE at /Users/XU/Desktop/mac/libroadrunner_c_api.dylib (unknown line)
_ZN2rr10RoadRunner4loadERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPKNS_10DictionaryE at /Users/XU/Desktop/mac/libroadrunner_c_api.dylib (unknown line)
loadSBML at /Users/XU/Desktop/mac/libroadrunner_c_api.dylib (unknown line)
loadSBML at /Users/XU/Desktop/mac/rr_funcs-Jin.jl:130
unknown function (ip: 0x169de0f96)
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
do_call at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
eval_body at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_interpret_toplevel_thunk at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_in at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
eval at ./boot.jl:360 [inlined]
include_string at ./loading.jl:1116
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
_include at ./loading.jl:1170
include at ./client.jl:444
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
do_call at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
eval_body at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_interpret_toplevel_thunk at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_in at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
eval at ./boot.jl:360 [inlined]
eval_user_input at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139
repl_backend_loop at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200
start_repl_backend at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185
#run_repl#42 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317
run_repl at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
#874 at ./client.jl:387
jfptr_YY.874_29243 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_f__call_latest at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:708 [inlined]
invokelatest at ./essentials.jl:706 [inlined]
run_main_repl at ./client.jl:372
exec_options at ./client.jl:302
_start at ./client.jl:485
jfptr__start_31088 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
true_main at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
repl_entrypoint at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
Allocations: 2648 (Pool: 2639; Big: 9); GC: 0

[Process completed]
luciansmith commented 9 months ago

Looks like our Julia bindings are working now, so I'm closing this issue. If there are still problems, feel free to re-open!

SunnyXu commented 9 months ago

@luciansmith @adelhpour Hi, I do not think this issue is fixed. The current Julia binding is only working on windows and linux as before but only with an updated version of binary files to 2.5.0. Please refer to the source code (https://github.com/sys-bio/RoadRunner.jl/blob/master/src/RoadRunner.jl#L31). It would be good if you could cross check and help fix this. Thanks.

adelhpour commented 9 months ago

@luciansmith , @SunnyXu is right. Julia bindings for RoadRunner were already disabled for macOS. I tried to get them working, but the problem is the dynamic library of roadrunner is not loaded properly in Julia (the problem is in llvm linkage). Some similar issues are reported, but I couldn't find any reasonable solution. So, as before, it is only available for Windows and Linux.