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.
Let people use Clang 9's compilation tracing with Bazel native CC rules.
No
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.
Most helpful comment
When I saw my JSON trace files had been deleted, I tried re-running my build command with
--spawn_strategy=standaloneand 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.