How to make a Debug Build

Hi,
I tried using cmake -DCMAKE_BUILD_TYPE:STRING=Debug but didn’t worked :frowning:
Can somebody help with the flags and options that should be used while building, to enable -debug and -debug-only in llc command.
I am using 12.0.1 version.
Trying this:
llc -debug-only=regalloc -regalloc=basic main.bc -o main_basic.s

llc: Unknown command line argument ‘-debug-only=regalloc’. Try: ‘llc --help’

llc: Did you mean ‘–debug-pass=regalloc’?

Even --debug-pass also don’t have any such option, please help!
Thanks!

Hi! This guide should help you get going:

https://www.llvm.org/docs/CMake.html

Hey,
Thanks, for responding!
As I already have mentioned that I have used -DCMAKE_BUILD_TYPE:STRING=Debug but still didn’t work.
This is only what documentation also says.
What else could I do?

CMAKE_BUILD_TYPE:STRING means cmake variable CMAKE_BUILD_TYPE requires a string type.

use something like -DCMAKE_BUILD_TYPE="debug" instead

I am wondering, is that option of -debug or -debug-only= is available in version 12.0.1 with llc?

I already have tried in each way @Arsenic-ATG including the one you have suggested.
Any further help, please.
Thanks

Hi, It would be helpful if you provide your whole build command, nvm try
cmake -S llvm-project/llvm -B llvm-project/build -DCMAKE_BUILD_TYPE=Debug (add other debug flags as per your requirement)

cmake -DCMAKE_BUILD_TYPE:STRING=Debug .. command i am using to build then make and then to see debug output llc -debug-only=regalloc -regalloc=basic main.bc -o main.s .
Have tried its multiple variants also.
Thanks!

Exactly that, or bin/llc? If you just use a plain llc you’ll continue to pick up whatever you have installed on the system, not the one you just built.

CMAKE_BUILD_TYPE doesn’t directly controls the debug macro in LLVM, even it should work by default.
-debug option is documented here: LLVM: include/llvm/Support/Debug.h Source File requires assertion to be on. That is controlled by LLVM_ENABLE_ASSERTIONS option, which should be ON for DEBUG build. Remember to remove CMakeCache.txt if you don’t start clean, or you can specify -D LLVM_ENABLE_ASSERTIONS=On to cmake.

Thank you so much! I just can’t express it in words, I am really thankful.
I know this was a dumb mistake but still I was not even looking for this.
Thank you again!