Repository: pytorch
Issue: LibTorch static build from source missing libshm.so
Labels: module: build,triaged

### 🐛 Describe the bug

Hi everyone,

I am trying to build LibTorch from source. I am following directions given in this link:

https://github.com/pytorch/pytorch/blob/orig/release/1.13/docs/libtorch.rst

I git cloned version 1.13.0 and then ran the following:

mkdir pytorch-build

cd pytorch-build

cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DUSE_CUDA:BOOL=OFF -DPYTHON_EXECUTABLE:PATH=`which python3` -DUSE_CUDNN:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=../pytorch-install ../pytorch

cmake --build . --target install

I am getting the following output during build configuration:
[build_config.txt](https://github.com/pytorch/pytorch/files/10160473/build_config.txt)

And then an error during build process itself:

...
[ 97%] Building CXX object caffe2/CMakeFiles/torch_cpu.dir/__/aten/src/ATen/native/cpu/Activation.cpp.AVX2.cpp.o
[ 97%] Linking CXX static library ../lib/libtorch_cpu.a
[ 97%] Built target torch_cpu
[ 97%] Building CXX object caffe2/CMakeFiles/torch.dir/__/empty.cpp.o
[ 97%] Linking CXX static library ../lib/libtorch.a
[ 97%] Built target torch
[ 97%] Built target python_copy_files
[ 97%] Building C object sleef/src/libm/CMakeFiles/mkrename_gnuabi.dir/mkrename_gnuabi.c.o
[ 97%] Linking C executable ../../bin/mkrename_gnuabi
[ 97%] Built target mkrename_gnuabi
[ 97%] Building C object sleef/src/libm/CMakeFiles/mkmasked_gnuabi.dir/mkmasked_gnuabi.c.o
[ 97%] Linking C executable ../../bin/mkmasked_gnuabi
[ 97%] Built target mkmasked_gnuabi
[ 97%] Building C object sleef/src/common/CMakeFiles/arraymap.dir/arraymap.c.o
[ 97%] Built target arraymap
[ 97%] Building C object sleef/src/common/CMakeFiles/addSuffix.dir/addSuffix.c.o
[ 97%] Linking C executable ../../bin/addSuffix
[ 97%] Built target addSuffix
[ 97%] Building CXX object caffe2/torch/lib/libshm/CMakeFiles/shm.dir/core.cpp.o
[ 97%] Linking CXX shared library ../../../../lib/libshm.so
/usr/bin/ld: cannot find $<TARGET_FILE:dnnl_graph>: No such file or directory
collect2: error: ld returned 1 exit status
gmake[2]: *** [caffe2/torch/lib/libshm/CMakeFiles/shm.dir/build.make:124: lib/libshm.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:5384: caffe2/torch/lib/libshm/CMakeFiles/shm.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

For the full output of cmake build command, please see: 
[build.txt](https://github.com/pytorch/pytorch/files/10162179/build.txt)

I am not sure what I am doing wrong. I also find it interesting that up to that point, all libraries linked were static and this is the first shared library that is being linked.

Thank you in advance,

Pavel.

### Versions

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.1 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-5.15.0-56-generic-x86_64-with-glibc2.35
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 2070 SUPER
Nvidia driver version: 515.86.01
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

Versions of relevant libraries:
[pip3] mypy==0.991
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.23.1
[pip3] types-mypy-extensions==0.4
[conda] Could not collect


cc @malfet @seemethere