Bug 120331

Summary: X.Org compile failures related to gcc 4.1.0 (gcc bug?)
Product: [openSUSE] SUSE Linux 10.1 Reporter: Stefan Dirsch <sndirsch>
Component: OtherAssignee: Richard Biener <rguenther>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P2 - High CC: eich, matz, rguenther
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: All   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Stefan Dirsch 2005-10-05 09:19:43 UTC
X.Org compilation no longer works with gcc 4.1.0 . :-(

# xc/lib/ICE$ make
rm -f transport.o unshared/transport.o
gcc -m32 -c -ansi -pedantic -Wall -Wpointer-arith -Wundef    -I../..
+-I../../exports/include  -I../../../include -I../../../glide3 -Dlinux -D__i386__
+-D_POSIX_C_SOURCE=199309L                                 -D_POSIX_SOURCE
+-D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE
+-D_GNU_SOURCE           -DFUNCPROTO=15 -DNARROWPROTO           -O2 -march=i586
+-mtune=i686 -fmessage-length=0 -Wall  -fno-strict-aliasing  -I../../lib/xtrans
+-DUNIXCONN -DTCPCONN -DHAS_STICKY_DIR_BIT -DHAS_FCHOWN -DIPv6 -DICE_t
-DTRANS_CLIENT
+-DTRANS_SERVER -DFAIL_HARD  transport.c -o unshared/transport.o
/tmp/cckqbWcr.s: Assembler messages:
/tmp/cckqbWcr.s:6371: Error: Local symbol `in6addr_any' can't be equated to
undefined
+symbol `local_in6addr_any'
/tmp/cckqbWcr.s:6371: Error: Local symbol `in6addr_any' can't be equated to
undefined
+symbol `local_in6addr_any'
/tmp/cckqbWcr.s:6371: Error: Local symbol `in6addr_any' can't be equated to
undefined
+symbol `local_in6addr_any'
/tmp/cckqbWcr.s:6371: Error: Local symbol `in6addr_any' can't be equated to
undefined
+symbol `local_in6addr_any'
make: *** [transport.o] Error 1

xc/lib/ICE/transport.c:
[...]
#if defined(TCPCONN) || defined(UNIXCONN)
#include "Xtranssock.c"
#endif
[...]

xc/lib/xtrans/Xtranssock.c:
[...]
#if defined(IPv6) && defined(AF_INET6)
static const struct in6_addr local_in6addr_any = IN6ADDR_ANY_INIT;
#pragma weak in6addr_any = local_in6addr_any
[...]
Comment 1 Stefan Dirsch 2005-10-05 09:20:32 UTC
Hmpf.  Es ist so, dass weak Symbole defined sein muessen (man kann also
nicht in einem anderen File einen Alias fuer ein Symbol einfuehren.
Das ist zumindest in deinem kleinen Ausschnitt der Fall.  Der Compiler
scheint allerdings diese lokale Variable wegzuoptimieren was dann zu
der Fehlermeldung fuehrt.  :-(  Ein Compilerbug wuerde ich sagen.

Ciao,
Micha.
Comment 2 Stefan Dirsch 2005-10-05 09:21:07 UTC
Dieses Problem ist bereits einmal aufgetaucht und in Ticket
#64364 disukutiert worden. Dort gibt es auch einen pointer auf
ein gcc Ticket, wo das Problem schlussendlich gefixed wurde.

Gruss,
        Egbert.
Comment 3 Matthias Hopf 2005-10-05 10:47:22 UTC
For me bug 64364 looks completely different to me. This time the code doesn't
even compile. It might be the same construction that leads to compilation
failure, but it's not the same bug.
Comment 4 Michael Matz 2005-10-05 14:35:27 UTC
Matthias, it's really the same, only this time the assembler already    
complains.  If it wouldn't, then there would be a link error afterwards.   
It's a compiler bug, somehow in cgraph code, hence assigning to Honza.   
   
Honza: this bug already happened with gcc 4.0 but was fixed there, but 
seems to have resurfaced. 
Comment 5 Richard Biener 2005-10-10 10:47:47 UTC
This can be worked around by sticking __attribute__((used)) to the otherwise
unused static local like

static const struct in6_addr local_in6addr_any __attribute__((used)) =
IN6ADDR_ANY_INIT;

I filed gcc PR24295 for the bug.
Comment 6 Stefan Dirsch 2005-10-10 11:04:45 UTC
From the bugzilla I suspect that with

static const struct in6_addr local_in6addr_any = IN6ADDR_ANY_INIT;
#pragma weak in6addr_any = local_in6addr_any

the only use of local_in6addr_any is in the weak definition?  If so,
try

static const struct in6_addr local_in6addr_any __attribute__((used)) =
IN6ADDR_ANY_INIT;
#pragma weak in6addr_any = local_in6addr_any

Btw, from a C pov this isn't a gcc bug.

Richard.
Comment 7 Egbert Eich 2005-10-10 11:11:17 UTC
We may have to put the __attribute__((used)) into a macro which only expands for
gcc.
Comment 8 Stefan Dirsch 2005-10-12 13:27:28 UTC
The proposal by Richard works, but I let this bugreport open until it is
investigated upstream. Assigning to Richard, since he made the upstream bugreport.
Comment 9 Richard Biener 2005-10-24 08:19:58 UTC
The bug is fixed upstream, I'll get a fixed compiler into beta asap.
Comment 10 Stefan Dirsch 2005-10-24 08:36:59 UTC
Thanks for keeping us up-to-date. Please let us know, when the new compiler is in BETA/STABLE, so I can remove the workaround of comment #6 again.
Comment 11 Richard Biener 2005-10-25 10:39:32 UTC
The compiler hit BETA, can you remove the workaround and close the bug if it is really fixed?

Thanks,
Richard.
Comment 12 Stefan Dirsch 2005-10-25 13:11:43 UTC
Thanks. I'll give it a try.
Comment 13 Stefan Dirsch 2005-10-25 13:12:57 UTC
Sorry ...
Comment 14 Stefan Dirsch 2005-10-25 15:16:17 UTC
Works fine now without the workaround. Thanks. I disabled this patch in xorg-x11 build now completely.