Skip to contentSkip to conversation

Compiling glibc with 2.6.28 linux headers

DISCUSSION Friedrich Oslage 6 participants 11 messages Dec 13, 2008 – Jan 6, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

when compiling glibc(2.9, 20081208 snapshot) with linux 2.6.28-rc8 headers I get a lot of errors like this one:

In file included from /tmp/toolchain-build/rootfs/usr/include/asm/byteorder.h:49,
from
/tmp/toolchain-build/rootfs/usr/include/linux/atalk.h:4,

                 from ../sysdeps/unix/sysv/linux/netatalk/at.h:25,
                 from ../sysdeps/unix/sysv/linux/sa_len.c:22:

/tmp/toolchain-build/rootfs/usr/include/linux/byteorder.h:8:3: error:
#error Fix asm/byteorder.h to define one endianness

About a month ago arch/sparc/include/asm/byteorder.h was changed to include the new linux/byteorder.h instead of the old linux/byteorder/big_endian.h. The new one panics if both __LITTLE_ENDIAN and __BIG_ENDIAN are defined.

But since glibc's string/endian.h(/usr/include/endian.h) always defines __BIG_ENDIAN and __LITTLE_ENDIAN it may occur, depending on the includes, that both are defined when asm/byteorder.h is included.

My assumption is that asm/byteorder.h should ensure that only one of these is defined.

After applying the patch below compiling glibc works again. But when compiling the kernel I get

In file included from drivers/scsi/qla2xxx/qla_dfs.c:7:
drivers/scsi/qla2xxx/qla_def.h:1487:7: warning: "__LITTLE_ENDIAN" is not defined

Which sould be okay...I think the #elif should really be an #elif defined but that's another thing ;)

Is this the right solution or did I miss anything?

Cheers,
Friedrich

- --- arch/sparc/include/asm/byteorder.h
+++ arch/sparc/include/asm/byteorder.h
@@ -5,6 +5,9 @@
#include <asm/asi.h>

#define __BIG_ENDIAN
+#ifdef __LITTLE_ENDIAN
+# undef __LITTLE_ENDIAN
+#endif

#ifdef CONFIG_SPARC32
#define __SWAB_64_THRU_32__
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklD2tYACgkQknxn9PmJ76XvEACZAajpv/iRLAeEHXp7cIWBCEEX V9kAnRZ0BBDwLrMENDsPsYMuPWpLDlKv
HUQ
-----END PGP SIGNATURE-----

maintainer
#1 lore raw

From: Friedrich Oslage <[email protected]>
Date: Sat, 13 Dec 2008 16:55:02 +0100

Quoted 8 lines

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

when compiling glibc(2.9, 20081208 snapshot) with linux 2.6.28-rc8 headers I get a lot of errors like this one:

Quoted 8 lines

In file included from /tmp/toolchain-build/rootfs/usr/include/asm/byteorder.h:49,
from
/tmp/toolchain-build/rootfs/usr/include/linux/atalk.h:4,

                 from ../sysdeps/unix/sysv/linux/netatalk/at.h:25,
                 from ../sysdeps/unix/sysv/linux/sa_len.c:22:

/tmp/toolchain-build/rootfs/usr/include/linux/byteorder.h:8:3: error:
#error Fix asm/byteorder.h to define one endianness

Harvey, we might need to do something about this.

Quoted 51 lines

About a month ago arch/sparc/include/asm/byteorder.h was changed to include the new linux/byteorder.h instead of the old linux/byteorder/big_endian.h. The new one panics if both __LITTLE_ENDIAN and __BIG_ENDIAN are defined.

But since glibc's string/endian.h(/usr/include/endian.h) always defines __BIG_ENDIAN and __LITTLE_ENDIAN it may occur, depending on the includes, that both are defined when asm/byteorder.h is included.

My assumption is that asm/byteorder.h should ensure that only one of these is defined.

After applying the patch below compiling glibc works again. But when compiling the kernel I get

In file included from drivers/scsi/qla2xxx/qla_dfs.c:7:
drivers/scsi/qla2xxx/qla_def.h:1487:7: warning: "__LITTLE_ENDIAN" is not defined

Which sould be okay...I think the #elif should really be an #elif defined but that's another thing ;)

Is this the right solution or did I miss anything?

Cheers,
Friedrich

- --- arch/sparc/include/asm/byteorder.h
+++ arch/sparc/include/asm/byteorder.h

(quoted diff) +3 -1
@@ -5,6 +5,9 @@
 #include <asm/asi.h>
 
 #define __BIG_ENDIAN
+#ifdef __LITTLE_ENDIAN
+# undef __LITTLE_ENDIAN
+#endif
 
 #ifdef CONFIG_SPARC32
 #define __SWAB_64_THRU_32__
-----BEGIN PGP SIGNATURE-----

Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklD2tYACgkQknxn9PmJ76XvEACZAajpv/iRLAeEHXp7cIWBCEEX V9kAnRZ0BBDwLrMENDsPsYMuPWpLDlKv
HUQ
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 20 lines · David Miller

From: Friedrich Oslage <[email protected]>
Date: Sat, 13 Dec 2008 16:55:02 +0100

Quoted 8 lines

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

when compiling glibc(2.9, 20081208 snapshot) with linux 2.6.28-rc8 headers I get a lot of errors like this one:

Quoted 8 lines

In file included from /tmp/toolchain-build/rootfs/usr/include/asm/byteorder.h:49,
from
/tmp/toolchain-build/rootfs/usr/include/linux/atalk.h:4,

                 from ../sysdeps/unix/sysv/linux/netatalk/at.h:25,
                 from ../sysdeps/unix/sysv/linux/sa_len.c:22:

/tmp/toolchain-build/rootfs/usr/include/linux/byteorder.h:8:3: error:
#error Fix asm/byteorder.h to define one endianness

Quoted 1 line

Harvey, we might need to do something about this.

I'm on the run today, will take a look in 24 hours.

Harvey

#3 lore raw

[PATCH-2.6.28 final] byteorder: fix new headers for userspace

In reply to David Miller

glibc headers define both __LITTLE_ENDIAN and __BIG_ENDIAN which was tripping the check in linux/byteorder.h. Let's just stay out of userspace's way and use __KERN_{endian}

The old implementation got away with it as it kept the two implementations in different headers and conditionally included the right one. The combined header does checks within each function body and depends on only one being defined.

Converted the arches in mainline that have already moved to the new header, as the other arches merge the will need simlar fixups.

---
 arch/avr32/include/asm/byteorder.h |    2 +-
 arch/mips/include/asm/byteorder.h  |    4 +-
 arch/sh/include/asm/byteorder.h    |    4 +-
 arch/sparc/include/asm/byteorder.h |    2 +-
 include/linux/byteorder.h          |   84 ++++++++++++++++++------------------
 5 files changed, 48 insertions(+), 48 deletions(-)
arch/avr32/include/asm/byteorder.h +1 -1
index 8e3af02..b7d6dd1 100644
@@ -7,7 +7,7 @@
 #include <asm/types.h>
 #include <linux/compiler.h>
 
-#define __BIG_ENDIAN
+#define __KERN_BIG_ENDIAN
 #define __SWAB_64_THRU_32__
 
 #ifdef __CHECKER__
arch/mips/include/asm/byteorder.h +2 -2
index 2988d29..8ad8a5b 100644
@@ -12,9 +12,9 @@
 #include <asm/types.h>
 
 #if defined(__MIPSEB__)
-# define __BIG_ENDIAN
+# define __KERN_BIG_ENDIAN
 #elif defined(__MIPSEL__)
-# define __LITTLE_ENDIAN
+# define __KERN_LITTLE_ENDIAN
 #else
 # error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???"
 #endif
arch/sh/include/asm/byteorder.h +2 -2
index f5fa065..4aa5f1d 100644
@@ -9,9 +9,9 @@
 #include <linux/types.h>
 
 #ifdef __LITTLE_ENDIAN__
-# define __LITTLE_ENDIAN
+# define __KERN_LITTLE_ENDIAN
 #else
-# define __BIG_ENDIAN
+# define __KERN_BIG_ENDIAN
 #endif
 
 #define __SWAB_64_THRU_32__
arch/sparc/include/asm/byteorder.h +1 -1
index 5a70f13..5b8347e 100644
@@ -4,7 +4,7 @@
 #include <asm/types.h>
 #include <asm/asi.h>
 
-#define __BIG_ENDIAN
+#define __KERN_BIG_ENDIAN
 
 #ifdef CONFIG_SPARC32
 #define __SWAB_64_THRU_32__
include/linux/byteorder.h +42 -42

250 lines not on this page · raw message

Signature · 1 line
1.6.1.rc2.316.geb2f0
#4 lore raw

Re: [PATCH-2.6.28 final] byteorder: fix new headers for userspace

Quoted 4 lines · Harvey Harrison

glibc headers define both __LITTLE_ENDIAN and __BIG_ENDIAN which was tripping the check in linux/byteorder.h. Let's just stay out of userspace's way and use __KERN_{endian}

Gaah, ugly.

I think it would be better to just make it a config option, call it CONFIG_[LITTLE|BIG]_ENDIAN and set it up in the architecture Kconfig file. I think some of the people who can set it dynamically (or where it depends on the target machine) already effectively do that.

Hmm?

Linus

#5 lore raw

Re: [PATCH-2.6.28 final] byteorder: fix new headers for userspace

Quoted 5 lines · Linus Torvalds

I think it would be better to just make it a config option, call it CONFIG_[LITTLE|BIG]_ENDIAN and set it up in the architecture Kconfig file. I think some of the people who can set it dynamically (or where it depends on the target machine) already effectively do that.

Never mind, since we end up having to export it to user space (do we?) we can't depend on the config.h file, nor can we pollute the name space.

Oh well.

Linus

#6 lore raw

Re: [PATCH-2.6.28 final] byteorder: fix new headers for userspace

Quoted 8 lines · Linus Torvalds
Quoted 5 lines · Linus Torvalds

I think it would be better to just make it a config option, call it CONFIG_[LITTLE|BIG]_ENDIAN and set it up in the architecture Kconfig file. I think some of the people who can set it dynamically (or where it depends on the target machine) already effectively do that.

Quoted 4 lines

Never mind, since we end up having to export it to user space (do we?) we can't depend on the config.h file, nor can we pollute the name space.

Oh well.

I'm still having a bit of a think on this if we can avoid it. But I think we're stuck with needing a different symbol. :-/

Harvey

#7 lore raw

Re: [PATCH-2.6.28 final] byteorder: fix new headers for userspace

In reply to Linus Torvalds
Quoted 10 lines · On Thu, 18 Dec 2008 12:47:28 -0800 (PST) Linus Torvalds…
Quoted 6 lines · Linus Torvalds

I think it would be better to just make it a config option, call it CONFIG_[LITTLE|BIG]_ENDIAN and set it up in the architecture Kconfig file. I think some of the people who can set it dynamically (or where it depends on the target machine) already effectively do that.

Quoted 4 lines

Never mind, since we end up having to export it to user space (do we?) we can't depend on the config.h file, nor can we pollute the name space.

why are we exposing byte order functions to userspace in the first place ????

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#8 lore raw

Re: [PATCH-2.6.28 final] byteorder: fix new headers for userspace

Quoted 13 lines · Arjan van de Ven
Quoted 10 lines · On Thu, 18 Dec 2008 12:47:28 -0800 (PST) Linus Torvalds…
Quoted 6 lines · Linus Torvalds

I think it would be better to just make it a config option, call it CONFIG_[LITTLE|BIG]_ENDIAN and set it up in the architecture Kconfig file. I think some of the people who can set it dynamically (or where it depends on the target machine) already effectively do that.

Quoted 8 lines
Quoted 4 lines

Never mind, since we end up having to export it to user space (do we?) we can't depend on the config.h file, nor can we pollute the name space.

why are we exposing byte order functions to userspace in the first place ????

Hysterical raisons. When I originally consolidated the byteorder stuff I removed the userspace export. HPA (CC'd) made the point that this API (rightly or wrongly) was currently exported and used by userspace and we shouldn't pull the rug out from under them.

I would have liked to un-export it, then we could also make linux/byteorder.h the preferred include instead of asm/ ... but we appear to be stuck with historical baggage here.

Crazy idea: could a byteorder-user.h be added that make headers-export will pick up instead of byteorder.h that the kernel _actually_ uses?

Then we could keep exporting _something_ to avoid breaking userspace and allow the version the kernel actually uses to be evolved a bit more easily?

Harvey

#9 lore raw

Re: [PATCH-2.6.28 final] byteorder: fix new headers for userspace

In reply to Harvey Harrison
Quoted 3 lines · Harvey Harrison

glibc headers define both __LITTLE_ENDIAN and __BIG_ENDIAN which was tripping the check in linux/byteorder.h. Let's just stay out of userspace's way and use __KERN_{endian}

Ping. What is the status of this?

Quoted 3 lines

Converted the arches in mainline that have already moved to the new header, as the other arches merge the will need simlar fixups.

In latest git powerpc, s390 and x86 are merged and need this fix too.

cheers,
Gerd

#10 lore raw

Re: [PATCH-2.6.28 final] byteorder: fix new headers for userspace

Quoted 7 lines · Gerd Hoffmann
Quoted 3 lines · Harvey Harrison

glibc headers define both __LITTLE_ENDIAN and __BIG_ENDIAN which was tripping the check in linux/byteorder.h. Let's just stay out of userspace's way and use __KERN_{endian}

Ping. What is the status of this?

Quoted 8 lines
Quoted 3 lines

Converted the arches in mainline that have already moved to the new header, as the other arches merge the will need simlar fixups.

In latest git powerpc, s390 and x86 are merged and need this fix too.

cheers,
Gerd

I was waiting for the cris, xtensa and parisc arches to merge as they have conversion patches in their arch trees. I'll send the patchset out today with the proviso it shouldn't be applied until those three have merged.

Cheers,

Harvey