I am trying to understand an existing pass in LLVM and thus trying to print the nicely written debug messages in the pass. I am doing so by using clang -debug -some-other-flags
. However while compiling it says:
clang: warning: argument unused during compilation: '-debug'
How to enable the debug output?
clang is a C, C++, and Objective-C compiler which encompasses preprocessing, parsing, optimization, code generation, assembly, and linking.
Introduction. The Clang Compiler is an open-source compiler for the C family of programming languages, aiming to be the best in class implementation of these languages. Clang builds on the LLVM optimizer and code generator, allowing it to provide high-quality optimization and code generation support for many targets.
The Clang tool is a front end compiler that is used to compile programming languages such as C++, C, Objective C++ and Objective C into machine code. Clang is also used as a compiler for frameworks like OpenMP, OpenCL, RenderScript, CUDA and HIP.
Clang does not have a "debug" command-line option; you need to either build the IR from clang and then run opt -debug
separately, or run clang -mllvm -debug
.
In general, the -mllvm
flag passes whatever appears afterwards on to LLVM itself. Use multiple -mllvm
flags if you want to pass multiple options onwards.
In case the accepted answer does not work for you: apart from adding -mllvm -debug
, you need clang which is built with debug assertions enabled, which is done by adding -DLLVM_ENABLE_ASSERTIONS=On
to cmake options when compiling clang (ref).
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