[PATCH 0/2] Work around broken clang. Again.

Michal Prívozník mprivozn at redhat.com
Thu Mar 16 04:18:10 UTC 2023


On 3/15/23 20:10, Michal Privoznik wrote:
>

Another option might be to just turn off optimization for the whole
virnuma.c file when compiling with clang. Except not really, because
meson deliberately doesn't allow that:

  https://github.com/mesonbuild/meson/issues/1367

On the other hand, that would solve only the problem at hand and not the
root cause. So maybe we need a bigger hammer after all. Something among
these lines:



diff --git i/meson.build w/meson.build
index 319ed790f9..d018693ca0 100644
--- i/meson.build
+++ w/meson.build
@@ -206,6 +206,12 @@ libvirt_lib_version = '@0 at .@1 at .@2@'.format(libvirt_so_version, libvirt_age, libv
 cc = meson.get_compiler('c')
 cc_flags = []
 
+compiler_warn = 0
+if cc.get_id() == 'clang'
+  cc_flags += [ '-O0' ]
+  compiler_warn = 1
+endif
+
 git_werror = get_option('git_werror')
 if (git_werror.enabled() or git_werror.auto()) and git and not get_option('werror')
   cc_flags += [ '-Werror' ]
@@ -2268,3 +2274,7 @@ if conf.has('WITH_QEMU')
   }
   summary(priv_summary, section: 'Privileges')
 endif
+
+if compiler_warn != 0
+  summary({'compiler': 'broken !!! Forcibly turning off optimizations. Go unbreak your compiler !!!'}, section: 'Compiler')
+endif



Of course, we could do more clever check (from my example in cover
letter whether Y() calls X()), but I don't know how to write that in
meson. But since we officially aim on GCC an Clang and only the latter
is broken I guess checking for compiler's ID is just fine.

Michal



More information about the libvir-list mailing list