lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master fe203b1e 4/8: Use undefined-behavior sanitize


From: Greg Chicares
Subject: [lmi-commits] [lmi] master fe203b1e 4/8: Use undefined-behavior sanitizer
Date: Mon, 6 Jun 2022 18:40:33 -0400 (EDT)

branch: master
commit fe203b1e792a11d02b8552ec86eed0a095c14422
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Use undefined-behavior sanitizer
    
    Incidentally renamed /gprof_flag/analyzer_flag/ so that both of those
    code-analysis tools can share a single flag. It wouldn't make sense to
    use them both together.
---
 objects.make   | 10 +++++-----
 workhorse.make | 16 ++++++++++++++--
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/objects.make b/objects.make
index f5a5a211..9af29c4e 100644
--- a/objects.make
+++ b/objects.make
@@ -352,14 +352,14 @@ endif
 
 # Override this variable to exclude tests that are inappropriate in
 # context--e.g., tests that don't even compile with a particular
-# toolchain. For example:
-#
-# ifeq (foobar,$(build_type))
-#   excluded_unit_test_targets += calendar_date_test
-# endif
+# toolchain.
 
 excluded_unit_test_targets :=
 
+ifeq (ubsan,$(findstring ubsan,$(build_type)))
+  excluded_unit_test_targets += loads_test mortality_rates_test
+endif
+
 unit_test_targets := \
   account_value_test \
   actuarial_table_test \
diff --git a/workhorse.make b/workhorse.make
index b4ebe75a..382b1712 100644
--- a/workhorse.make
+++ b/workhorse.make
@@ -686,6 +686,16 @@ CXX_WARNINGS = \
 #  - gprof
 #  - libstdc++ debugging macros
 
+# Options for undefined-behavior sanitizer.
+
+ubsan_options := \
+  -fsanitize=undefined \
+  -Wno-duplicated-branches \
+  -fno-omit-frame-pointer \
+  -fno-var-tracking \
+  -fno-var-tracking-assignments \
+  -O3 \
+
 # libstdc++ debugging macros
 
 every_libstdcxx_warning_macro := \
@@ -700,7 +710,9 @@ test_targets := unit_tests cgi_tests cli_tests
 
 ifeq (gprof,$(findstring gprof,$(build_type)))
   optimization_flag := -O0 -fno-omit-frame-pointer
-  gprof_flag := -pg
+  analyzer_flag := -pg
+else ifeq (ubsan,$(findstring ubsan,$(build_type)))
+  analyzer_flag := $(ubsan_options)
 else ifeq (safestdlib,$(findstring safestdlib,$(build_type)))
   optimization_flag := -O0 -fno-omit-frame-pointer
   libstdcxx_warning_macros := $(every_libstdcxx_warning_macro)
@@ -774,7 +786,7 @@ endif
 #   https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#DOCF1
 # Yet another is 'debug_flag'.
 
-c_l_flags := $(debug_flag) $(gprof_flag)
+c_l_flags := $(debug_flag) $(analyzer_flag)
 
 ifeq (x86_64-pc-linux-gnu,$(LMI_TRIPLET))
   c_l_flags += -fPIC



reply via email to

[Prev in Thread] Current Thread [Next in Thread]