[libvirt] [PATCH 0/2] Fix building with clang (again)

*** SOME VERY RANDOM BLURB HERE *** Martin Kletzander (2): Skip pdwtags-related tests when compiling with clang Fix build with clang src/Makefile.am | 4 +++- tests/qemuxml2argvmock.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) -- 2.7.3

The reason for this is that clang uses different ordering of dwarves data in the object files, so our diff fails even though everything is correct. Workaround this by skipping such tests when using clang. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index d57d30361fa7..255db87af7dc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -485,7 +485,7 @@ struct_prefix = ($(libs_prefix)|$(other_prefix)) # the newest of the two, in case configure options changed and a stale # file is left around from an earlier build. PDWTAGS = \ - $(AM_V_GEN)if (pdwtags --help) > /dev/null 2>&1; then \ + $(AM_V_GEN)if (pdwtags --help && ! $(CC) --version | grep -q clang) >/dev/null 2>&1; then \ o=`ls -t $(<:.lo=.$(OBJEXT)) \ $(subst /,/.libs/,$(<:.lo=.$(OBJEXT))) \ 2>/dev/null | sed -n 1p`; \ @@ -522,6 +522,8 @@ PDWTAGS = \ case $$? in 8) rm -f $(@F)-t?; exit 0;; 0) ;; *) exit 1;; esac;\ diff -u $(@)s $(@F)-t3; st=$$?; rm -f $(@F)-t?; exit $$st; \ fi; \ + elif (pdwtags --help) >/dev/null 2>&1; then \ + echo 'WARNING: Skipping the $@ test due to its incompatibility with clang' >&2; \ else \ echo 'WARNING: you lack pdwtags; skipping the $@ test' >&2; \ echo 'WARNING: install the dwarves package to get pdwtags' >&2; \ -- 2.7.3

Even though this is, technically speaking, a build-breaker fix, different version of this was posted before [1] and not accepted (although neither rejected), so I'm sending this as another way of approaching it. [1] https://www.redhat.com/archives/libvir-list/2015-March/msg00203.html Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- tests/qemuxml2argvmock.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 8426108b29ed..5667f34f1267 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -62,6 +62,34 @@ virNumaNodeIsAvailable(int node) { return node >= 0 && node <= virNumaGetMaxNode(); } + +/* This is a copy-paste of the same function from src/util/virnuma.c. + * the reason for this is that some compilers might inline the + * function above (virNumaNodeIsAvailable) and hence mocking that + * function is pointless from our test suite's POV. This is a + * (hopefully) temporary workaround until someone finds out how to + * disable inlining of exported functions with -O2 on clang. The + * other option would be disabling inlining of that particular + * function which was proposed but did not come to a conclusion. + */ +bool +virNumaNodesetIsAvailable(virBitmapPtr nodeset) +{ + ssize_t bit = -1; + + if (!nodeset) + return true; + + while ((bit = virBitmapNextSetBit(nodeset, bit)) >= 0) { + if (virNumaNodeIsAvailable(bit)) + continue; + + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("NUMA node %zd is unavailable"), bit); + return false; + } + return true; +} #endif /* WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET */ char * -- 2.7.3

On Fri, 2016-03-11 at 16:36 +0100, Martin Kletzander wrote:
Even though this is, technically speaking, a build-breaker fix, different version of this was posted before [1] and not accepted (although neither rejected), so I'm sending this as another way of approaching it. [1] https://www.redhat.com/archives/libvir-list/2015-March/msg00203.html Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- tests/qemuxml2argvmock.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 8426108b29ed..5667f34f1267 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -62,6 +62,34 @@ virNumaNodeIsAvailable(int node) { return node >= 0 && node <= virNumaGetMaxNode(); } + +/* This is a copy-paste of the same function from src/util/virnuma.c. + * the reason for this is that some compilers might inline the + * function above (virNumaNodeIsAvailable) and hence mocking that + * function is pointless from our test suite's POV. This is a + * (hopefully) temporary workaround until someone finds out how to + * disable inlining of exported functions with -O2 on clang. The + * other option would be disabling inlining of that particular + * function which was proposed but did not come to a conclusion. + */
I'd rather go the __attribute__((noinline)) way, because I'm very concerned that the two copies of virNumaNodesetIsAvailable() will get out of sync at some point. If that happened, our tests will continue to pass just fine even though the code shipped in the library is potentially broken. Of course if someone can come up with a proper fix, that's even better :) Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team

On Fri, Mar 11, 2016 at 05:20:35PM +0100, Andrea Bolognani wrote:
On Fri, 2016-03-11 at 16:36 +0100, Martin Kletzander wrote:
Even though this is, technically speaking, a build-breaker fix, different version of this was posted before [1] and not accepted (although neither rejected), so I'm sending this as another way of approaching it. [1] https://www.redhat.com/archives/libvir-list/2015-March/msg00203.html Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- tests/qemuxml2argvmock.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 8426108b29ed..5667f34f1267 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -62,6 +62,34 @@ virNumaNodeIsAvailable(int node) { return node >= 0 && node <= virNumaGetMaxNode(); } + +/* This is a copy-paste of the same function from src/util/virnuma.c. + * the reason for this is that some compilers might inline the + * function above (virNumaNodeIsAvailable) and hence mocking that + * function is pointless from our test suite's POV. This is a + * (hopefully) temporary workaround until someone finds out how to + * disable inlining of exported functions with -O2 on clang. The + * other option would be disabling inlining of that particular + * function which was proposed but did not come to a conclusion. + */
I'd rather go the __attribute__((noinline)) way, because I'm very concerned that the two copies of virNumaNodesetIsAvailable() will get out of sync at some point. If that happened, our tests will continue to pass just fine even though the code shipped in the library is potentially broken.
I don't want this to sound like I'm against that approach. If anyone agrees, then let's push Jan's patch and we're good to go :) I just wanted to show another look at things.
Of course if someone can come up with a proper fix, that's even better :)
That would be, but... Anyway, thanks for your opinion, we'll see how this goes. Martin

On Fri, Mar 11, 2016 at 04:36:26PM +0100, Martin Kletzander wrote:
*** SOME VERY RANDOM BLURB HERE ***
Martin Kletzander (2): Skip pdwtags-related tests when compiling with clang Fix build with clang
SNACK, will sent v2 that doesn't break syntax-check O:-)
src/Makefile.am | 4 +++- tests/qemuxml2argvmock.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-)
-- 2.7.3
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Andrea Bolognani
-
Martin Kletzander