Cling and Vulkan

Hello,
I’m new to cling. I just finished reading vulkan tutorial and wanted to try if it’s possible to use vulkan in realtime somehow: the program basically uses vulkan through glfw after defining GLFW_INCLUDE_VULKAN. To make it work you need to load the vulkan shared library before the inclusion of glfw. As soon as the functions called execute vkEnumerateInstanceExtensionProperties it crashes with this message:

#0 0x00005645baec611e llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0xa2711e)
#1 0x00005645baec3f56 llvm::sys::RunSignalHandlers() (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0xa24f56)
#2 0x00005645baec40be SignalHandler(int) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0xa250be)
#3 0x00007f3986ac2210 (/lib/x86_64-linux-gnu/libc.so.6+0x46210)
#4 0x00005645bd8f66ea llvm::RegisterPassParser<llvm::MachineSchedRegistry>::NotifyAdd(llvm::StringRef, void* (*)(), llvm::StringRef) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x34576ea)
#5 0x00007f397f91103d (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x8df03d)
#6 0x00007f3987080b8a (/lib64/ld-linux-x86-64.so.2+0x11b8a)
#7 0x00007f3987080c91 (/lib64/ld-linux-x86-64.so.2+0x11c91)
#8 0x00007f3986bdf915 _dl_catch_exception /build/glibc-eX1tMB/glibc-2.31/elf/dl-error-skeleton.c:184:18
#9 0x00007f39870850bf (/lib64/ld-linux-x86-64.so.2+0x160bf)
#10 0x00007f3986bdf8b8 _dl_catch_exception /build/glibc-eX1tMB/glibc-2.31/elf/dl-error-skeleton.c:209:18
#11 0x00007f39870845fa (/lib64/ld-linux-x86-64.so.2+0x155fa)
#12 0x00007f398700934c dlopen_doit /build/glibc-eX1tMB/glibc-2.31/dlfcn/dlopen.c:66:13
#13 0x00007f3986bdf8b8 _dl_catch_exception /build/glibc-eX1tMB/glibc-2.31/elf/dl-error-skeleton.c:209:18
#14 0x00007f3986bdf983 _dl_catch_error /build/glibc-eX1tMB/glibc-2.31/elf/dl-error-skeleton.c:228:12
#15 0x00007f3987009b59 _dlerror_run /build/glibc-eX1tMB/glibc-2.31/dlfcn/dlerror.c:174:40
#16 0x00007f39870093da dlopen /build/glibc-eX1tMB/glibc-2.31/dlfcn/dlopen.c:87:51
#17 0x00007f3986820b14 _init (/home/USER/.local/share/ov/pkg/create-2021.1.1/_build/kit_release/_build/linux-x86_64/release/plugins/carb_gfx/libvulkan.so+0x26b14)
#18 0x00007f398682104f _init (/home/USER/.local/share/ov/pkg/create-2021.1.1/_build/kit_release/_build/linux-x86_64/release/plugins/carb_gfx/libvulkan.so+0x2704f)
#19 0x00007f3986825a47 _init (/home/USER/.local/share/ov/pkg/create-2021.1.1/_build/kit_release/_build/linux-x86_64/release/plugins/carb_gfx/libvulkan.so+0x2ba47)
#20 0x00007f3986829a3b vkEnumerateInstanceExtensionProperties (/home/USER/.local/share/ov/pkg/create-2021.1.1/_build/kit_release/_build/linux-x86_64/release/plugins/carb_gfx/libvulkan.so+0x2fa3b)
#21 0x00007f3985f8803a
#22 0x00005645bae15254 cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x976254)
#23 0x00005645bae28487 cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x989487)
#24 0x00005645bae29d8d cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x98ad8d)
#25 0x00005645bae2a0a9 cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x98b0a9)
#26 0x00005645bae76eed cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x9d7eed)
#27 0x00005645baef22ed cling::UserInterface::runInteractively(bool) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0xa532ed)
#28 0x00005645bacee60d main (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x84f60d)
#29 0x00007f3986aa30b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#30 0x00005645bad618fe _start (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x8c28fe)
Stack dump:
0.      Program arguments: /home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling --nologo -std=c++17 
Segmentation fault (core dumped)

What am I missing?

The stack trace tells me that Vulcan uses llvm11. That llvm clashes with cling’s llvm. You’ll have to hide all llvm symbols when linking cling, e.g. by passing -fvisibility=hidden and -Wl,-Bsymbolic to the compiler for the llvm built “as part of” cling.

Thanks for your reply! Unfortunately it doesn’t work. I add the command line options and it reports warning: -Wl,-Bsymbolic: 'linker' input unused which I have no idea about what it means and then report the same error:

#0 0x000055dd0791711e llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0xa2711e)
#1 0x000055dd07914f56 llvm::sys::RunSignalHandlers() (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0xa24f56)
#2 0x000055dd079150be SignalHandler(int) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0xa250be)
#3 0x00007f9f04e5a210 (/lib/x86_64-linux-gnu/libc.so.6+0x46210)
#4 0x000055dd0a3476ea llvm::RegisterPassParser<llvm::MachineSchedRegistry>::NotifyAdd(llvm::StringRef, void* (*)(), llvm::StringRef) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x34576ea)installed
#5 0x00007f9efdc2203d (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x8df03d)
#6 0x00007f9f05418b8a (/lib64/ld-linux-x86-64.so.2+0x11b8a)
#7 0x00007f9f05418c91 (/lib64/ld-linux-x86-64.so.2+0x11c91)
#8 0x00007f9f04f77915 _dl_catch_exception /build/glibc-eX1tMB/glibc-2.31/elf/dl-error-skeleton.c:184:18
#9 0x00007f9f0541d0bf (/lib64/ld-linux-x86-64.so.2+0x160bf)
#10 0x00007f9f04f778b8 _dl_catch_exception /build/glibc-eX1tMB/glibc-2.31/elf/dl-error-skeleton.c:209:18
#11 0x00007f9f0541c5fa (/lib64/ld-linux-x86-64.so.2+0x155fa)
#12 0x00007f9f053a134c dlopen_doit /build/glibc-eX1tMB/glibc-2.31/dlfcn/dlopen.c:66:13
#13 0x00007f9f04f778b8 _dl_catch_exception /build/glibc-eX1tMB/glibc-2.31/elf/dl-error-skeleton.c:209:18
#14 0x00007f9f04f77983 _dl_catch_error /build/glibc-eX1tMB/glibc-2.31/elf/dl-error-skeleton.c:228:12
#15 0x00007f9f053a1b59 _dlerror_run /build/glibc-eX1tMB/glibc-2.31/dlfcn/dlerror.c:174:40
#16 0x00007f9f053a13da dlopen /build/glibc-eX1tMB/glibc-2.31/dlfcn/dlopen.c:87:51
#17 0x00007f9f04db8ad9 (/usr/lib/x86_64-linux-gnu/libvulkan.so.1.2.131+0x26ad9)
#18 0x00007f9f04dbd80c (/usr/lib/x86_64-linux-gnu/libvulkan.so.1.2.131+0x2b80c)
#19 0x00007f9f04dc170e vkEnumerateInstanceExtensionProperties (/usr/lib/x86_64-linux-gnu/libvulkan.so.1.2.131+0x2f70e)
#20 0x00007f9f04d37733 (/usr/lib/x86_64-linux-gnu/libglfw.so.3.3+0xe733)
#21 0x00007f9f04d37a4a glfwGetRequiredInstanceExtensions (/usr/lib/x86_64-linux-gnu/libglfw.so.3.3+0xea4a)
#22 0x00007f9f038b7f31
#23 0x00007f9f0390fac6
#24 0x00007f9f0390f550
#25 0x00007f9f03916560
#26 0x00007f9f040f5022
#27 0x000055dd07866254 cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x976254)
#28 0x000055dd07879487 cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x989487)
#29 0x000055dd0787ad8d cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x98ad8d)
#30 0x000055dd0787b0a9 cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x98b0a9)
#31 0x000055dd078c7eed cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x9d7eed)
#32 0x000055dd079432ed cling::UserInterface::runInteractively(bool) (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0xa532ed)
#33 0x000055dd0773f60d main (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x84f60d)
#34 0x00007f9f04e3b0b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#35 0x000055dd077b28fe _start (/home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling+0x8c28fe)
Stack dump:
0.      Program arguments: /home/USER/bin/cling_2020-11-05_ROOT-ubuntu2004/bin/cling --nologo -std=c++17 -Wl,-Bsymbolic 
Segmentation fault (core dumped)

isn’t there a comprehensive manual or something similar (I couldn’t find it)? I really know too less to even start to reason correctly and maybe I just messed up something trivial like maybe my llvm version is not the right one. If I recall correctly cling works with llvm-9, right?

Edit: Important: i’ve an Intel gpu and am using the distributed mesa driver (on a surface pro). It may be inaccurate but that could be the culprit according to this bug report. As soon as I have some time I’ll try to switch to a llvm-statically linked mesa driver and try on another workstation with an nvidia gpu and proprietary driver. I may be wrong though.

Hi,

Those are compiler flags for building cling. You should be able to pass them to cmake with -DCXX_FLAGS="-fvisibility=hidden -Wl,-Bsymbolic"; once that’s done you can build cling (and llvm and clang). If this doesn’t work / doesn’t make sense then please let me know how you built cling!

Cheers, Axel…

Hello,

previously I didn’t build it but downloaded the most recent binaries. I did build it now following this guide and using the script in which I added the specified option in the cmake line. Unfortunately cling still segfaults calling vkEnumerateInstanceExtensionProperties. As already said it’s not unlikely I missed some steps and, as always, thanks for the support.

Error message below:

/home/USER/bin/cling_interpreter/inst/bin/cling(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2e)[0x564c7b3e2e4e]
/home/USER/bin/cling_interpreter/inst/bin/cling(_ZN4llvm3sys17RunSignalHandlersEv+0x34)[0x564c7b3e0da4]
/home/USER/bin/cling_interpreter/inst/bin/cling(+0xdd2ee2)[0x564c7b3e0ee2]
/lib/x86_64-linux-gnu/libc.so.6(+0x41950)[0x7fe167f22950]
/home/USER/bin/cling_interpreter/inst/bin/cling(_ZNK4llvm19raw_svector_ostream11current_posEv+0x8)[0x564c7b3c6f08]
/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZN4llvm11raw_ostream5writeEPKcm+0x1fb)[0x7fe1619e2b7b]
/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZN4llvm18report_fatal_errorERKNS_5TwineEb+0xf3)[0x7fe161953803]
/lib/x86_64-linux-gnu/libLLVM-11.so.1(+0x9fa708)[0x7fe161953708]
/lib/x86_64-linux-gnu/libLLVM-11.so.1(+0x9e9ec9)[0x7fe161942ec9]
/lib/x86_64-linux-gnu/libLLVM-11.so.1(+0x9def15)[0x7fe161937f15]
/lib/x86_64-linux-gnu/libLLVM-11.so.1(+0x9ebd5d)[0x7fe161944d5d]
/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZNK4llvm17ManagedStaticBase21RegisterManagedStaticEPFPvvEPFvS1_E+0xd4)[0x7fe161993914]
/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZN4llvm2cl14OptionCategory16registerCategoryEv+0x2d)[0x7fe161937cad]
/lib/x86_64-linux-gnu/libLLVM-11.so.1(+0x8cfff2)[0x7fe161828ff2]
/lib64/ld-linux-x86-64.so.2(+0x11dbe)[0x7fe169c08dbe]
/lib64/ld-linux-x86-64.so.2(+0x11ea8)[0x7fe169c08ea8]
/lib/x86_64-linux-gnu/libc.so.6(_dl_catch_exception+0xe5)[0x7fe16803b505]
/lib64/ld-linux-x86-64.so.2(+0x16505)[0x7fe169c0d505]
/lib/x86_64-linux-gnu/libc.so.6(_dl_catch_exception+0x88)[0x7fe16803b4a8]
/lib64/ld-linux-x86-64.so.2(+0x15b5d)[0x7fe169c0cb5d]
/lib/x86_64-linux-gnu/libdl.so.2(+0x134c)[0x7fe169b7534c]
/lib/x86_64-linux-gnu/libc.so.6(_dl_catch_exception+0x88)[0x7fe16803b4a8]
/lib/x86_64-linux-gnu/libc.so.6(_dl_catch_error+0x33)[0x7fe16803b573]
/lib/x86_64-linux-gnu/libdl.so.2(+0x1b89)[0x7fe169b75b89]
/lib/x86_64-linux-gnu/libdl.so.2(dlopen+0x48)[0x7fe169b753d8]
/usr/lib/x86_64-linux-gnu/libvulkan.so.1.2.141(+0x27e19)[0x7fe167eaae19]
/usr/lib/x86_64-linux-gnu/libvulkan.so.1.2.141(+0x2ccd9)[0x7fe167eafcd9]
/usr/lib/x86_64-linux-gnu/libvulkan.so.1.2.141(vkEnumerateInstanceExtensionProperties+0x1e1)[0x7fe167eb3ad1]
/usr/lib/x86_64-linux-gnu/libglfw.so.3.3(+0xe733)[0x7fe167e28733]
/usr/lib/x86_64-linux-gnu/libglfw.so.3.3(glfwGetRequiredInstanceExtensions+0x5a)[0x7fe167e28a4a]
[0x7fe166537b05]
[0x7fe166579426]
[0x7fe166578f03]
[0x7fe16657f1c3]
[0x7fe1665c8022]
/home/USER/bin/cling_interpreter/inst/bin/cling(_ZNK5cling19IncrementalExecutor14executeWrapperEN4llvm9StringRefEPNS_5ValueE+0x344)[0x564c7b312b64]
/home/USER/bin/cling_interpreter/inst/bin/cling(_ZN5cling11Interpreter11RunFunctionEPKN5clang12FunctionDeclEPNS_5ValueE+0x9f)[0x564c7b32a4df]
/home/USER/bin/cling_interpreter/inst/bin/cling(_ZN5cling11Interpreter16EvaluateInternalERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_18CompilationOptionsEPNS_5ValueEPPNS_11TransactionEm+0x1fb)[0x564c7b32be9b]
/home/USER/bin/cling_interpreter/inst/bin/cling(_ZN5cling11Interpreter7processERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_5ValueEPPNS_11TransactionEb+0x15d)[0x564c7b32c17d]
/home/USER/bin/cling_interpreter/inst/bin/cling(_ZN5cling13MetaProcessor7processEN4llvm9StringRefERNS_11Interpreter17CompilationResultEPNS_5ValueEb+0x247)[0x564c7b36f407]
/home/USER/bin/cling_interpreter/inst/bin/cling(_ZN5cling13UserInterface16runInteractivelyEb+0x1fd)[0x564c7b413d7d]
/home/USER/bin/cling_interpreter/inst/bin/cling(main+0x4f0)[0x564c7b1ce300]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf2)[0x7fe167f09cb2]
/home/USER/bin/cling_interpreter/inst/bin/cling(_start+0x2e)[0x564c7b25bdae]
Stack dump:
0.      Program arguments: /home/USER/bin/cling_interpreter/inst/bin/cling -std=c++17 
Errore di segmentazione (core dump creato)

This:

has your system lib’s LLVM call into cling, which is a proof that your build system modifications were not successful / sufficient. Please check with make VERBOSE=1 (if you use GNU Makefiles) that the llvm built as part of building cling (and not just cling itself) is indeed built with these flags.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.