From 6646909eb0b08af2609b23d0b65d24d64c8468fe Mon Sep 17 00:00:00 2001 From: silverqx Date: Sat, 28 May 2022 18:01:26 +0200 Subject: [PATCH] added Clang UBSan support - allow to enable UBSan with the CONFIG+=ubsan config with qmake - added UBSan.supp config to suppress Qt's errors, can be enabled using the UBSAN_OPTIONS=suppressions=/UBSan.supp env. variable --- qmake/unixconf.pri | 21 +++++++++++++++++++++ tools/configs/UBSan.supp | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 tools/configs/UBSan.supp diff --git a/qmake/unixconf.pri b/qmake/unixconf.pri index de5c5f13d..51caf813f 100644 --- a/qmake/unixconf.pri +++ b/qmake/unixconf.pri @@ -41,3 +41,24 @@ QMAKE_CXXFLAGS_WARN_ON *= \ # Clang 12 still doesn't support -Wstrict-null-sentinel !clang: QMAKE_CXXFLAGS_WARN_ON *= -Wstrict-null-sentinel + +# Allow to enable UBSan with Clang +clang:ubsan: { + QMAKE_CXXFLAGS += -O1 + + QMAKE_CXXFLAGS *= \ + -fsanitize=undefined \ + -fsanitize=nullability \ + -fsanitize=float-divide-by-zero \ + -fsanitize=unsigned-integer-overflow \ + -fsanitize=implicit-conversion \ + -fsanitize=local-bounds \ + + QMAKE_LFLAGS *= \ + -fsanitize=undefined \ + -fsanitize=nullability \ + -fsanitize=float-divide-by-zero \ + -fsanitize=unsigned-integer-overflow \ + -fsanitize=implicit-conversion \ + -fsanitize=local-bounds +} diff --git a/tools/configs/UBSan.supp b/tools/configs/UBSan.supp new file mode 100644 index 000000000..ee2b44006 --- /dev/null +++ b/tools/configs/UBSan.supp @@ -0,0 +1,2 @@ +implicit-integer-sign-change:qarraydata.h +unsigned-integer-overflow:qhashfunctions.h