Bug 16171 - X_{BIG|LITTLE}_ENDIAN not defined in dix-config.h
Summary: X_{BIG|LITTLE}_ENDIAN not defined in dix-config.h
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL: http://bugs.gentoo.org/show_bug.cgi?i...
Whiteboard:
Keywords:
Depends on:
Blocks: 15206
  Show dependency treegraph
 
Reported: 2008-05-30 12:26 UTC by Ralph_Ulrich
Modified: 2018-04-23 21:17 UTC (History)
8 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Preprocessed output of colormap.c (275.49 KB, text/plain)
2008-06-13 12:11 UTC, Dirk Schoebel
no flags Details
a not exactly nice but effective fix. (1.32 KB, text/plain)
2008-06-15 05:13 UTC, Luca Barbato
no flags Details
better patch to work around autoconf macro problem (557 bytes, patch)
2008-08-29 13:40 UTC, Brian Tarricone
no flags Details | Splinter Review

Description Ralph_Ulrich 2008-05-30 12:26:34 UTC
On a ps3 ~ppc64 system xorg-server-1.4.0 fails to compile:
---
In file included from colormap.c:61:
../include/colormapst.h:110:42: error: operator '==' has no left operand
colormap.c:283:19: error: operator '==' has no left operand
make[2]: *** [colormap.lo] Fehler 1
make[2]: Leaving directory
`/home/tmp/portage/x11-base/xorg-server-1.4.0.90-r3/work/xorg-server-1.4.0.90/dix'
make[1]: *** [all] Fehler 2
---
colormapst.h line 110:
---
#if defined(_XSERVER64) && (X_BYTE_ORDER == X_LITTLE_ENDIAN) 
---
From xorg-server-1.3 to 1.4 there has been an additional variable
_X_BYTE_ORDER
introduced. The old variable X_BYTE_ORDER keeps on to be present in header files - but not mentioned anymore in:
xorg-server-1.4.0.90-r3/work/xorg-server-1.4.0.90/configure
---
PS:
I do not know if "_X_BYTE_ORDER" was introduced by gentoo developers (then forget this bug report here on site bugs.freedesktop.org)
Comment 1 Peter Hutterer 2008-05-30 21:12:26 UTC
verified with git master. 

Problem is that dix-config.h defines X_BYTE_ORDER without having a definition for X_LITTLE_ENDIAN or X_BIG_ENDIAN. A subsequent include of Xarch.h then doesn't define it because it believes them to be defined already. This would affect all files that include dix-config.h before any other header files (i.e. most if not all).

Two possible fixes - either include Xarch.h before dix-config.h (lots of changes!) or somehow define L/B_ENDIAN in dix-config.h.

Alan: you have more experience than me with this, can you please have a look at that?
Comment 2 Peter Hutterer 2008-06-12 18:52:46 UTC
actually, can you give us the output of the preprocessor?

cd dix/
make colormap.o

then copy the full gcc command (without the if/then wrapper around it) and append a -E. Run it, and please rename and attach the output file (colormap.o -> colormap.txt) to this bug report. Thx.
Comment 3 Dirk Schoebel 2008-06-13 12:11:12 UTC
Created attachment 17105 [details]
Preprocessed output of colormap.c

compiler call:

powerpc-unknown-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../include -I../Xprint -DHAVE_DIX_CONFIG_H -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT -DDBUS_API_SUBJECT_TO_CHANGE -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/hal -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I../include -I../include -I../Xext -I../composite -I../damageext -I../xfixes -I../Xi -I../mi -I../miext/shadow -I../miext/damage -I../render -I../randr -I../fb "-DVENDOR_NAME=\"The X.Org Foundation\"" "-DVENDOR_RELEASE=(((1) * 10000000) + ((4) * 100000) + ((2) * 1000) + 0)" -mcpu=7400 -mtune=7400 -maltivec -mabi=altivec -O2 -pipe -MT colormap.lo -MD -MP -MF .deps/colormap.Tpo -c colormap.c  -fPIC -DPIC -E > colormap.txt
Comment 4 Dirk Schoebel 2008-06-13 12:17:43 UTC
Since i'm bothered by the problem for quite a while now (just didn't have the time to look into it closer) i'll provide the preprocessed output and hope for a quick solution ;)
The problem occurs on a ppc32 system (iBook G4) running Gentoo linux.
Comment 5 Dirk Schoebel 2008-06-13 13:33:37 UTC
Actually, since it's the preprocessor that fails during compile attempt it's not really preprocessed output (the file specified using -o doesn't exist/is empty), just something the compiler wrote to stdout on the aforementioned call.
Comment 6 Luca Barbato 2008-06-14 19:05:31 UTC
The sanest thing should be avoid this completely and just include Xarch.h in that header.

(or make sure _X_BYTE_ORDER doesn't get defined as nothing as now happens.
Comment 7 Peter Hutterer 2008-06-15 04:35:33 UTC
> --- Comment #6 from Luca Barbato <lu_zero@gentoo.org>  2008-06-14 19:05:31 PST ---
> The sanest thing should be avoid this completely and just include Xarch.h in
> that header.

That's the problem. Xarch.h is included.
http://cgit.freedesktop.org/xorg/xserver/tree/include/colormapst.h#n51
Comment 8 Luca Barbato 2008-06-15 05:13:18 UTC
Created attachment 17120 [details]
a not exactly nice but effective fix.

the "problem" is that dix-config.h has some brain damage added so instead of using Xarch.h to get the endianess or using the autotool facility to get it. Tries to put a simplified Xarch.h for apple and tries to overwrite the value using configure. The thing doesn't work for a reason I didn't tracked, but just sticking #include <X11/Xarch.h> inside dix-config.h.in did the job (now I'm tracking glibc-2.8 related fixes)

Probably just removing all endianess reference from dix-config.h should work as well but I'd rather be safe than sorry.
Comment 9 Alan Coopersmith 2008-06-16 09:16:34 UTC
Peter & I discussed on IRC last week - I can't see any way that you
can #include Xarch.h and not end up with X_LITTLE_ENDIAN & X_BIG_ENDIAN
undefined.

I'm not sure what the added MacOS X code is trying to do there though.
Comment 10 Luca Barbato 2008-06-16 11:48:08 UTC
_X_BYTE_ORDER is defined as nothing in the dix-config.h

X_BYTE_ORDER gets defined as nothing, thus making the macro eval as
( == X_LITTLE_ENDIAN)

since X_BYTE_ORDER is defined Xarch.h doesn't reset it.

either removing everything from dix-config.h or putting there 

#include <X11/Xarch.h>

solves the issue (and will work for generating fat binaries in macosx/darwin.

Comment 11 Jeremy Huddleston Sequoia 2008-06-16 19:25:34 UTC
Why is X_BYTE_ORDER getting set to nothing?  Shouldn't configure.ac be setting it appropriately?

The added Apple code there is trying to get around the problem that the same header file is used to compile for both little endian and big endian at the exact same time, so we can't just ./configure for one target... we need to ./configure for multiple targets (ppc, ppc64, i386, x86_64) at the same time.
Comment 12 Robin Johnson 2008-06-21 16:03:11 UTC
xorg-server-1.4.0.90, little-endian:
# grep _X_BYTE_ORDER /usr/include/{xorg,X11} -r
/usr/include/xorg/xorg-server.h:#define _X_BYTE_ORDER X_LITTLE_ENDIAN
/usr/include/xorg/xorg-server.h:#define X_BYTE_ORDER _X_BYTE_ORDER

xorg-server-1.4.2, big-endian (PPC64-32ul):
# grep _X_BYTE_ORDER /usr/include/{xorg,X11} -r
/usr/include/xorg/xorg-server.h:/* #undef _X_BYTE_ORDER */
/usr/include/xorg/xorg-server.h:#define X_BYTE_ORDER _X_BYTE_ORDER

xorg-server-1.4.2, little-endian:
# grep _X_BYTE_ORDER /usr/include/{xorg,X11} -r
/usr/include/xorg/xorg-server.h:/* #undef _X_BYTE_ORDER */
/usr/include/xorg/xorg-server.h:#define X_BYTE_ORDER _X_BYTE_ORDER
Comment 13 Robin Johnson 2008-06-21 17:52:32 UTC
The source of the issue for xorg is this definition in configure.ac:
AC_C_BIGENDIAN([ENDIAN="X_BIG_ENDIAN"], [ENDIAN="X_LITTLE_ENDIAN"])
while AC_C_BIGENDIAN can take 4 inputs: true, false, failure, universal.

But it doesn't end there...

And autoconf-2.6.2 has a broken detection of universal on linux-PPC:
http://www.mail-archive.com/bug-autoconf@gnu.org/msg01680.html

AC_C_BIGENDIAN takes the universal path when autoconf-2.6.2 is installed and we are on ppclinux, so $ENDIAN does not get defined, so _X_BYTE_ORDER ends up as empty (and Luca tried to patch that part out).

There hasn't been any fix posted to the autoconf list yet however :-(.
Comment 14 Brian Tarricone 2008-08-29 13:40:57 UTC
Created attachment 18574 [details] [review]
better patch to work around autoconf macro problem

Attachment #17120 [details] didn't work for me -- build failed later because X11/Xarch.h includes features.h before _GNU_SOURCE gets set, so things don't work right.  Switching it around so Xarch.h gets included after settting _GNU_SOURCE allowed the build to succeed, but then generated an xorg-config.h with incorrect endianness detection/macros, which broke the nouveau driver.

This patch works for me, though I'm not entirely sure I need it anymore, as when I ran configure, it actually detected as 'big endian' this time, rather than 'universal'.  So maybe the autoconf bug has been fixed since the last time I tried.

I imagine this patch might also break things on systems that actually should be correctly detected as 'universal'... though maybe xorg doesn't support them anyway.
Comment 15 Brian Tarricone 2008-08-29 13:48:38 UTC
(In reply to comment #14)
> ... though I'm not entirely sure I need it anymore, as
> when I ran configure, it actually detected as 'big endian' this time, rather
> than 'universal'.  So maybe the autoconf bug has been fixed since the last time
> I tried.

Ah, no, it looks like Gentoo has a patched version of autoconf 2.62 that reverts the changes in AC_C_BIGENDIAN() so the macro is effectively the same as in 2.61.

So I can't be completely sure that my patch fixes the issue (since I'm apparently being correctly identified as big endian again), but I think it should.  The other patch almost certainly doesn't work properly, and can make the problems worse.
Comment 16 Jesse Adkins 2010-11-15 19:02:57 UTC
Autoconf 2.63, released 2008-09-09, fixed this bug. You can read the report here :
http://lists.gnu.org/archive/html/autoconf/2008-09/msg00065.html.

Since this only affects autoconf versions two+ years old, can this bug just be closed?
Comment 17 Adam Jackson 2018-04-23 21:17:18 UTC
Fixed by now.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.