[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 21660874 2/2: Work around a libstdc++ issue l
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 21660874 2/2: Work around a libstdc++ issue less brutally |
Date: |
Wed, 5 Oct 2022 19:49:23 -0400 (EDT) |
branch: master
commit 21660874d37298761461391ae9ea5bdb9de6e475
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Work around a libstdc++ issue less brutally
The <regex> header in libstdc++ is not UBSAN-clean when used with llvm's
libunwind. Inhibiting '-Wmaybe-uninitialized' for all unit tests that
use UBSAN, as in the last commit, was quite brutal. Instead, this commit
inhibits that warning for <regex> only, using a pragma that affects gcc
only...but without regard to UBSAN. This is not ideal, but a proposal to
add a builtin __SANITIZE_UNDEFINED__ macro:
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-09/msg01286.html
was rejected; and changing the build system to implement our own is too
much wasted work, as our time would be better spent repairing <regex>,
but that's silly because libstdc++'s implementation has such woeful
performance that it needs a wholesale replacement.
Similarly, it's hardly worthwhile to extend this "improved" workaround
to the other three object files in $(wno_maybe_uninitialized_objects),
e.g., by creating a new "regex_pragmatized" header to replace <regex>,
though it is worthwhile to avoid excluding all object files dependent on
any unit-test target.
---
compiler_gcc_warnings.make | 1 -
test_main.cpp | 8 ++++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/compiler_gcc_warnings.make b/compiler_gcc_warnings.make
index 6a82fc5a..857f29c6 100644
--- a/compiler_gcc_warnings.make
+++ b/compiler_gcc_warnings.make
@@ -266,7 +266,6 @@ $(wno_sign_conv_objects): gcc_common_extra_warnings +=
-Wno-sign-conversion
# For lmi, this seems to affect only UBSAN builds.
wno_maybe_uninitialized_objects := \
- $(unit_test_targets) \
my_prod.o \
pdf_command_wx.o \
wx_test_about_version.o \
diff --git a/test_main.cpp b/test_main.cpp
index f611c414..a0876c2d 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -67,7 +67,15 @@
#include <atomic>
#include <iostream>
#include <ostream>
+// Avoid UBSAN clash with libstdc++'s <regex>.
+#if defined LMI_GCC
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif // defined LMI_GCC
#include <regex>
+#if defined LMI_GCC
+# pragma GCC diagnostic pop
+#endif // defined LMI_GCC
#include <stdexcept>
#include <string>