Greetings!
This is an RFC prototype for adding initial -ftime-trace support to GCC.

The patch adds a new -ftime-trace option and emits a simple JSON trace file
containing total compilation time. The JSON format follows the traceEvents
structure used by browser tracing tools.

This is intended as a first step toward a more complete compile-time tracing
feature with per-pass timing events, possibly integrated with GCC's existing
timevar infrastructure.

Testing done:

make -j2 all-gcc
make -k check-gcc RUNTESTFLAGS="dg.exp=ftime-trace-1.c"
make info

Manual test:

./gcc/xgcc -B./gcc -S /tmp/test.c -ftime-trace -o /tmp/test.s
python3 -m json.tool /tmp/test.c.json

Result:

# of expected passes 1

gcc/ChangeLog:

* common.opt: Add -ftime-trace.
* toplev.cc (gcc_time_trace_now_us): New function.
(gcc_write_simple_time_trace): New function.
(do_compile): Emit JSON trace when -ftime-trace is enabled.
* doc/invoke.texi: Document -ftime-trace.

gcc/testsuite/ChangeLog:

* gcc.dg/ftime-trace-1.c: New test.

Signed-off-by: Heli  [email protected]

Attachment: 0001-gcc-Add-initial-ftime-trace-support.patch
Description: Binary data

Reply via email to