mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Allow to specify specific files for debug info (#111748)
Building with `USE_CUSTOM_DEBINFO=torch/csrc/Module.cpp python setup.py develop` for example will provide debug info only for this file. This allows to enable debug symbols very fast from a non-debug build by doing a clean then develop (as long as you have ccache) and avoid very large binaries that take a very long time to load in gdb. Pull Request resolved: https://github.com/pytorch/pytorch/pull/111748 Approved by: https://github.com/drisspg, https://github.com/ezyang, https://github.com/malfet
This commit is contained in:
parent
024ffd342a
commit
236472b32a
2 changed files with 23 additions and 0 deletions
|
|
@ -1225,3 +1225,23 @@ caffe2_print_configuration_summary()
|
|||
if(BUILD_FUNCTORCH)
|
||||
add_subdirectory(functorch)
|
||||
endif()
|
||||
|
||||
# Parse custom debug info
|
||||
if(DEFINED USE_CUSTOM_DEBINFO)
|
||||
string(REPLACE ";" " " SOURCE_FILES "${USE_CUSTOM_DEBINFO}")
|
||||
message(STATUS "Source files with custom debug infos: ${SOURCE_FILES}")
|
||||
|
||||
string(REGEX REPLACE " +" ";" SOURCE_FILES_LIST "${SOURCE_FILES}")
|
||||
|
||||
# Set the COMPILE_FLAGS property for each source file
|
||||
foreach(SOURCE_FILE ${SOURCE_FILES_LIST})
|
||||
# We have to specify the scope here. We do this by specifying the
|
||||
# targets we care about and caffe2/ for all test targets defined there
|
||||
set(ALL_PT_TARGETS "torch_python;c10;torch_cpu;torch")
|
||||
set_source_files_properties(${SOURCE_FILE} DIRECTORY "caffe2/" TARGET_DIRECTORY ${ALL_PT_TARGETS} PROPERTIES COMPILE_FLAGS "-g")
|
||||
endforeach()
|
||||
|
||||
# Link everything with debug info when any file is in debug mode
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -g")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -g")
|
||||
endif()
|
||||
|
|
|
|||
3
setup.py
3
setup.py
|
|
@ -8,6 +8,9 @@
|
|||
# REL_WITH_DEB_INFO
|
||||
# build with optimizations and -g (debug symbols)
|
||||
#
|
||||
# USE_CUSTOM_DEBINFO="path/to/file1.cpp;path/to/file2.cpp"
|
||||
# build with debug info only for specified files
|
||||
#
|
||||
# MAX_JOBS
|
||||
# maximum number of compile jobs we should use to compile your code
|
||||
#
|
||||
|
|
|
|||
Loading…
Reference in a new issue