How to instrument engine code with Flax.Build?

Hi!

We’ve recently switched to the native X11 backend on Linux because we ran into an issue with the SDL/Wayland backend that prevents drag-and-drop operations from working correctly, particularly when dragging scripts.

While testing the X11 backend, we’ve encountered a few other Linux-specific issues. We’d like to help improve the engine by investigating these problems when we can and reporting reproducible bugs through GitHub issues, ideally with enough technical information to make them useful to the developers.

To help us with this task, we’d like to trace function calls using uftrace.

For this, we’d like to compile some parts of the engine with Clang’s: -finstrument-functions.

Ideally, we’d like to instrument only a specific module, or even better, a few specific source files such as Source/Engine/Platform/Linux/LinuxPlatform.cpp rather than instrumenting the whole engine.

We saw that Flax.Build exposes compilation options through BuildOptions / CompileEnv, so we were wondering what the recommended way to do this would be.

Is there a way from a .Build.cs file to:

  1. add a custom compiler flag such as -finstrument-functions to a specific engine module; and/or

  2. add compiler flags only to selected .cpp files?

We’d prefer to do this through the normal Flax.Build configuration if possible, rather than modifying UnixToolchain.cs.

The goal is simply to temporarily instrument a small part of the engine and compare the function call traces between a working and a failing run.

How would you approach this with Flax.Build?

Thanks! :slightly_smiling_face:

You could put some custom args into CustomArgs of CompileEnvironment when building engine or just fork it and customize.

Also, we have native Tracy support: Tracy Profiler | Flax Documentation and dotTrace: dotTrace Profiler | Flax Documentation

1 Like