How to build with custom utility source files?

I’m struggling with building pytorch, with additional c++ source code. Because it is about code instrumentation, I’m not considering c++ extensions.
So I tried to locate my .h and .cpp files in torch/csrc/utils/, but it seems like additional treatment is needed to build properly with additional source files. If it is true, where is the place that I should add the information about my additional sources?

Current state:


int foo();


#include <torch/csrc/utils/instrument.h>

int foo() {
  return 42;

When foo() is invoked by other (existing) source code, pytorch is built without error, but fails to be imported in python with undefined symbol error.


By entirely reinstalling pytorch,(that is, python clean followed by python install) it works. Guess compile commands for new source files are added by cmake, which remains unchanged when only python install invoked :sweat_smile: