manabreak
manabreak

Reputation: 5597

How to make GCC debug dumps with Makefile projects?

The title says it pretty nicely. I have a huge project that uses Makefile. How do I do a project-wide debug dumps (say, -fdump-tree-gimple) with GCC?

Upvotes: 0

Views: 444

Answers (1)

Konstantin Vladimirov
Konstantin Vladimirov

Reputation: 7009

You must pass -fdump-tree-gimple (actually put any pass-name instead of gimple, or even all to dump all tree passes) to compilation string for every compiler execution (i.e. every time, you are calling gcc on source files or with -c option). Dump in form filename.c.XXX.gimple for any source file name will appear (XXX is a pass number like 003, depends on gcc version) in a working directory (often it is build folder). Also you may want to specify -dumpdir to collect all dumps in a single dump directory, this may be handy to avoid mess.

How will you do it in you makefile -- up to you. You may add it to $CFLAGS (most common solution, because dumping is a part of compilation flags), or create special variable and pass it around, or hard-code it inside makefile.

If you are building your project with lto, you must pass those flag(s) also on second link stage (i.e. add to LDFLAGS or so).

Upvotes: 1

Related Questions