PyTorch 2.5.1 -fstack-protector-strong does not result in stack-protected libpytorch.so

Ubuntu 18.04
gcc 9.4.0
ldd 2.27
Python 3.11

I am attempting to build PyTorch 2.5.1 so that the resulting shared libraries are “hardened”, such that when we run hardening-check from Debian’s devscripts against them, it reports that stack protection is enabled.

I’ve added “-fstack-protector-strong” to the extra_compile_args in setup.py, and all but two libraries (libtorch.so and libtorch_global_deps.so) are successfully hardened.

Nothing I have tried so far has had any effect on these two libraries. Does anyone know what I’m doing wrong?

I notice that these libraries are very small compared to the others that get produced during the build. Are these libraries special somehow?

Solved! libtorch.so and libtorch_global_deps.so are empty helper libraries, which is explained via comments in CMakeLists.txt.

I gather this means that there isn’t a stack to protect, so the compiler flag has no effect. Which rhymes, so it must be true.