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
- bcc: link LLVM dynamically. As a distro, we want this anyway, but static linking also broke, e.g. bpftrace: https://github.com/iovisor/bpftrace/issues/1855 — committed to void-linux/void-packages by leahneukirchen 5 years ago
- bcc: link LLVM dynamically. As a distro, we want this anyway, but static linking also broke, e.g. bpftrace: https://github.com/iovisor/bpftrace/issues/1855 — committed to Noodlez1232/void-packages by leahneukirchen 5 years ago
- tasks/bcc: Make bcc runnable as explained in the following post: https://github.com/iovisor/bpftrace/issues/1855 It's almost a year ago... — committed to keithnoguchi/arch-on-air by keithnoguchi 5 years ago
This is only known to be an issue with LLVM 12.
The current suggested workaround is to build bcc with:
-DENABLE_LLVM_SHARED=1cmake flagOn Ubuntu this is caused by having two copies of LLVM in the same process.
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:This is despite
find_package (LLVM)correctly finding our LLVM. Removing this check and always dynamically linking LLVM ifSTATIC_LINKING=OFFseems 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=1fix worked for me, thanks!For me, the error was caused by the bcc installed from source. I fixed it with:
-DENABLE_LLVM_SHARED=1solve my problem.