After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 674483 - broken configure results when cross-compiling with gcc >= 4.5
broken configure results when cross-compiling with gcc >= 4.5
Status: VERIFIED FIXED
Product: glib
Classification: Platform
Component: build
2.32.x
Other Linux
: Normal critical
: ---
Assigned To: gtkdev
gtkdev
: 674773 680429 681244 683820 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-04-20 17:04 UTC by Michael Olbrich
Modified: 2012-09-11 22:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to make sure configure bails out if the problem occurs (1.21 KB, patch)
2012-04-25 08:44 UTC, Michael Olbrich
committed Details | Review
use AS_IF for correct prerequisite placement (1.03 KB, patch)
2012-05-03 09:25 UTC, Michael Olbrich
committed Details | Review
configure: Use AS_IF almost everywhere (26.42 KB, patch)
2012-05-03 19:29 UTC, Colin Walters
committed Details | Review
on more AS_IF (1.10 KB, patch)
2012-05-07 11:13 UTC, Michael Olbrich
committed Details | Review

Description Michael Olbrich 2012-04-20 17:04:14 UTC
Wenn cross-compiling with gcc >= 4.5 AC_CHECK_ALIGNOF() is broken and 
returns 0, without reporting an error.

What happens is this: 
AC_CHECK_ALIGNOF generates some try-compile magic that is supposed to
declare an array with an positive or negative size.  Unfortunately since
gcc 4.5 this always fails with:

error: storage size of ‘test_array’ isn’t constant

Then because ac_cv_type_guint32 (for AC_CHECK_ALIGNOF([guint32], ...)) is 
not set, no error is reported and ALIGNOF_GUINT32 is set to '0'.

Everything compile just fine, but error occur at runtime. I got a SIGFPE in
msort_r.
Comment 1 Colin Walters 2012-04-24 14:40:30 UTC
This should be fixed in autoconf, but I think we could take a workaround patch in glib for now.
Comment 2 Michael Olbrich 2012-04-25 08:44:22 UTC
Created attachment 212752 [details] [review]
patch to make sure configure bails out if the problem occurs

This does not fix the problem, but with this patch it no longer fails silently. At least this way, we know that we have to set the correct cache variables.
Comment 3 Colin Walters 2012-04-25 13:21:57 UTC
*** Bug 674773 has been marked as a duplicate of this bug. ***
Comment 4 Colin Walters 2012-04-25 13:36:23 UTC
Review of attachment 212752 [details] [review]:

Looks OK; I think we're kind of abusing autoconf here because AC_CHECK_TYPE should always fail (because "guint32" won't be in the system headers).

On the other hand, I started reading through /usr/share/autoconf/autoconf/types.m4 to see if we can do better, but there's only so much m4 one can take in the morning...
Comment 5 Tomas Frydrych 2012-04-25 14:41:58 UTC
(In reply to comment #4)
> On the other hand, I started reading through
> /usr/share/autoconf/autoconf/types.m4 to see if we can do better, but there's
> only so much m4 one can take in the morning...

There is no practical way to do better than fail when the check returns 0 because AC_CHECK_ALIGNOF macro simply does not work for crosscompilation. But would it not be cleaner to just test the $ac_cv_alignof_guint32 et al variables for 0 after the check?
Comment 6 Tomas Frydrych 2012-04-25 14:50:37 UTC
As a side note on the "error: storage size of ‘test_array’ isn’t constant": this is because on arm the 'offsetof' token used to define the size of the test_array is an intrinsic __builtin_offsetof. (Though this is not the reason it does not work; AC_CHECK_ALIGNOF() is simply not designed to work during cross compilation.)
Comment 7 Michael Olbrich 2012-04-25 14:54:19 UTC
Not true. AC_CHECK_ALIGNOF works when cross-compiling with gcc-4.3
And I have a patch that fixes it for newer gcc versions (using __builtin_offsetof)
Comment 8 Colin Walters 2012-04-25 15:46:53 UTC
(In reply to comment #7)
> Not true. AC_CHECK_ALIGNOF works when cross-compiling with gcc-4.3
> And I have a patch that fixes it for newer gcc versions (using
> __builtin_offsetof)

Can you link to your patch here so anyone who hits the same bug has the option to patch their autoconf?
Comment 9 Michael Olbrich 2012-05-03 09:25:42 UTC
Created attachment 213354 [details] [review]
use AS_IF for correct prerequisite placement

I reported the issue to autoconf upstream and learned, that this was 
actually caused by another bug in configure.ac: AC_CHECK_HEADER (and 
probably all other macros) should never be used inside an 'if'. The problem
is this:
Macros can have prerequisites. Any prerequisites are unly included the 
first time they are needed. If this is inside an 'if', then they not be 
executed at all.
In this case, because of that <stddef.h> was not included. offsetof is 
defined to __builtin_offsetof there...

The solution is to use AS_IF. It generated an 'if' but places the
prerequisites _before_ the 'if'.

The patch changes this for the 'if' that causes by problem, but this is 
probably not the only place, where this should be changed.
Comment 10 Colin Walters 2012-05-03 16:16:20 UTC
(In reply to comment #9)
> Created an attachment (id=213354) [details] [review]
> use AS_IF for correct prerequisite placement
> 
> I reported the issue to autoconf upstream and learned, that this was 
> actually caused by another bug in configure.ac: AC_CHECK_HEADER (and 
> probably all other macros) should never be used inside an 'if'. The problem
> is this:
> Macros can have prerequisites. Any prerequisites are unly included the 
> first time they are needed. If this is inside an 'if', then they not be 
> executed at all.

Hmm...evil =/

> In this case, because of that <stddef.h> was not included. offsetof is 
> defined to __builtin_offsetof there...

But then it seems like this bug would ALSO be fixed if we used AC_CHECK_HEADER([stdint.h]) unconditionally before these alignof calls, right?
Comment 11 Colin Walters 2012-05-03 16:17:36 UTC
Note, I'm not objecting to your patch, we should clearly convert to AS_IF in general, but if the unconditional AC_CHECK_HEADER works we should *also* do that since it's just way clearer and less fragile.
Comment 12 Michael Olbrich 2012-05-03 17:06:25 UTC
> But then it seems like this bug would ALSO be fixed if we used
> AC_CHECK_HEADER([stdint.h]) unconditionally before these alignof calls, right?

No, that won't work either. HAVE_STDINT_H is still not defined. I'm not
sure why. It only works if the first AC_CHECK_HEADER is always executed.
Comment 13 Colin Walters 2012-05-03 18:25:57 UTC
Review of attachment 213354 [details] [review]:

Looks OK then; I assume you want this on the glib-2-32 branch too?
Comment 14 Colin Walters 2012-05-03 19:29:53 UTC
Created attachment 213403 [details] [review]
configure: Use AS_IF almost everywhere

Not doing so is an evil trap, sadly.  This patch has been
compile-checked on Fedora 16, and I've verified that the generated
config.status and config.h is exactly the same.
Comment 15 Michael Olbrich 2012-05-07 11:13:33 UTC
Created attachment 213577 [details] [review]
on more AS_IF

There is one other place where it actually makes a difference. At least the 
generated configure is different. I don't think it has any practical
consequences. The prerequisites are not uses elsewhere (I think).
Comment 16 Michael Olbrich 2012-05-07 11:15:29 UTC
(In reply to comment #13)
> Review of attachment 213354 [details] [review]:
> 
> Looks OK then; I assume you want this on the glib-2-32 branch too?

That would be great. But it's not critical. With the other patch applied I get
the error message. That's something I can work with.
Comment 17 Colin Walters 2012-05-07 21:19:15 UTC
(In reply to comment #16)
> (In reply to comment #13)
> > Review of attachment 213354 [details] [review] [details]:
> > 
> > Looks OK then; I assume you want this on the glib-2-32 branch too?
> 
> That would be great. But it's not critical. With the other patch applied I get
> the error message. That's something I can work with.

Ok, let's just push all this to master then.  Thanks!
Comment 18 Colin Walters 2012-05-07 21:19:38 UTC
Attachment 213403 [details] pushed as 54e31ab - configure: Use AS_IF almost everywhere
Comment 19 Colin Walters 2012-07-25 15:24:01 UTC
*** Bug 680429 has been marked as a duplicate of this bug. ***
Comment 20 Allison Karlitskaya (desrt) 2012-08-05 19:43:42 UTC
*** Bug 681244 has been marked as a duplicate of this bug. ***
Comment 21 Colin Walters 2012-09-11 22:10:45 UTC
*** Bug 683820 has been marked as a duplicate of this bug. ***
Comment 22 Mike Frysinger 2012-09-11 22:21:09 UTC
(In reply to comment #1)

autoconf's AC_CHECK_ALIGNOF macro was specifically broken independent of check headers.  but that too has been fixed now upstream.