I want to use DS-5 Streamline profiler
to profile my code. In the documentation its mentioned that to be able to see call stacks, we need to compile code with compiler option -fno-omit-frame-pointer
. This option is there in gcc.
Is there an equivalent option for clang also?
-fno-omit-frame-pointer
is not working for me with clang.
I have also tried setting the compiler optimization level to 0, but still I am not getting call stacks in streamline.
Clang uses the LLVM compiler as its back end and it has been included in the release of the LLVM since the LLVM 2.6. Clang is also built to be a drop-in replacement for GCC command. In its design, the Clang compiler has been constructed to work very similarly to GCC to ensure that portability is maximized.
Clang is much faster and uses far less memory than GCC. Clang aims to provide extremely clear and concise diagnostics (error and warning messages), and includes support for expressive diagnostics. GCC's warnings are sometimes acceptable, but are often confusing and it does not support expressive diagnostics.
Clang is designed to provide a frontend compiler that can replace GCC. Apple Inc. (including NeXT later) has been using GCC as the official compiler.
Yes, for C code Clang and GCC are compatible (they both use the GNU Toolchain for linking, in fact.) You just have to make sure that you tell clang to create compiled objects and not intermediate bitcode objects. C ABI is well-defined, so the only issue is storage format.
It looks like DS-5 is an ARM thing, so this might not be relevant, but I ran into a similar issue trying to get good stack traces out of a clang-compiled executable using Linux's perf profiler.
The problem ended up being that, on x86-64 Linux at least, Clang requires both -fno-omit-frame-pointer
and -mno-omit-leaf-frame-pointer
in order to get the same behavior that gcc gives with only -fno-omit-frame-pointer
. See this LLVM bug: "Need both -fno-omit-frame-pointer and -mno-omit-leaf-frame-pointer to get a fp on linux on a leaf function"
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