Skip to content

Commit

Permalink
[BE] Compile FBGEMM with ASAN (#111266)
Browse files Browse the repository at this point in the history
If `USE_ASAN` is set, compile FBGEMM with ASAN as well, by setting `USE_SANITIZER` to `address,undefined`

This fixes regression in sanitizer coverage introduced by #93147  that change effects of sanitizer from the entire project to just torch libraries, and finally allows one to reliably catch regression reported in #111189

Pull Request resolved: #111266
Approved by: https://github.com/huydhn
  • Loading branch information
malfet authored and pytorchmergebot committed Oct 14, 2023
1 parent cff8bf4 commit 6dc54fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions caffe2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,14 @@ if(BUILD_TEST)
if(USE_FBGEMM)
target_link_libraries(${test_name}_${CPU_CAPABILITY} fbgemm)
endif()
if(USE_ASAN)
if(TARGET Sanitizer::address)
target_link_libraries(${test_name}_${CPU_CAPABILITY} Sanitizer::address)
endif()
if(TARGET Sanitizer::undefined)
target_link_libraries(${test_name}_${CPU_CAPABILITY} Sanitizer::undefined)
endif()
endif()
else()
add_executable(${test_name}_${CPU_CAPABILITY} "${test_src}")
target_link_libraries(${test_name}_${CPU_CAPABILITY} torch_library gtest_main)
Expand Down
3 changes: 3 additions & 0 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,9 @@ if(USE_FBGEMM)
else()
set(FBGEMM_LIBRARY_TYPE "static" CACHE STRING "")
endif()
if(USE_ASAN)
set(USE_SANITIZER "address,undefined" CACHE STRING "-fsanitize options for FBGEMM")
endif()
add_subdirectory("${FBGEMM_SOURCE_DIR}")
set_property(TARGET fbgemm_generic PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET fbgemm_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON)
Expand Down

0 comments on commit 6dc54fe

Please sign in to comment.