I am building LLVM with cmake and Ninja build generator as following:
cmake path/to/llvm/ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=1 -DLLVM_ENABLE_CXX1Y=1 -DLLVM_ENABLE_RTTI=1 -DLLVM_TARGETS_TO_BUILD="X86" -G Ninja
Now I a am trying to use the -debug-only=mytype
option of opt to print some debug information about my own passes: using the following in my passes code:
define DEBUG_TYPE "mytype"
DEBUG(errs() << "My debug message\n");
Running opt as following doesn't generate any output messages:
opt < a.bc > /dev/null -mypass -debug-only=mytype
According to LLVM documentation:
For performance reasons, -debug-only is not available in optimized build (--enable-optimized) of LLVM.
I suspect this to be the root of my issue, but I can't find how to turn on/off this option when using cmake to build llvm.
It is controlled by enabling assertions.
cmake -DLLVM_ENABLE_ASSERTIONS=ON
is enough to turn it on. If you don't see your debug output, then your code is not executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With