From bf4c7340f32c1e673e6a37b91fc65305757f52d1 Mon Sep 17 00:00:00 2001 From: zmiao Date: Tue, 7 Apr 2020 16:30:30 +0300 Subject: [build] Fix undefined behavour sanitizer (#16375) * [build] Fix integer overflow runtime error for core part Temporarily remove circle ci UBSAN build precondition * [build] Enable all of the ubsans [build] Check runtime error [build] Update UBSAN_OPTION * [build] Add UBSAN blacklist [build] Ignore system libraries [build] Ignore vendor library * [build] Fix implicit conversion runtime error in core * [build] Fix division by zero runtime error * [build] Add unfixed error to ubsan blacklist * [build] Make UBSAN halt on error Revert "Temporary remove build precondition" * [build] Fix division by zero error * [build] Make UBSAN officially work without FIXME prefix * [build] Fix implicit conversion from int64_t to uint64_t * [build] Rename style test json file name * Address review findings --- CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fdd98a41a..89096358dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,8 @@ add_library( mbgl-compiler-options INTERFACE ) +set(UBSAN_BLACKLIST ${PROJECT_SOURCE_DIR}/scripts/ubsan.blacklist) + target_compile_options( mbgl-compiler-options INTERFACE @@ -36,9 +38,16 @@ target_compile_options( $<$:-fno-optimize-sibling-calls> $<$:-fsanitize=address> $<$:-fsanitize=thread> - $<$:-fsanitize=implicit-conversion> - $<$:-fsanitize=undefined> - $<$:-fsanitize=unsigned-integer-overflow> + $<$:-fsanitize=implicit-conversion, + -fsanitize-blacklist=${UBSAN_BLACKLIST}> + $<$:-fsanitize=undefined, + -fsanitize-blacklist=${UBSAN_BLACKLIST}> + $<$:-fsanitize=unsigned-integer-overflow, + -fsanitize-blacklist=${UBSAN_BLACKLIST}> + $<$:-fsanitize=nullability, + -fsanitize-blacklist=${UBSAN_BLACKLIST}> + $<$:-fsanitize=float-divide-by-zero, + -fsanitize-blacklist=${UBSAN_BLACKLIST}> $<$,$>>:-fno-rtti> $<$,$>>:-Wall> $<$,$>>:-Wshadow> -- cgit v1.2.1