Bazel: Support Clang 9's "ftime-trace"

Created on 1 Aug 2019  路  4Comments  路  Source: bazelbuild/bazel

Description of the problem / feature request:

Clang 9 introduces the -ftime-trace option which dumps a .json file containing the tracing information from the compilation run. It would be great to retrieve this from sandbox for the relevant C++ compilation rules.

Feature requests: what underlying problem are you trying to solve with this feature?

Let people use Clang 9's compilation tracing with Bazel native CC rules.

Have you found anything relevant by searching the web?

No

P4 team-Rules-CPP feature request

Most helpful comment

When I saw my JSON trace files had been deleted, I tried re-running my build command with --spawn_strategy=standalone and it kept the files around. It's not building in the sandbox, but for me it was useful enough as a one-off build to be able to debug what was taking long to compile.

e.g.

bazel build //foo --copt=-ftime-trace --spawn_strategy=standalone

All 4 comments

This is great, I have been trying to get this to work but unfortunately the .json file always gets deleted. I understand it is running in the sandbox but can anyone explain why the unexpected file gets deleted and the expected files are preserved?

Does anyone have a workaround? We would like to enable this for our codebase.

When I saw my JSON trace files had been deleted, I tried re-running my build command with --spawn_strategy=standalone and it kept the files around. It's not building in the sandbox, but for me it was useful enough as a one-off build to be able to debug what was taking long to compile.

e.g.

bazel build //foo --copt=-ftime-trace --spawn_strategy=standalone

Thanks so much for the helpful tip @jez !

Someone at our company was able to add support for this using an aspect. I've asked them to chime in here if they have time.

Was this page helpful?
0 / 5 - 0 ratings