mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Generate PDB files for better debugging on Windows (#16008)
Summary: 1. Unify `build_pytorch_libs.bat`, `setup.py` and `torch/CMakeLists.txt` on the debugging flags with the `CMAKE_BUILD_TYPE` being `Debug`, `Release` and `RelWithDebInfo`. 2. Install PDBs through CMake if they are generated. Reference: 1. CMake PDB install: https://gitlab.kitware.com/cmake/cmake/issues/18393#note_459199 2. About debugging flags https://stackoverflow.com/a/4662345 3. MSDN page about /DEBUG flag: https://docs.microsoft.com/en-us/cpp/build/reference/debug-generate-debug-info?view=vs-2017 4. MSDN page about /Z{i/I/7}: https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=vs-2017 Work to do: - [x] Test the changes work in Release config through this PR - [ ] <del> Test debug build through https://github.com/pytorch/pytorch/pull/16009 </del> - [x] Test release build with debugging symbols through #16013 Difficulties: - [x] Replace /Zi flags with /Z7 (which will be added if DEBUG or RelWithDebInfo is used), as it is not supported by sccache - [x] Resolve `LINK : fatal error LNK1210: exceeded internal ILK size limit; link with /INCREMENTAL:NO` in the debug build - [ ] DEBUG build blocked by a MSVC bug. In order to resolve it, we'll need to update the MSVC in CI: https://developercommunity.visualstudio.com/content/problem/225957/fatal-error-lnk1318-unexpected-pdb-error-ok-0.html Pull Request resolved: https://github.com/pytorch/pytorch/pull/16008 Differential Revision: D13709527 Pulled By: ezyang fbshipit-source-id: e8365bc75d9ec64099093f7001f83d99a06b196b
This commit is contained in:
committed by
Facebook Github Bot
parent
0dfdc2cbdb
commit
f7733526aa
@ -12,9 +12,15 @@ if (BUILD_CAFFE2_OPS)
|
||||
|
||||
target_link_libraries(caffe2_detectron_ops_gpu caffe2_gpu)
|
||||
install(TARGETS caffe2_detectron_ops_gpu DESTINATION lib)
|
||||
if (MSVC)
|
||||
install(FILES $<TARGET_PDB_FILE:caffe2_detectron_ops_gpu> DESTINATION lib OPTIONAL)
|
||||
endif()
|
||||
elseif(NOT IOS_PLATFORM)
|
||||
add_library(caffe2_detectron_ops SHARED ${Detectron_CPU_SRCS})
|
||||
target_link_libraries(caffe2_detectron_ops caffe2)
|
||||
install(TARGETS caffe2_detectron_ops DESTINATION lib)
|
||||
if (MSVC)
|
||||
install(FILES $<TARGET_PDB_FILE:caffe2_detectron_ops> DESTINATION lib OPTIONAL)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
@ -12,4 +12,7 @@ if (BUILD_TEST)
|
||||
|
||||
target_link_libraries(caffe2_module_test_dynamic caffe2_library)
|
||||
install(TARGETS caffe2_module_test_dynamic DESTINATION lib)
|
||||
if (MSVC)
|
||||
install(FILES $<TARGET_PDB_FILE:caffe2_module_test_dynamic> DESTINATION lib OPTIONAL)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -19,6 +19,9 @@ target_include_directories(caffe2_observers PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.
|
||||
target_compile_options(caffe2_observers PRIVATE "-DCAFFE2_BUILD_OBSERVER_LIB")
|
||||
install(TARGETS caffe2_observers DESTINATION lib)
|
||||
caffe2_interface_library(caffe2_observers caffe2_observers_library)
|
||||
if (MSVC)
|
||||
install(FILES $<TARGET_PDB_FILE:caffe2_observers> DESTINATION lib OPTIONAL)
|
||||
endif()
|
||||
|
||||
if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
||||
set(Caffe2_MODULES ${Caffe2_MODULES} caffe2_observers_library PARENT_SCOPE)
|
||||
|
Reference in New Issue
Block a user