From ba26bc0fc266ddb58ec199349d2c93c7a905dfd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Barto=C5=88?= Date: Mon, 31 Oct 2022 21:11:16 +0000 Subject: [PATCH] Fix random "C1041: cannot open program database" errors when compiling on Windows (#88084) Adds `/FS` option to `CMAKE_CXX_FLAGS` and `CMAKE_CUDA_FLAGS`. So far I've encountered this kind of errors: ``` C:\Users\MyUser\AppData\Local\Temp\tmpxft_00004728_00000000-7_cuda.cudafe1.cpp: fatal error C1041: cannot open program database 'C:\Projects\pytorch\build\third_party\gloo\gloo\CMakeFiles\gloo_cuda.dir\vc140.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS ``` when building with VS 2022. cc @peterjc123 @mszhanyi @skyline75489 @nbcsm Related issues: - https://github.com/pytorch/pytorch/issues/87691 - https://github.com/pytorch/pytorch/issues/39989 Pull Request resolved: https://github.com/pytorch/pytorch/pull/88084 Approved by: https://github.com/ezyang --- CMakeLists.txt | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 105e38e7c1a..baf97a45586 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -545,6 +545,9 @@ if(MSVC) # Try harder string(APPEND CMAKE_CUDA_FLAGS " -Xcompiler /w -w") + + string(APPEND CMAKE_CXX_FLAGS " /FS") + string(APPEND CMAKE_CUDA_FLAGS " -Xcompiler /FS") endif(MSVC) string(APPEND CMAKE_CUDA_FLAGS " -Xfatbin -compress-all") diff --git a/setup.py b/setup.py index 72a6bbae7b4..ed0f0327165 100644 --- a/setup.py +++ b/setup.py @@ -795,7 +795,7 @@ def configure_extension_build(): # /EHsc is about standard C++ exception handling # /DNOMINMAX removes builtin min/max functions # /wdXXXX disables warning no. XXXX - extra_compile_args = ['/MD', '/EHsc', '/DNOMINMAX', + extra_compile_args = ['/MD', '/FS', '/EHsc', '/DNOMINMAX', '/wd4267', '/wd4251', '/wd4522', '/wd4522', '/wd4838', '/wd4305', '/wd4244', '/wd4190', '/wd4101', '/wd4996', '/wd4275']