diff options
author | Bernhard Rosenkraenzer <bero@arklinux.ch> | 2011-03-21 11:19:36 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-03-21 11:21:12 (GMT) |
commit | e6b61b98f46918d2770a0147a42d10f0a0e18ca8 (patch) | |
tree | 099fce2d8b8ade4aa6ec646bb4dba9eb592e77e0 | |
parent | 312a46e052dd596d620437f1f5dde0ed5b173c28 (diff) | |
download | Qt-e6b61b98f46918d2770a0147a42d10f0a0e18ca8.zip Qt-e6b61b98f46918d2770a0147a42d10f0a0e18ca8.tar.gz Qt-e6b61b98f46918d2770a0147a42d10f0a0e18ca8.tar.bz2 |
Fix endianness detection with gcc 4.6 -flto -fwhole-program
Trying to build Qt with gcc 4.6 and the -flto optimization enabled
fails at ./configure state because the endianness can't be detected.
With -flto in QMAKE_CFLAGS and -fwhole-program in QMAKE_LFLAGS_APP,
gcc 4.6 manages to compute msb_bigendian[1] == lsb_littleendian[1] at
build time and reduces main() to "return 1;", throwing away the bits
being looked for.
Treating the short[] arrays as "code" and trying to actually run them
prevents even the -fwhole-program optimizer from kicking them out, and
since the endian test isn't actually run, doesn't break anything.
Merge-request: 1130
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
-rw-r--r-- | config.tests/unix/endian/endiantest.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/config.tests/unix/endian/endiantest.cpp b/config.tests/unix/endian/endiantest.cpp index 296f890..40b2c38 100644 --- a/config.tests/unix/endian/endiantest.cpp +++ b/config.tests/unix/endian/endiantest.cpp @@ -48,9 +48,9 @@ short lsb_littleendian[] = { 0x0000, 0x654c, 0x7361, 0x5374, 0x6769, 0x696e, 0x6 int main(int, char **) { // make sure the linker doesn't throw away the arrays - char *msb_bigendian_string = (char *) msb_bigendian; - char *lsb_littleendian_string = (char *) lsb_littleendian; - (void) msb_bigendian_string; - (void) lsb_littleendian_string; + void (*msb_bigendian_string)() = (void (*)())msb_bigendian; + void (*lsb_littleendian_string)() = (void (*)())lsb_littleendian; + (void)msb_bigendian_string(); + (void)lsb_littleendian_string(); return msb_bigendian[1] == lsb_littleendian[1]; } |