[LLVMdev] Static linking of execution engine
Mario Schwalbe
mario at se.inf.tu-dresden.de
Wed May 22 02:34:20 PDT 2013
Hi,
Am 21.05.13 21:57, schrieb Kaylor, Andrew:
> Yeah, this is a problem with the static constructor getting optimized out. Including "JIT.h" is supposed to fix that.
> Is it possible that the file where you are including "JIT.h" doesn't have any required code in it?
I'm including "JIT.h" directly in the main module, which also uses the
engine. See the small test case attached. Even if I bypass the dummy object
and call LLVMLinkInJIT() directly, it still gets optimized out...
ciao,
Mario
-------------- next part --------------
/*
* vim: set tabstop=4 shiftwidth=4 expandtab:
*/
#define DEBUG_TYPE "ExecutionEngineTest"
#include <llvm/ExecutionEngine/Interpreter.h>
#include <llvm/ExecutionEngine/JIT.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <cassert>
using namespace llvm;
int main(void)
{
InitializeNativeTarget();
#if 1
LLVMLinkInJIT();
#endif
EngineBuilder engineBuilder(new Module("foo", getGlobalContext()));
#if 0
engineBuilder.setEngineKind(EngineKind::Interpreter);
#else
engineBuilder.setEngineKind(EngineKind::JIT);
#endif
const OwningPtr<ExecutionEngine> executionEngine(engineBuilder.create());
assert(executionEngine && "Failed to create execution engine");
return 0;
}
More information about the llvm-dev
mailing list