From 1941fd80f29ea7698171fb13670fe6a12a809b03 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Wed, 13 Apr 2022 11:23:03 -0700 Subject: [PATCH] Disable object-size analysis if optimization set to -O0 --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79ee3c74c9..812e9720f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,7 +178,6 @@ if ( ZEEK_SANITIZERS ) # list(APPEND _check_list "nullability-assign") # Not normally part of "undefined" # list(APPEND _check_list "nullability-return") # Not normally part of "undefined" # list(APPEND _check_list "objc-cast") # Not truly UB - list(APPEND _check_list "object-size") # list(APPEND _check_list "pointer-overflow") # Not implemented in older GCCs list(APPEND _check_list "return") list(APPEND _check_list "returns-nonnull-attribute") @@ -190,6 +189,13 @@ if ( ZEEK_SANITIZERS ) list(APPEND _check_list "vla-bound") # list(APPEND _check_list "vptr") # TODO: fix associated errors + # Clang complains if this one is defined and the optimizer is set to -O0. We + # only set that optimization level if NO_OPTIMIZATIONS is passed, so disable + # the option if that's set. + if ( NOT DEFINED ENV{NO_OPTIMIZATIONS} ) + list(APPEND _check_list "object-size") + endif () + string(REPLACE ";" "," _ub_checks "${_check_list}") set(ZEEK_SANITIZER_UB_CHECKS "${_ub_checks}" CACHE INTERNAL "" FORCE) else ()