Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example fails with `Inserted && "Pass registered multiple times!"' error #45

Open
spyked opened this issue Feb 22, 2019 · 4 comments
Open
Assignees

Comments

@spyked
Copy link

spyked commented Feb 22, 2019

Compiling with a custom build of LLVM 6.0 works:

$ pwd
/home/mogosanu/llvm-jit/easyjit-obj
$ cmake -DLLVM_DIR=/opt/llvm-6.0/lib/cmake/llvm/ ../easy-just-in-time/
$ cmake --build .
# generates /home/mogosanu/llvm-jit/easyjit-obj/bin/{EasyJitPass.so,libEasyJitRuntime.so}

And so does compiling a very simple example:

/opt/llvm-6.0/bin/clang++ -O2 --std=c++14 -o hello hello.cpp \
  -Xclang -load -Xclang /home/mogosanu/llvm-jit/easyjit-obj/bin/EasyJitPass.so \
  -I/home/mogosanu/llvm-jit/easy-just-in-time/include -L/home/mogosanu/llvm-jit/easyjit-obj/bin \
  -lEasyJitRuntime

But running it gives the following error:

$ LD_LIBRARY_PATH=/home/mogosanu/llvm-jit/easyjit-obj/bin ./hello 
hello: /home/mogosanu/llvm-jit/llvm/lib/IR/PassRegistry.cpp:62: void llvm::PassRegistry::registerPass(const llvm::PassInfo&, bool): Assertion `Inserted && "Pass registered multiple times!"' failed.
Aborted

hello.cpp:

#include <cstdio>

int main(void)
{
	printf("Hello, world!\n");
	return 0;
}

Can I get some help regarding this? Thank you!

@jmmartinez
Copy link
Owner

Hello! I'll try to reproduce it and I'll come back to you.
Thanks for the issue !

@jmmartinez jmmartinez self-assigned this Feb 22, 2019
@spyked
Copy link
Author

spyked commented Feb 22, 2019

Thank you for looking at this!

I forgot to add: the LLVM build I used is the official LLVM 6.0 release compiled with X86 as a target and with RTTI support.

@spyked
Copy link
Author

spyked commented Mar 4, 2019

I've been digging a bit more into this and the reason for the assertion failure seems to be related to the fact that registerPass is called multiple times from the initialization routines in the run-time, e.g. LLVMInitializeX86Target called from InitNativeTarget. This can be observed by running the example under gdb and breaking on registerPass.

The bug doesn't manifest in the LLVM packaged in e.g. Debian because that is a release build, or in any case, assertions are disabled for package builds. Passing -DCMAKE_BUILD_TYPE="Release" to the LLVM cmake call works around the bug.

@jmmartinez
Copy link
Owner

Today I've been trying to fix this. I did not find a solution for the moment. There seem to be other problems also with static linking for example. Thanks a lot for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants