Skip to content

VS2022Preview ParallelCommon.cpp.obj : fatal error LNK1161: invalid export specification #87957

@meongmeongasd

Description

@meongmeongasd

🐛 Describe the bug

[5554/5844] Linking CXX shared library bin\torch_cpu.dll
FAILED: bin/torch_cpu.dll lib/torch_cpu.lib
cmd.exe /C "cd . && C:\Prog\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\Preview\VC\Tools\MSVC\1434~1.319\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:/Github/pytorch/build/lib/caffe2_protos.lib -WHOLEARCHIVE:C:/Github/pytorch/build/lib/onnx.lib  && cd ."
LINK: command "C:\PROGRA~1\MICROS~4\2022\Preview\VC\Tools\MSVC\1434~1.319\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:/Github/pytorch/build/lib/caffe2_protos.lib -WHOLEARCHIVE:C:/Github/pytorch/build/lib/onnx.lib /MANIFEST /MANIFESTFILE:bin\torch_cpu.dll.manifest" failed (exit code 1161) with the following output:
ParallelCommon.cpp.obj : fatal error LNK1161: invalid export specification

after some comparsion
VS2022Preview 17.4.0 Preview 5.0
emit this

/EXPORT:?init@?1??lazy_init_num_threads@internal@at@@YAXXZ@4_NA,THREAD_DATA

while
VS2019 16.11.20

/EXPORT:?init@?1??lazy_init_num_threads@internal@at@@YAXXZ@4_NA,DATA 

here the object files
obj_files.zip

Workaround?
idk

Thanks.

CC @vladimir-aubrecht

Versions

pytorch trunk
commit f967918
VS2022

C:\Github\pytorch>cl -v
Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31932 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

VS2019

C:\Github\pytorch_VS2019>cl -v
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30146 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cc @malfet @seemethere

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: buildBuild system issuesmodule: static linkingRelated to statically linked libtorch (we dynamically link by default)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions