Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define __STDC_LIMIT_MACROS
- #define __STDC_CONSTANT_MACROS
- #include <llvm/IR/LLVMContext.h>
- #include <llvm/IR/Module.h>
- #include <llvm/IR/Value.h>
- #include <llvm/IR/Function.h>
- #include <llvm/IR/DerivedTypes.h>
- #include <llvm/IR/Intrinsics.h>
- #include <llvm/IR/IRBuilder.h>
- #include <llvm/IR/TypeBuilder.h>
- #include <llvm/Support/TargetSelect.h>
- #include <llvm/Support/raw_os_ostream.h>
- #include <llvm/ExecutionEngine/ExecutionEngine.h>
- #include <llvm/ExecutionEngine/JIT.h>
- #include <llvm/ExecutionEngine/GenericValue.h>
- #include <X11/Xlib.h>
- #include <GL/gl.h>
- #include <GL/glx.h>
- #include <iostream>
- int main() {
- llvm::InitializeNativeTarget();
- Display * display = XOpenDisplay(NULL);
- if (display) {
- GLint attributes[] = {
- GLX_RGBA,
- GLX_DEPTH_SIZE, 24,
- GLX_DOUBLEBUFFER,
- None
- };
- std::cout << "display." << std::endl;
- // crashes on the call to glXChooseVisual if I call InitializeNativeTarget...
- XVisualInfo * vi = glXChooseVisual(display, 0, attributes);
- if (vi) {
- std::cout << "visual." << std::endl;
- }
- XCloseDisplay(display);
- }
- return 0;
- }
- /*
- Built using:
- 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
- (result of llvm-config --libs jit x86, basically)
- */
- /*
- Segfault I get:
- #0 0x0000000000b7d745 in llvm::cl::generic_parser_base::findOption(char const*) ()
- #1 0x00000000008b30fd in llvm::RegisterPassParser<llvm::MachineSchedRegistry>::NotifyAdd(char const*, void* (*)(), char const*) ()
- #2 0x00007f0fa825ff99 in ?? () from /usr/lib/x86_64-linux-gnu/libLLVM-3.1.so.1
- #3 0x00007f0facc17316 in ?? () from /lib64/ld-linux-x86-64.so.2
- #4 0x00007f0facc173ef in ?? () from /lib64/ld-linux-x86-64.so.2
- #5 0x00007f0facc1baea in ?? () from /lib64/ld-linux-x86-64.so.2
- #6 0x00007f0facc17186 in ?? () from /lib64/ld-linux-x86-64.so.2
- #7 0x00007f0facc1b32a in ?? () from /lib64/ld-linux-x86-64.so.2
- #8 0x00007f0fab675f26 in ?? () from /lib/x86_64-linux-gnu/libdl.so.2
- #9 0x00007f0facc17186 in ?? () from /lib64/ld-linux-x86-64.so.2
- #10 0x00007f0fab67652f in ?? () from /lib/x86_64-linux-gnu/libdl.so.2
- #11 0x00007f0fab675fc1 in dlopen () from /lib/x86_64-linux-gnu/libdl.so.2
- #12 0x00007f0fac9e7928 in ?? () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
- #13 0x00007f0fac9eb13c in ?? () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
- #14 0x00007f0fac9c5409 in ?? () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
- #15 0x00007f0fac9c1b19 in ?? () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
- #16 0x00007f0fac9c22bb in glXChooseVisual () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
- #17 0x0000000000438f41 in main ()
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement