For some older CLang (or in combination with !intel arch) the
-fsemantic-interposition might be not present. But in that case,
we still want our mocking in test suite to work properly. Disable
optimizations as that seems to be the only way.
Also, don't forget to drop this when FreeBSD 11 and macOS 12 are
dropped.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
This still doesn't work when somebody overrides CFLAGS as those are
placed AFTER our supported_cc_flags:
$ export CFLAGS="-O2 -ggdb"
$ meson setup _build
$ ninja -v -C _build/
[1/1202] clang ... -O2 -g ... -O0 -O2 -ggdb -fPIC ... -c ../src/util/glibcompat.c
meson.build | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/meson.build b/meson.build
index a0682e8d0b..249505d474 100644
--- a/meson.build
+++ b/meson.build
@@ -492,6 +492,13 @@ if get_option('warning_level') == '2'
endif
endif
+
+if cc.get_id() == 'clang' and not
supported_cc_flags.contains('-fsemantic-interposition')
+ # If CLang is old enough to not support -fsemantic-interposition
+ # then this is our best bet to make mocking in tests working properly.
+ supported_cc_flags += [ '-O0' ]
+endif
+
add_project_arguments(supported_cc_flags, language: 'c')
if cc.has_argument('-Wsuggest-attribute=format')
--
2.39.2