Build shared lib fail at linking stage

Hello there,

I am trying to build the lite version in Release on Windows. The goal is to get a smaller shared lib that focus on the inference part of Pytorch.
After trying multiple times, both following README instructions from the repository and using the builder available on Git, I’m reaching a point where everything seems to build correctly but the lib generation fails at linking stage.
Does anyone know what’s happening here ?
Thanks for reading me !

I’m providing the logs after removing a few lines of unresolved external symbols for clarity :

[6837/7346] Linking CXX shared library bin\torch_cpu.dll
FAILED: bin/torch_cpu.dll lib/torch_cpu.lib 
C:\Windows\system32\cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --intdir=caffe2\CMakeFiles\torch_cpu.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\MICROS~4\2022\COMMUN~1\VC\Tools\MSVC\1437~1.328\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\torch_cpu.rsp  /out:bin\torch_cpu.dll /implib:lib\torch_cpu.lib /pdb:bin\torch_cpu.pdb /dll /version:0.0 /machine:x64 /ignore:4049 /ignore:4217 /ignore:4099 /INCREMENTAL:NO  -WHOLEARCHIVE:C:/Users/juliena/Desktop/builder/windows/pytorch/build/lib/caffe2_protos.lib -WHOLEARCHIVE:C:/Users/juliena/Desktop/builder/windows/pytorch/build/lib/onnx.lib  && cd ."
LINK: command "C:\PROGRA~1\MICROS~4\2022\COMMUN~1\VC\Tools\MSVC\1437~1.328\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\torch_cpu.rsp /out:bin\torch_cpu.dll /implib:lib\torch_cpu.lib /pdb:bin\torch_cpu.pdb /dll /version:0.0 /machine:x64 /ignore:4049 /ignore:4217 /ignore:4099 /INCREMENTAL:NO -WHOLEARCHIVE:C:/Users/juliena/Desktop/builder/windows/pytorch/build/lib/caffe2_protos.lib -WHOLEARCHIVE:C:/Users/juliena/Desktop/builder/windows/pytorch/build/lib/onnx.lib /MANIFEST:EMBED,ID=2" failed (exit code 1120) with the following output:
   Creating library lib\torch_cpu.lib and object lib\torch_cpu.exp
AdaptiveAvgPoolKernel.cpp.AVX2.cpp.obj : error LNK2001: unresolved external symbol "void __cdecl at::share_memory_(class at::TensorBase &)" (?share_memory_@at@@YAXAEAVTensorBase@1@@Z)
Activation.cpp.AVX2.cpp.obj : error LNK2001: unresolved external symbol "void __cdecl at::share_memory_(class at::TensorBase &)" (?share_memory_@at@@YAXAEAVTensorBase@1@@Z)
BinaryOpsKernel.cpp.AVX2.cpp.obj : error LNK2001: unresolved external symbol "void __cdecl at::share_memory_(class at::TensorBase &)" (?share_memory_@at@@YAXAEAVTensorBase@1@@Z)

... (a lot of unresolved external sympbols here)

sgd.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl torch::nn::Module::load(class torch::serialize::InputArchive &)" (?load@Module@nn@torch@@UEAAXAEAVInputArchive@serialize@3@@Z)
sgd.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl torch::nn::Module::pretty_print(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (?pretty_print@Module@nn@torch@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
sgd.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl torch::nn::Module::is_serializable(void)const " (?is_serializable@Module@nn@torch@@UEBA_NXZ)

sgd.cpp.obj : error LNK2001: unresolved external symbol "private: virtual void __cdecl torch::nn::Module::clone_(class torch::nn::Module &,class std::optional<struct c10::Device> const &)" (?clone_@Module@nn@torch@@EEAAXAEAV123@AEBV?$optional@UDevice@c10@@@std@@@Z)

bin\torch_cpu.dll : fatal error LNK1120: 80 unresolved externals

Is there anyone that can help me please ?
I can provide more logs if necessary… I really need to compile a lite version and I can’t make it using the provided scripts

Thank you again :pray: