summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzmiao <miao.zhao@mapbox.com>2020-04-01 22:46:34 +0300
committerzmiao <miao.zhao@mapbox.com>2020-04-03 12:32:58 +0300
commitba23e027189f748ac6c812e9f7ab5219fe79bc6d (patch)
tree23387eb1f46de387c9c1fa6ee03fc5dee401c611
parent7e239b88341e48d5a158a1b8936104b989343bf6 (diff)
downloadqtlocation-mapboxgl-ba23e027189f748ac6c812e9f7ab5219fe79bc6d.tar.gz
[build] Add UBSAN blacklist
[build] Ignore system libraries [build] Ignore vendor library
-rw-r--r--CMakeLists.txt17
-rw-r--r--scripts/ubsan.blacklist25
2 files changed, 37 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3f66c01d2f..8367802148 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,8 @@ add_library(
mbgl-compiler-options INTERFACE
)
+set(UBSAN_BLACKLIST ${PROJECT_SOURCE_DIR}/scripts/ubsan.blacklist)
+
target_compile_options(
mbgl-compiler-options
INTERFACE
@@ -35,11 +37,16 @@ target_compile_options(
$<$<BOOL:${MBGL_WITH_SANITIZER}>:-fno-optimize-sibling-calls>
$<$<STREQUAL:${MBGL_WITH_SANITIZER},address>:-fsanitize=address>
$<$<STREQUAL:${MBGL_WITH_SANITIZER},thread>:-fsanitize=thread>
- $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=implicit-conversion>
- $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=undefined>
- $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=unsigned-integer-overflow>
- $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=nullability>
- $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=float-divide-by-zero>
+ $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=implicit-conversion,
+ -fsanitize-blacklist=${UBSAN_BLACKLIST}>
+ $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=undefined,
+ -fsanitize-blacklist=${UBSAN_BLACKLIST}>
+ $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=unsigned-integer-overflow,
+ -fsanitize-blacklist=${UBSAN_BLACKLIST}>
+ $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=nullability,
+ -fsanitize-blacklist=${UBSAN_BLACKLIST}>
+ $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=float-divide-by-zero,
+ -fsanitize-blacklist=${UBSAN_BLACKLIST}>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<BOOL:${MBGL_WITH_RTTI}>>>:-fno-rtti>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wall>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wshadow>
diff --git a/scripts/ubsan.blacklist b/scripts/ubsan.blacklist
new file mode 100644
index 0000000000..9934662eb2
--- /dev/null
+++ b/scripts/ubsan.blacklist
@@ -0,0 +1,25 @@
+#############################################################################
+# Ignore system libraries.
+src:*/usr/*
+
+#############################################################################
+# Mostly hash functions where integer overflow is OK.
+src:*/mbgl/util/hash.hpp
+
+#############################################################################
+# vendor libs
+
+# unsigned integer overflow: unsigned interger index in for loop
+src:*/vendor/earcut.hpp/include/mapbox/earcut.hpp
+
+# unsigned integer overflow: hash function: str_hash
+src:*/vendor/eternal/*/eternal.hpp
+
+# unsigned integer overflow
+src: */vendor/*/rapidjson/include/rapidjson/reader.h
+
+# Boost bug: Implicit conversion
+src:*/include/boost/locale/utf.hpp
+
+# Boost bug: unsigned integer overflow
+src:*/include/boost/crc.hpp \ No newline at end of file