Regression: at::cuda::getCurrentCUDASparseHandle() link error on linux

I have a C++ extension containing the following code:

auto handle = at::cuda::getCurrentCUDASparseHandle();

It was working fine until version Pytorch 1.11.0, now with 1.12.1 linking with the same .so files I get undefined reference to at::cuda::getCurrentCUDASparseHandle() but only on my linux build. Windows is fine.

Did this function move to a new .so file? Maybe I need to explicitly include some header, instead of the all-in-one #include <torch/cuda.h>?
Thanks!

Solution to the above is to add --no-as-needed to my CMake linker params. For some yet unknown reason, the default --as-needed option for ld would discard torch_cuda_cpp.so in my build with 1.12.1.