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 651959 - gbitlock: "asm goto" is not available in gcc < 4.5
gbitlock: "asm goto" is not available in gcc < 4.5
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.29.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-06-06 00:57 UTC by Ryan Schmidt
Modified: 2011-06-09 02:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
log with V=1 (64.49 KB, text/plain)
2011-06-07 00:42 UTC, Ryan Schmidt
  Details
proposed patch (2.64 KB, patch)
2011-06-08 09:22 UTC, Christophe Fergeau
committed Details | Review
bitlock: don't use asm goto on older gcc (2.68 KB, patch)
2011-06-09 02:48 UTC, Matthias Clasen
committed Details | Review

Description Ryan Schmidt 2011-06-06 00:57:07 UTC
Building glib 2.29.6 for -arch i386 on Mac OS X 10.6.7 with Xcode 3.2.6 fails with:


Making all in .
  CC     garray.lo
  CC     gasyncqueue.lo
  CC     gatomic.lo
  CC     gbacktrace.lo
  CC     gbase64.lo
  CC     gbitlock.lo
gbitlock.c: In function 'g_bit_lock':
gbitlock.c:211: error: expected '(' before 'goto'
gbitlock.c:211: error: expected identifier or '*' before '(' token
gbitlock.c:219: warning: label 'contended' defined but not used
gbitlock.c: In function 'g_pointer_bit_lock':
gbitlock.c:398: error: expected '(' before 'goto'
gbitlock.c:398: error: expected identifier or '*' before '(' token
gbitlock.c:406: warning: label 'contended' defined but not used
make[4]: *** [gbitlock.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Comment 1 Ryan Schmidt 2011-06-06 04:34:27 UTC
It happens with -arch x86_64 too.

glib2 2.29.4 and 2.28.7 build fine on the same system.
Comment 2 Colin Walters 2011-06-06 21:57:35 UTC
What compiler is being used here?  Can we get "make V=1" output as well as gcc --version (if GCC)?
Comment 3 Matthias Clasen 2011-06-06 21:59:21 UTC
Sounds like Xcode claims to be gcc but is not quite up to it after all...
The code in question is:

#if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
 retry:
  asm volatile goto ("lock bts %1, (%0)\n"
                     "jc %l[contended]"
                     : /* no output */
                     : "r" (address), "r" (lock_bit)
                     : "cc", "memory"
                     : contended);
  return;

 contended:
 ...
Comment 4 Ryan Schmidt 2011-06-06 23:13:01 UTC
I should have been clearer: I'm using a standard command-line configure and make build process (using MacPorts; I am the MacPorts maintainer for the glib2 ports), using the version of gcc provided by Xcode 3.2.6, which is Apple gcc 4.2.1:


$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


I'll attach the verbose build output for you shortly.
Comment 5 Ryan Schmidt 2011-06-07 00:42:04 UTC
Created attachment 189370 [details]
log with V=1
Comment 6 Christophe Fergeau 2011-06-07 13:45:16 UTC
asm goto is new in gcc 4.5:
"An asm goto feature has been added to allow asm statements that jump to C labels."
(from http://gcc.gnu.org/gcc-4.5/changes.html )

I assume the volatile has no incidence here.

See also http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Extended-Asm.html#Extended-asm-with-goto
Comment 7 Christophe Fergeau 2011-06-08 09:22:34 UTC
Created attachment 189452 [details] [review]
proposed patch

Here is one way of fixing this bug, though I haven't tested it yet on an older gcc, hopefully I'll have time for that in the next hours.
Comment 8 Christophe Fergeau 2011-06-08 14:38:09 UTC
I can confirm this fixes compilation for me on osx, but then my test app crashes, I'm not sure yet if this is caused by the bitlocks or something else (reverting to the commit right before the use of asm goto in bitlocks gives me a non-crashing app)
Comment 9 Christophe Fergeau 2011-06-08 14:58:03 UTC
I'm also seeing regressions in the tests/refcount testsuite, going from one failure to 3, not sure if this is related to this patch or not.
Comment 10 Christophe Fergeau 2011-06-08 15:53:10 UTC
Hmm, it seems to randomly fail actually, running the test suite several times in a row results in a different number of failures, unrelated to this bug anyway :)
Comment 11 Allison Karlitskaya (desrt) 2011-06-08 16:43:42 UTC
Comment on attachment 189452 [details] [review]
proposed patch

This patch looks quite fine.  After your testing, please commit it.

Thanks for the catch.
Comment 12 Ryan Schmidt 2011-06-09 01:04:46 UTC
Thanks, it builds for me, and I've committed it to MacPorts: https://trac.macports.org/changeset/79309
Comment 13 Matthias Clasen 2011-06-09 02:40:34 UTC
The following fix has been pushed:
602f8ba bitlock: don't use asm goto on older gcc
Comment 14 Matthias Clasen 2011-06-09 02:48:19 UTC
The following fix has been pushed:
602f8ba bitlock: don't use asm goto on older gcc
Comment 15 Matthias Clasen 2011-06-09 02:48:24 UTC
Created attachment 189518 [details] [review]
bitlock: don't use asm goto on older gcc

asm goto was addded in gcc 4.5 so don't try to use it on gcc versions
older than this one. This is achieved by explicitly checking gcc
version, an alternative would be to try to compile a program using
asm volatile in configure.