Advertisement
Guest User

LLVM + GLX crash

a guest
Jan 28th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.93 KB | None | 0 0
  1. #define __STDC_LIMIT_MACROS
  2. #define __STDC_CONSTANT_MACROS
  3. #include <llvm/IR/LLVMContext.h>
  4. #include <llvm/IR/Module.h>
  5. #include <llvm/IR/Value.h>
  6. #include <llvm/IR/Function.h>
  7. #include <llvm/IR/DerivedTypes.h>
  8. #include <llvm/IR/Intrinsics.h>
  9. #include <llvm/IR/IRBuilder.h>
  10. #include <llvm/IR/TypeBuilder.h>
  11. #include <llvm/Support/TargetSelect.h>
  12. #include <llvm/Support/raw_os_ostream.h>
  13. #include <llvm/ExecutionEngine/ExecutionEngine.h>
  14. #include <llvm/ExecutionEngine/JIT.h>
  15. #include <llvm/ExecutionEngine/GenericValue.h>
  16. #include <X11/Xlib.h>
  17. #include <GL/gl.h>
  18. #include <GL/glx.h>
  19. #include <iostream>
  20.  
  21. int main() {
  22.     llvm::InitializeNativeTarget();
  23.  
  24.     Display * display = XOpenDisplay(NULL);
  25.  
  26.     if (display) {
  27.         GLint attributes[] = {
  28.             GLX_RGBA,
  29.             GLX_DEPTH_SIZE, 24,
  30.             GLX_DOUBLEBUFFER,
  31.             None
  32.         };
  33.         std::cout << "display." << std::endl;
  34.  
  35.         // crashes on the call to glXChooseVisual if I call InitializeNativeTarget...
  36.         XVisualInfo * vi = glXChooseVisual(display, 0, attributes);
  37.         if (vi) {
  38.             std::cout << "visual." << std::endl;
  39.         }
  40.  
  41.         XCloseDisplay(display);
  42.     }
  43.  
  44.     return 0;
  45. }
  46.  
  47. /*
  48. Built using:
  49.  
  50. g++ main.cpp -lGL -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMJIT -lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMObject -lLLVMCore -lLLVMSupport -o test
  51.  
  52. (result of llvm-config --libs jit x86, basically)
  53. */
  54.  
  55. /*
  56. Segfault I get:
  57.  
  58. #0  0x0000000000b7d745 in llvm::cl::generic_parser_base::findOption(char const*) ()
  59. #1  0x00000000008b30fd in llvm::RegisterPassParser<llvm::MachineSchedRegistry>::NotifyAdd(char const*, void* (*)(), char const*) ()
  60. #2  0x00007f0fa825ff99 in ?? () from /usr/lib/x86_64-linux-gnu/libLLVM-3.1.so.1
  61. #3  0x00007f0facc17316 in ?? () from /lib64/ld-linux-x86-64.so.2
  62. #4  0x00007f0facc173ef in ?? () from /lib64/ld-linux-x86-64.so.2
  63. #5  0x00007f0facc1baea in ?? () from /lib64/ld-linux-x86-64.so.2
  64. #6  0x00007f0facc17186 in ?? () from /lib64/ld-linux-x86-64.so.2
  65. #7  0x00007f0facc1b32a in ?? () from /lib64/ld-linux-x86-64.so.2
  66. #8  0x00007f0fab675f26 in ?? () from /lib/x86_64-linux-gnu/libdl.so.2
  67. #9  0x00007f0facc17186 in ?? () from /lib64/ld-linux-x86-64.so.2
  68. #10 0x00007f0fab67652f in ?? () from /lib/x86_64-linux-gnu/libdl.so.2
  69. #11 0x00007f0fab675fc1 in dlopen () from /lib/x86_64-linux-gnu/libdl.so.2
  70. #12 0x00007f0fac9e7928 in ?? () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
  71. #13 0x00007f0fac9eb13c in ?? () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
  72. #14 0x00007f0fac9c5409 in ?? () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
  73. #15 0x00007f0fac9c1b19 in ?? () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
  74. #16 0x00007f0fac9c22bb in glXChooseVisual () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
  75. #17 0x0000000000438f41 in main ()
  76. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement