On 04/25/2012 02:56 AM, Michael Olbrich wrote: > Hi, > > when cross-compiling with gcc >= 4.5 (I think), AC_CHECK_ALIGNOF fails to > detect the alignment. This happens because the compiler fails with "error: > storage size of ‘test_array’ isn’t constant" instead of succeeding.
Thanks for the report. Alas, you just missed the release autoconf 2.69, so if this turns out to be an autoconf bug, you have the honor of the first bug report on the new release (even though the problem itself is older). > Using __builtin_offsetof helps. Patch attached. I'm not quite sure when > __builtin_offsetof should be used, but it is used in the Linux kernel for > gcc 4.x, so I think this is correct. Thanks for the attempted patch. However, the real bug is that we are trying to use our own offsetof, instead of relying on the system headers to do the heavy lifting on our behalf. That is, <stddef.h> should already by using __builtin_offsetof, and we should be turning to <stddef.h> rather than reinventing the work in autoconf. > +++ b/lib/autoconf/types.m4 > @@ -800,8 +800,12 @@ m4_define([_AC_CHECK_ALIGNOF], > _AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$3])], > [(long int) offsetof (ac__type_alignof_, y)], > [AC_INCLUDES_DEFAULT([$2]) Normally, AC_INCLUDES_DEFAULT should already be including <stddef.h>; the only time this is not true is if $2 is non-empty (you were providing specific headers to include instead of relying on the defaults). And once <stddef.h> is in the picture, > -#ifndef offsetof > -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) offsetof should already be defined for gcc compilers, at which point, this fallback is good enough for non-compliant platforms with older compilers that don't warn like gcc does. So the real question is: how did you trigger this failure in the first place, and could it be a bug in your configure.ac that resulted in the $2 argument passed to _AC_CHECK_ALIGNOF overriding the AC_INCLUDES_DEFAULT in such a manner that <stddef.h> is not being included? Can you post both a configure.ac that reproduces the problem, and the corresponding config.log that shows how what program was actually being compiled when you hit the gcc warning? -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature