Add address sanitizer build option (#389)

[ROCm/rccl commit: eea7b24058]
This commit is contained in:
Eiden Yoshida
2021-06-10 09:14:54 -06:00
کامیت شده توسط GitHub
والد 5bebcb0015
کامیت a24e180296
2فایلهای تغییر یافته به همراه18 افزوده شده و 1 حذف شده
@@ -40,6 +40,7 @@ set(AMDGPU_TARGETS "${DEFAULT_AMDGPU_TARGETS}" CACHE STRING "List of specific ma
option(BUILD_TESTS "Build test programs" OFF)
option(INSTALL_DEPENDENCIES "Force install dependencies" OFF)
option(BUILD_ADDRESS_SANITIZER "Build with address sanitizer enabled" OFF)
# parse version from Makefile NCCL_MAJOR, NCCL_MINOR, NCCL_PATCH must exist
# NCCL_SUFFIX is optional NCCL_VERSION formatting is ((X) * 1000 + (Y) * 100 +
@@ -215,6 +216,12 @@ if("${HIP_COMPILER}" MATCHES "clang")
string (REPLACE ";" " " LINK_PROPS "${link_libraries}")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -o <TARGET> ${LINK_PROPS} <LINK_FLAGS> <OBJECTS>")
endif()
if(BUILD_ADDRESS_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -shared-libasan")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -shared-libasan")
add_link_options(-fuse-ld=lld)
endif()
endif()
if("${HIP_COMPILER}" MATCHES "hcc")
+11 -1
مشاهده پرونده
@@ -18,6 +18,7 @@ function display_help()
echo " [--run_tests_all] Run all unit tests (must be built already.)"
echo " [--hcc] Build library using deprecated hcc compiler (default:hip-clang)."
echo " [--prefix] Specify custom directory to install RCCL to (default: /opt/rocm)."
echo " [--address-sanitizer] Build with address sanitizer enabled"
}
# #################################################
@@ -29,6 +30,7 @@ build_tests=false
run_tests=false
run_tests_all=false
build_release=true
build_address_sanitizer=false
install_library=false
build_hip_clang=true
clean_build=true
@@ -42,7 +44,7 @@ build_static=false
# check if we have a modern version of getopt that can handle whitespace and long parameters
getopt -T
if [[ $? -eq 4 ]]; then
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,dependencies,package_build,tests_build,run_tests_quick,static,run_tests_all,hcc,hip-clang,no_clean,prefix: --options hidptrs -- "$@")
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,dependencies,package_build,tests_build,run_tests_quick,static,run_tests_all,hcc,hip-clang,no_clean,prefix:,address-sanitizer --options hidptrs -- "$@")
else
echo "Need a new version of getopt"
exit 1
@@ -92,6 +94,9 @@ while true; do
--no_clean)
clean_build=false
shift ;;
--address-sanitizer)
build_address_sanitizer=true
shift ;;
--prefix)
install_prefix=${2}
shift 2 ;;
@@ -168,6 +173,11 @@ if [[ "${build_static}" == true ]]; then
cmake_common_options="${cmake_common_options} -DBUILD_STATIC=ON"
fi
# sanitizer
if [[ "${build_address_sanitizer}" == true ]]; then
cmake_common_options="${cmake_common_options} -DBUILD_ADDRESS_SANITIZER=ON"
fi
compiler=hipcc
if [[ "${build_hip_clang}" == false ]]; then
compiler=hcc