On Tue, Mar 21, 2023 at 04:11:33PM +0100, Michal Privoznik wrote: > 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@xxxxxxxxxx> > --- > > 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 I don't like the idea of forcing -O0 for the production builds, just to work around the problem of our broken tests. Can we approach it from the opposite POV and disable building of tests, if we see meson optimization level is > 0 eg something roughly like this: with_tests = true if cc.get_id() == 'clang' and not supported_cc_flags.contains('-fsemantic-interposition') and get_option('optimization') != 0 with_tests = false endif if with_tests subdir('tests') endif So people can choose to have tests work or not With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|