bpftrace: Abort on startup: `CommandLine Error: Option ... registered more than once!`

Bcc static links llvm by default, if we then link LLVM again we get llvm command line fatal errors during startup.

We should either:

  • find out whether we can fix this at link time. Maybe if we specify bcc before llvm it grabs most of the stuff it needs from the bcc archive, preventing issues. Although it seems tricky to get right
  • Note in the docs that bcc needs to be built with shared llvm, see:

Did you build bcc yourself, if you did make sure you dynamic link against llvm. See debc79ef9ad4784258705a92ae70f9c7689a9c24

_Originally posted by @fbs in https://github.com/iovisor/bpftrace/issues/251#issuecomment-846424774_


: CommandLine Error: Option ‘openmp-ir-builder-optimistic-attributes’ registered more than once!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 23 (9 by maintainers)

Commits related to this issue

Most upvoted comments

This is only known to be an issue with LLVM 12.

The current suggested workaround is to build bcc with: -DENABLE_LLVM_SHARED=1 cmake flag

On Ubuntu this is caused by having two copies of LLVM in the same process.

  • bpfcc is linked to LLVM dynamically as expected.
  • bpftrace pulls in the static libraries, despite Ubuntu’s build process not asking for it.

This causes two copies of LLVM to be loaded into the resulting bpftrace process.

After some investigation, this is due to the following check failing in src/ast/CMakeLists.txt:

  find_library(found_LLVM LLVM HINTS ${LLVM_LIBRARY_DIRS})
  if(found_LLVM)

This is despite find_package (LLVM) correctly finding our LLVM. Removing this check and always dynamically linking LLVM if STATIC_LINKING=OFF seems to fix the issue.

To users in this thread, the fix will be available in Ubuntu 24.10 as soon as feasible.

The bcc with -DENABLE_LLVM_SHARED=1 fix worked for me, thanks!

For me, the error was caused by the bcc installed from source. I fixed it with:

cd bcc/build
sudo make uninstall

sudo apt install bpftrace bpfcc-tools libbpfcc --reinstall

This is only known to be an issue with LLVM 12.

The current suggested workaround is to build bcc with: -DENABLE_LLVM_SHARED=1 cmake flag

-DENABLE_LLVM_SHARED=1 solve my problem.