[libvirt] libvirt cannot be built with -Werror on RHEL6RC(x86_64)

Wen Congyang wency at cn.fujitsu.com
Thu May 12 09:55:43 UTC 2011


At 05/12/2011 02:40 PM, Wen Congyang Write:
> My steps to build libvirt:
> 1. # export CFLAGS=-Werror
> 2. # ./autogen.sh
> 3. # make dist && rpmbuild --nodeps --define "_sourcedir `pwd`" -ba libvirt.spec
>    ...
>    checking for msgmerge... /usr/bin/msgmerge
>    checking whether NLS is requested... yes
>    checking for GNU gettext in libc... no
>    checking for iconv... yes
>    checking for GNU gettext in libintl... no
>    checking whether to use NLS... no
>    checking for UDEV... yes
>    checking for PCIACCESS... yes
>    ...
>    + rm -f /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64/etc/libvirt/qemu/networks/default.xml
>    + rm -f /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64/etc/libvirt/qemu/networks/autostart/default.xml
>    + sed -i -e '/<uuid>/d' /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64/usr/share/libvirt/networks/default.xml
>    + /usr/lib/rpm/find-lang.sh /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64 libvirt
>    No translations found for libvirt in /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64
>    error: Bad exit status from /var/tmp/rpm-tmp.nSgCNo (%install)
> 
> 
>    RPM build errors:
>        Bad exit status from /var/tmp/rpm-tmp.nSgCNo (%install)
> 
> 4. # cat config.log
>    ...
> configure:82567: checking for GNU gettext in libc
> configure:82596: gcc -std=gnu99 -o conftest -Werror   conftest.c -ldl  >&5
> cc1: warnings being treated as errors
> conftest.c: In function 'main':
> conftest.c:468: error: cast from pointer to integer of different size
> configure:82603: $? = 1
> configure: failed program was:
> ...
> | int
> | main ()
> | {
> | bindtextdomain ("", "");
> | return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_domain_bindings
> |   ;
> |   return 0;
> | }

This test program is generated according to gettext.m4.
It's a bug of old version gettext, and it's fixed in gettext-0.14.4.

I modify configure.ac to require gettext-0.14.4, build libvirt
with -Werror, and receive the following error messages:
RPM build errors:
    File not found: /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64/etc/libvirt/lxc.conf
    File not found: /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64/var/run/libvirt/lxc
    File not found: /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64/var/lib/libvirt/lxc
    File not found: /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64/usr/share/augeas/lenses/libvirtd_lxc.aug
    File not found: /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64/usr/share/augeas/lenses/tests/test_libvirtd_lxc.aug
    File not found: /home/wency/rpmbuild/BUILDROOT/libvirt-0.9.1-1.el6.x86_64/usr/libexec/libvirt_lxc

The following patch can fix the problem:

>From 95a02c3f6c594a623c01183067a1abd0d925d492 Mon Sep 17 00:00:00 2001
From: Wen Congyang <wency at cn.fujitsu.com>
Date: Thu, 12 May 2011 17:51:21 +0800
Subject: [PATCH] build: fix building error with -Werror

---
 configure.ac |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 71c4968..0d369ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -638,7 +638,10 @@ if test "$with_libvirtd" = "no" ; then
   with_lxc=no
 fi
 if test "$with_lxc" = "yes" || test "$with_lxc" = "check"; then
-    AC_TRY_LINK([#define _GNU_SOURCE
+    AC_TRY_LINK([
+        #ifndef _GNU_SOURCE
+        #define _GNU_SOURCE
+        #endif
         #include <sched.h>
     ], [
         unshare (1);
@@ -1981,7 +1984,7 @@ dnl Enable building libvirtd?
 AM_CONDITIONAL([WITH_LIBVIRTD],[test "x$with_libvirtd" = "xyes"])
 
 dnl Check for gettext
-AM_GNU_GETTEXT_VERSION([0.14.1])
+AM_GNU_GETTEXT_VERSION([0.14.4])
 AM_GNU_GETTEXT([external])
 dnl Since we're using such an old version of gettext, we must also define
 dnl this symbol, in order to make the autopoint-supplied Makefile.in.in
-- 
1.7.1



> configure:82623: result: no
> ...
> 
> 5. # cat po/Makefile.in.in
> ...
> install: install-exec install-data
> install-exec:
> install-data: install-data- at USE_NLS@
>         if test "$(PACKAGE)" = "gettext-tools"; then \
>           $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
>           for file in $(DISTFILES.common) Makevars.template; do \
>             $(INSTALL_DATA) $(srcdir)/$$file \
>                             $(DESTDIR)$(gettextsrcdir)/$$file; \
>           done; \
>           for file in Makevars; do \
>             rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
>           done; \
>         else \
>           : ; \
>         fi
> install-data-no: all
> install-data-yes: all
>         $(mkinstalldirs) $(DESTDIR)$(datadir)
> ...
> gettext() returns char *, and we try to convert it to int. The size of pointer
> and int is different, and gcc will give a warning. I build it with -Werror, so
> the test program can not be built, and NLS is disabled. But We only install
> translations when NLS is enabled.
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
> 




More information about the libvir-list mailing list