3

I am a llvm beginner. I run the command:

../llvm-6.0.0.src/build/bin/opt -load=./test.so -Hello < main.bc

according to the tutorial but got the error:

opt: CommandLine Error: Option 'use-dbg-addr' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

I googled again and again, and got nothing about this error.

compor
  • 2,239
  • 1
  • 19
  • 29
mark
  • 31
  • 3

1 Answers1

4

You need a LLVM build with shared libraries enabled, which corresponds to cmake options BUILD_SHARED_LIBS=On. You can check what type of LLVM you have installed by either checking its lib directory or executing:

llvm-config --shared-mode

This should report shared; anything else will require you to recompile.

compor
  • 2,239
  • 1
  • 19
  • 29
  • 1
    Thanks for your help! After runing "llvm-config --shared-mode" I got "static", so I have to compile llvm again? – mark Jul 23 '18 at 08:48
  • yeah, I'm afraid so. Maybe [this](https://stackoverflow.com/questions/47696773/llvm-6-trunk-build-on-ubuntu-16-04-not-building-lld/47729443#47729443) thread could help a bit – compor Jul 23 '18 at 09:01
  • hmm, I recompile the llvm as your advice, and now "llvm-config -shared-mode" says "shared", but now get another problem:" opt: CommandLine Error: Option 'o' registered more than once!". So what's wrong with this error? – mark Jul 25 '18 at 08:21
  • are you sure you have the right `opt` in your `$PATH`? What does `which opt` say? – compor Jul 25 '18 at 13:28
  • unless you're also defining a `-o` option in your plugin too? that is already taken by `opt` itself – compor Jul 25 '18 at 14:49
  • Thanks for reply. "which opt" says "/usr/local/bin/opt", and there is no difference between "which opt" and "llvm/build/bin/opt", compared by vimdiff. And I just ran the same command in the question, but got such error. – mark Jul 26 '18 at 03:04
  • I found that cmake couldn't recognize "add_llvm_loadable_module". I just compile llvm as the llvm.org says. – mark Jul 26 '18 at 03:06
  • oh ok, you hadn't said so; let's see how that goes – compor Jul 26 '18 at 08:02
  • I hava used cmake options `-DLLVM_BUILD_LLVM_DYLIB=ON` `-DBUILD_SHARED_LIBS=ON` to solve this problem in llvm-15.0.7 – mc_pengzi Feb 15 '23 at 12:26