1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Sat, 6 Sep 2025 12:54:00 +0100
Subject: tests/generated: Disable optimizations to avoid false positives
The code of the generated tests are fairly simple, and the compiler may
inline or optimize away some of the calls of the functions under test,
causing false positives.
Unfortunately, there's nothing we can do about intercepting inlined
functions (and much less calls that are optimized away), that's an
intrinsic limitation of the library and nothing new. And as compilers
change, the optimizations may cause different false positives in our
tests.
This happened in https://bugs.debian.org/1097184 where the malloc() call
was being optimized away by `gcc-15 -O2`, and causing a new false
positive.
This patch fixes/works around the problem by passing `-O0` to disable
optimizations in the compilation of the generated tests.
Ideally we would do something more targeted, but for now this is good
enough to prevent most of the problems.
---
tests/generated/Makefile | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/generated/Makefile b/tests/generated/Makefile
index 05e7498..7018801 100644
--- a/tests/generated/Makefile
+++ b/tests/generated/Makefile
@@ -11,6 +11,12 @@ ifdef PROFILE
ALL_CFLAGS += -g -pg -fprofile-arcs -ftest-coverage
endif
+# Note we pass -O0 (after $CFLAGS) to explicitly disable optimizations;
+# otherwise, the compiler may inline or optimize away some of the functions
+# under test, causing false positives.
+# See https://bugs.debian.org/1097184 for an example.
+ALL_CFLAGS += -O0
+
ifneq ($(V), 1)
NICE_CC = @echo " CC $@"; $(CC)
NICE_RUN = @echo " RUN $<"; \
|