Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-fno-omit-frame-pointer equivalent compiler option for clang

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.

like image 296
Arpit Aggarwal Avatar asked May 09 '17 08:05

Arpit Aggarwal


People also ask

What compiler does Clang use?

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.

Is GCC better than Clang?

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.

Will GCC be replaced by Clang?

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.

Is GCC compatible with Clang?

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.


1 Answers

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"

like image 171
Jason Creighton Avatar answered Sep 24 '22 06:09

Jason Creighton