diff options
Diffstat (limited to 'packaging/0001-Fix-build-with-Asan-15372.patch')
-rw-r--r-- | packaging/0001-Fix-build-with-Asan-15372.patch | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/packaging/0001-Fix-build-with-Asan-15372.patch b/packaging/0001-Fix-build-with-Asan-15372.patch new file mode 100644 index 0000000000..0163c78f0c --- /dev/null +++ b/packaging/0001-Fix-build-with-Asan-15372.patch @@ -0,0 +1,121 @@ +From 1cf30166f8b1489ff3c9958e7ad21f097aa5065e Mon Sep 17 00:00:00 2001 +From: Konstantin Baladurin <k.baladurin@partner.samsung.com> +Date: Sat, 9 Dec 2017 13:57:20 +0300 +Subject: [PATCH 1/4] Fix build with Asan (#15372) + +- verify_dependencies: disable checking dependencies for Asan build + because in this case shared libraries can have undefined symbols + (if static linking with compiler-rt is used). + +- enablesanitizers.sh: remove excess quotes for ASAN_OPTIONS and + UBSAN_OPTIONS environment variable because otherwise Asan cannot + parse flags. Also doesn't export ASAN_SYMBOLIZER_PATH for clang > 3.6. +--- + enablesanitizers.sh | 36 +++++++++++++++++++++++++++--------- + functions.cmake | 16 +++++++++++++++- + 2 files changed, 42 insertions(+), 10 deletions(-) + +diff --git a/enablesanitizers.sh b/enablesanitizers.sh +index 70555aa..2937b0b 100755 +--- a/enablesanitizers.sh ++++ b/enablesanitizers.sh +@@ -26,6 +26,7 @@ else + __EnableLSan=0 + __TurnOff=0 + __Options= ++ __ExportSymbolizerPath=1 + + for i in "$@" + do +@@ -60,6 +61,17 @@ else + clang3.7) + __ClangMajorVersion=3 + __ClangMinorVersion=7 ++ __ExportSymbolizerPath=0 ++ ;; ++ clang3.8) ++ __ClangMajorVersion=3 ++ __ClangMinorVersion=8 ++ __ExportSymbolizerPath=0 ++ ;; ++ clang3.9) ++ __ClangMajorVersion=3 ++ __ClangMinorVersion=9 ++ __ExportSymbolizerPath=0 + ;; + *) + echo "Unknown arg: $i" +@@ -83,7 +95,9 @@ else + __Options="$__Options ubsan" + fi + if [ $__EnableLSan == 1 ]; then +- ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks" ++ ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks=1" ++ else ++ ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks=0" + fi + + # passed to build.sh +@@ -92,18 +106,22 @@ else + echo "Setting DEBUG_SANITIZERS=$DEBUG_SANITIZERS" + + # used by ASan at run-time +- ASAN_OPTIONS="\"$ASAN_OPTIONS\"" + export ASAN_OPTIONS +- echo "Setting ASAN_OPTIONS=$ASAN_OPTIONS" ++ echo "Setting ASAN_OPTIONS=\"$ASAN_OPTIONS\"" + +- UBSAN_OPTIONS="\"$UBSAN_OPTIONS\"" + export UBSAN_OPTIONS +- echo "Setting UBSAN_OPTIONS=$UBSAN_OPTIONS" ++ echo "Setting UBSAN_OPTIONS=\"$UBSAN_OPTIONS\"" + +- # used by ASan at run-time +- ASAN_SYMBOLIZER_PATH="/usr/bin/llvm-symbolizer-$__ClangMajorVersion.$__ClangMinorVersion" +- export ASAN_SYMBOLIZER_PATH +- echo "Setting ASAN_SYMBOLIZER_PATH=$ASAN_SYMBOLIZER_PATH" ++ # for compiler-rt > 3.6 Asan check that binary name is 'llvm-symbolizer', 'addr2line' or ++ # 'atos' (for Darwin) otherwise it returns error ++ if [ $__ExportSymbolizerPath == 1 ]; then ++ # used by ASan at run-time ++ ASAN_SYMBOLIZER_PATH="/usr/bin/llvm-symbolizer-$__ClangMajorVersion.$__ClangMinorVersion" ++ export ASAN_SYMBOLIZER_PATH ++ echo "Setting ASAN_SYMBOLIZER_PATH=$ASAN_SYMBOLIZER_PATH" ++ else ++ unset ASAN_SYMBOLIZER_PATH ++ fi + echo "Done. You can now run: build.sh Debug clang$__ClangMajorVersion.$__ClangMinorVersion" + fi + +diff --git a/functions.cmake b/functions.cmake +index cf4d08f..50e4bbe 100644 +--- a/functions.cmake ++++ b/functions.cmake +@@ -223,9 +223,23 @@ function(_install) + endfunction() + + function(verify_dependencies targetName errorMessage) ++ set(SANITIZER_BUILD OFF) ++ ++ if (CLR_CMAKE_PLATFORM_UNIX) ++ if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED) ++ string(FIND "$ENV{DEBUG_SANITIZERS}" "asan" __ASAN_POS) ++ string(FIND "$ENV{DEBUG_SANITIZERS}" "ubsan" __UBSAN_POS) ++ if ((${__ASAN_POS} GREATER -1) OR (${__UBSAN_POS} GREATER -1)) ++ set(SANITIZER_BUILD ON) ++ endif() ++ endif() ++ endif() ++ + # We don't need to verify dependencies on OSX, since missing dependencies + # result in link error over there. +- if (NOT CLR_CMAKE_PLATFORM_DARWIN AND NOT CLR_CMAKE_PLATFORM_ANDROID) ++ # Also don't verify dependencies for Asan build because in this case shared ++ # libraries can contain undefined symbols ++ if (NOT CLR_CMAKE_PLATFORM_DARWIN AND NOT CLR_CMAKE_PLATFORM_ANDROID AND NOT SANITIZER_BUILD) + add_custom_command( + TARGET ${targetName} + POST_BUILD +-- +2.7.4 + |