Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 640494

Summary: app-emulation/libguestfs-1.36.5 fails src_compile with USE=test ( -Werror=expansion-to-defined )
Product: Gentoo Linux Reporter: Kent Fredric (IRC: kent\n) (RETIRED) <kentnl>
Component: Current packagesAssignee: Maxim Koltsov (RETIRED) <maksbotan>
Status: RESOLVED FIXED    
Severity: normal CC: rich
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=631422
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: libguestfs-1.36.5:20171210-120109.log
cleanup.i.gz

Description Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2017-12-10 12:22:48 UTC
Created attachment 509236 [details]
libguestfs-1.36.5:20171210-120109.log

This is due to:

$(use_enable test werror)

+ the warnings you can also see in bug #631422 which are normally non-fatal.

This looks to be GCC 7.2 related, or 17.0 profile related.


 * Package:    app-emulation/libguestfs-1.36.5
 * Repository: gentoo
 * Maintainer: maksbotan@gentoo.org rich@annexia.org
 * USE:        abi_x86_64 amd64 elibc_glibc fuse kernel_linux perl python_single_target_python3_5 python_targets_python2_7 python_targets_python3_5 test userland_GNU
 * FEATURES:   ccache preserve-libs sandbox test userpriv usersandbox


libtool: compile:  x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../.. -DGUESTFS_WARN_DEPRECATED=1 -DGUESTFS_PRIVATE=1 -I../../gnulib/lib -I../../gnulib/lib -I../../lib -I../../lib -fno-common -W -Wabi -Waddress -Waggressive-loop-optimizations -Wall -Wattributes -Wbad-function-cast -Wbool-compare -Wbuiltin-macro-redefined -Wchar-subscripts -Wchkp -Wclobbered -Wcomment -Wcomments -Wcoverage-mismatch -Wcpp -Wdate-time -Wdeprecated -Wdeprecated-declarations -Wdesignated-init -Wdisabled-optimization -Wdiscarded-array-qualifiers -Wdiscarded-qualifiers -Wdiv-by-zero -Wdouble-promotion -Wduplicated-cond -Wempty-body -Wendif-labels -Wenum-compare -Wextra -Wformat-contains-nul -Wformat-extra-args -Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat-y2k -Wformat-zero-length -Wframe-address -Wfree-nonheap-object -Whsa -Wignored-attributes -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wincompatible-pointer-types -Winit-self -Wint-conversion -Wint-to-pointer-cast -Winvalid-memory-model -Winvalid-pch -Wjump-misses-init -Wlogical-not-parentheses -Wlogical-op -Wmain -Wmaybe-uninitialized -Wmemset-transposed-args -Wmisleading-indentation -Wmissing-braces -Wmissing-declarations -Wmissing-field-initializers -Wmissing-include-dirs -Wmissing-parameter-type -Wmissing-prototypes -Wmultichar -Wnarrowing -Wnested-externs -Wnonnull -Wnonnull-compare -Wnull-dereference -Wodr -Wold-style-declaration -Wold-style-definition -Wopenmp-simd -Woverflow -Woverride-init
-Wpacked-bitfield-compat -Wparentheses -Wpointer-arith -Wpointer-sign -Wpointer-to-int-cast -Wpragmas -Wreturn-local-addr -Wreturn-type -Wscalar-storage-order -Wsequence-point -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value -Wsizeof-array-argument -Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-overflow -Wstrict-prototypes -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wswitch -Wswitch-bool -Wsync-nand -Wtautological-compare -Wtrampolines -Wtrigraphs -Wtype-limits -Wuninitialized -Wunknown-pragmas -Wunused -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-macros -Wunused-parameter -Wunused-result -Wunused-value -Wunused-variable -Wvarargs -Wvariadic-macros -Wvector-operation-performance -Wvolatile-register-var -Wwrite-strings -Warray-bounds=2 -Wnormalized=nfc -Wshift-overflow=2 -Wunused-const-variable=2 -Wno-unused-parameter -Wno-missing-field-initializers -fdiagnostics-show-option -Wframe-larger-than=5000 -Wstack-usage=10000 -Werror -fvisibility=hidden -I/usr/include/libxml2 -march=native -mtune=native -O2 -pipe -fno-strict-overflow -Wno-strict-overflow -c structs-cleanup.c  -fPIC -DPIC -o .libs/libutils_la-structs-cleanup.o
In file included from cleanup.c:59:0:
../../config.h:92:53: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
 #if __OPTIMIZE__ && (! defined (_FORTIFY_SOURCE) || _FORTIFY_SOURCE < 2)
                                                     ^~~~~~~~~~~~~~~
../../config.h:2955:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
             || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
                                                ^~~~~~~~~~~~~~~
In file included from structs-print.c:24:0:
../../config.h:92:53: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
 #if __OPTIMIZE__ && (! defined (_FORTIFY_SOURCE) || _FORTIFY_SOURCE < 2)
                                                     ^~~~~~~~~~~~~~~
../../config.h:2955:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
             || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
                                                ^~~~~~~~~~~~~~~
In file included from structs-cleanup.c:24:0:
../../config.h:92:53: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
 #if __OPTIMIZE__ && (! defined (_FORTIFY_SOURCE) || _FORTIFY_SOURCE < 2)
                                                     ^~~~~~~~~~~~~~~
../../config.h:2955:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
             || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
                                                ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
make[3]: *** [Makefile:1761: libutils_la-cleanup.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [Makefile:1775: libutils_la-structs-print.lo] Error 1
cc1: all warnings being treated as errors


emerge --info =app-emulation/libguestfs-1.36.5
Portage 2.3.13 (python 2.7.14-final-0, default/linux/amd64/17.0/no-multilib, gcc-7.2.0, glibc-2.25-r9, 4.9.6-gentoo-r1 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.9.6-gentoo-r1-x86_64-Intel-R-_Core-TM-2_Duo_CPU_E6750_@_2.66GHz-with-gentoo-2.4.1
KiB Mem:     2042732 total,    210300 free
KiB Swap:   18588764 total,  18494816 free
Head commit of repository gentoo: d65c0d4499c1f74ec423d358285d27589cd32cd5

sh bash 4.3_p48-r1
ld GNU ld (Gentoo 2.29.1 p3) 2.29.1
ccache version 3.2.4 [enabled]
app-shells/bash:          4.3_p48-r1::gentoo
dev-lang/perl:            5.26.1-r1::gentoo
dev-lang/python:          2.7.14::gentoo, 3.5.4::gentoo
dev-util/ccache:          3.2.4::gentoo
dev-util/cmake:           3.8.2::gentoo
sys-apps/baselayout:      2.4.1-r2::gentoo
sys-apps/openrc:          0.34.11::gentoo
sys-apps/sandbox:         2.10-r4::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.15.1-r1::gentoo
sys-devel/binutils:       2.29.1-r1::gentoo
sys-devel/gcc:            7.2.0::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.25-r9::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: git
    sync-uri: https://github.com/gentoo/gentoo.git
    priority: -1000
Comment 1 Richard Jones 2017-12-10 13:04:16 UTC
Meta-point: Is it possible for Gentoo to move to a newer version of libguestfs along the stable branch?  Newest is 1.36.11 currently.  Since this is a move along the stable branch, there should be no impact except fixing bugs.

I agree that werror shouldn't be enabled in distro builds.  We recommend it is enabled for upstream developers only.

Having said all that, I'm using:

  glibc-2.26.9000-28.fc28.x86_64
  binutils-2.29.1-5.fc28.x86_64

and I don't see any warnings along the stable-1.36 branch.

I checked out what this "expansion-to-defined" warning is supposed to mean and I don't understand how it applies here.

  '-Wexpansion-to-defined'
     Warn whenever 'defined' is encountered in the expansion of a macro
     (including the case where the macro is expanded by an '#if'
     directive).  Such usage is not portable.  This warning is also
     enabled by '-Wpedantic' and '-Wextra'.

Is Gentoo's _FORTIFY_SOURCE a macro?  How is it defined?  Can you run the code through cpp and attached the .i file?
Comment 2 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2017-12-10 14:09:37 UTC
(In reply to Richard Jones from comment #1)
> I agree that werror shouldn't be enabled in distro builds.  We recommend it
> is enabled for upstream developers only.

This is a sort of vague space, because well, the way our workflow works, end-user workflow and developer workflow is somewhat the same.

Here, the problem behaviour *only* occurs when some human opts-in to the "test" feature, and the sorts of humans who opt-in to that are sometimes end-users ( who might not care about this ), but are other times "arch-testers" ( who are more likely to care about things like this )

> Is Gentoo's _FORTIFY_SOURCE a macro?  How is it defined?  Can you run the
> code through cpp and attached the .i file?

Not sure, working on getting the '.i' file generated, but my make-foo is kinda failing me atm, and can't seem to work out how to invoke anything that will do this.
Comment 3 Richard Jones 2017-12-10 14:13:38 UTC
Probably easiest is to cut and paste the long gcc command and add -save-temps to it.  There should be a ‘cleanup.i’ file left around.
Comment 4 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2017-12-10 14:36:08 UTC
Created attachment 509244 [details]
cleanup.i.gz
Comment 5 Richard Jones 2017-12-10 16:18:59 UTC
Unfortunately cleanup.i contains the compiler input after macro preprocessing (which I should have known) so it doesn't show the error.

I'm still unclear what the warning means, but I advise just disable the warning, libguestfs won't work with non-GCC/clang anyway for lots of reasons, portability of some obscure cpp feature isn't a concern.
Comment 6 Richard Jones 2017-12-10 21:17:54 UTC
I tried to reproduce this locally using:

CFLAGS="-O2 -Wexpansion-to-defined" \
./configure --enable-werror
make

but it doesn't reproduce for me.  I'm using pretty recent
glibc and gcc:

glibc-2.26.9000-28.fc28.x86_64
gcc-7.2.1-4.fc28.x86_64

I also think that our use of macros on this line is safe.  We're
not expanding any macro that I can see which would expand to contain
"defined".

I suspect this must be something to do with the Gentoo environment ...

However we could actually remove the whole section.  It was added
back in 2009 and I'm not convinced that unconditionally defining
_FORTIFY_SOURCE=2 is worthwhile these days given that (a) we use
valgrind to routinely test the code and (b) _FORTIFY_SOURCE=2 is
defined downstream in many distros.  I posted a patch to this effect:

https://www.redhat.com/archives/libguestfs/2017-December/msg00036.html
Comment 7 Richard Jones 2018-01-16 16:34:57 UTC
The patch I mentioned before is now upstream and hopefully will
fix these problems.

https://github.com/libguestfs/libguestfs/commit/49263be47aaa2358a0fb12ee90220137ca260b92
Comment 8 Larry the Git Cow gentoo-dev 2018-02-07 22:39:18 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d5fdb7d569488c4f4a33a6d1cae714d45b5a4f56

commit d5fdb7d569488c4f4a33a6d1cae714d45b5a4f56
Author:     Gilles Dartiguelongue <eva@gentoo.org>
AuthorDate: 2018-02-07 22:34:53 +0000
Commit:     Gilles Dartiguelongue <eva@gentoo.org>
CommitDate: 2018-02-07 22:38:48 +0000

    app-emulation/libguestfs: version bump 1.36.5 → 1.36.13
    
        * Now compatible with >=glibc-2.26, bug #638180.
        * Make sure USE=introspection explicitely passes configure switch as we
          might split glib/gobject from introspection at some point.
        * Switch to perl-functions eclass as advised in bug #629946.
        * Restore USE=ocaml as I could not bug #629490 from provided info.
        * Fix pkg_postinst feature check on USE=gtk.
        * Fix build with FEATURES=test by disabling -Werror always. It makes no
          sense to enable this flag for a release, bug #640494.
        * Add myself to maintainers.
    
        Closes: https://bugs.gentoo.org/629690
        Closes: https://bugs.gentoo.org/629946
        Closes: https://bugs.gentoo.org/638180
        Closes: https://bugs.gentoo.org/640494
    
    Package-Manager: Portage-2.3.24, Repoman-2.3.6

 app-emulation/libguestfs/Manifest                  |   1 +
 app-emulation/libguestfs/libguestfs-1.36.13.ebuild | 173 +++++++++++++++++++++
 app-emulation/libguestfs/metadata.xml              |   4 +
 3 files changed, 178 insertions(+)