Hi all, After creating a new LLVM-based project, I faced an odd problem. ExecutionEngine::create always retuned null. After some investigation I found out that it was due to the target architecture not getting registered. I'm using Visual C++ 2005 and in the X86TargetMachine.cpp file an extern variable X86TargetMachineModule is created to 'ensure' that the module is linked in. It works for the example projects, but not for the one I created. When I write a value to X86TargetMachineModule in another module, all is fine and dandy. Although it's a viable workaround for now I was wondering if anyone knew a more elegant solution, or has an explanation why X86TargetMachineModule works for the example projects but not for mine. Thanks, Nicolas Capens -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080527/0b73ecda/attachment.html>
Evan Cheng
2008-May-27 18:17 UTC
[LLVMdev] JIT creation issue on Windows Was: Re: X86TargetMachineModule not helping
This is probably a Windows specific issue. If your subject contains Windows, perhaps some of the folks who are using llvm on Windows might chime in. Evan On May 26, 2008, at 3:10 PM, Nicolas Capens wrote:> Hi all, > > After creating a new LLVM-based project, I faced an odd problem. > ExecutionEngine::create always retuned null. After some > investigation I found out that it was due to the target architecture > not getting registered. I’m using Visual C++ 2005 and in the > X86TargetMachine.cpp file an extern variable X86TargetMachineModule > is created to ‘ensure’ that the module is linked in. It works for > the example projects, but not for the one I created. When I write a > value to X86TargetMachineModule in another module, all is fine and > dandy… > > Although it’s a viable workaround for now I was wondering if anyone > knew a more elegant solution, or has an explanation > whyX86TargetMachineModule works for the example projects but not for > mine. > > Thanks, > > Nicolas Capens > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080527/a07015b9/attachment.html>
Nicolas, In Visual Studio 2005, you can force the linker to include specific symbols. In your project, under "Configuration Properties/Linker/Input/Force Symbol References", try adding _X86TargetMachineModule. Hope that helps! Stein Pedersen _____ From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Nicolas Capens Sent: 27. mai 2008 00:11 To: 'LLVM Developers Mailing List' Subject: [LLVMdev] X86TargetMachineModule not helping Hi all, After creating a new LLVM-based project, I faced an odd problem. ExecutionEngine::create always retuned null. After some investigation I found out that it was due to the target architecture not getting registered. I'm using Visual C++ 2005 and in the X86TargetMachine.cpp file an extern variable X86TargetMachineModule is created to 'ensure' that the module is linked in. It works for the example projects, but not for the one I created. When I write a value to X86TargetMachineModule in another module, all is fine and dandy. Although it's a viable workaround for now I was wondering if anyone knew a more elegant solution, or has an explanation why X86TargetMachineModule works for the example projects but not for mine. Thanks, Nicolas Capens -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080528/4bef89f4/attachment.html>
Very interesting trick, thanks Stein! From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Stein Pedersen Sent: Wednesday, 28 May, 2008 12:28 To: 'LLVM Developers Mailing List' Subject: Re: [LLVMdev] X86TargetMachineModule not helping Nicolas, In Visual Studio 2005, you can force the linker to include specific symbols. In your project, under "Configuration Properties/Linker/Input/Force Symbol References", try adding _X86TargetMachineModule. Hope that helps! Stein Pedersen _____ From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Nicolas Capens Sent: 27. mai 2008 00:11 To: 'LLVM Developers Mailing List' Subject: [LLVMdev] X86TargetMachineModule not helping Hi all, After creating a new LLVM-based project, I faced an odd problem. ExecutionEngine::create always retuned null. After some investigation I found out that it was due to the target architecture not getting registered. I'm using Visual C++ 2005 and in the X86TargetMachine.cpp file an extern variable X86TargetMachineModule is created to 'ensure' that the module is linked in. It works for the example projects, but not for the one I created. When I write a value to X86TargetMachineModule in another module, all is fine and dandy. Although it's a viable workaround for now I was wondering if anyone knew a more elegant solution, or has an explanation why X86TargetMachineModule works for the example projects but not for mine. Thanks, Nicolas Capens -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080528/d0123516/attachment.html>