[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/53] configure: Avoid using strings binary
From: |
Paolo Bonzini |
Subject: |
[PULL 06/53] configure: Avoid using strings binary |
Date: |
Tue, 18 Oct 2022 15:29:55 +0200 |
From: Michal Privoznik <mprivozn@redhat.com>
When determining the endiandness of the target architecture we're
building for a small program is compiled, which in an obfuscated
way declares two strings. Then, we look which string is in
correct order (using strings binary) and deduct the endiandness.
But using the strings binary is problematic, because it's part of
toolchain (strings is just a symlink to
x86_64-pc-linux-gnu-strings or llvm-strings). And when
(cross-)compiling, it requires users to set the symlink to the
correct toolchain.
Fortunately, we have a better alternative anyways. We can mimic
what compiler.h is already doing: comparing __BYTE_ORDER__
against values for little/big endiandness.
Bug: https://bugs.gentoo.org/876933
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id:
<d6d9c7043cfe6d976d96694f2b4ecf85cf3206f1.1665732504.git.mprivozn@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/configure b/configure
index f9ec050bf8..81561be7c1 100755
--- a/configure
+++ b/configure
@@ -1423,30 +1423,31 @@ if test "$tcg" = "enabled"; then
git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
fi
-# ---
+##########################################
# big/little endian test
cat > $TMPC << EOF
-#include <stdio.h>
-short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
-short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
-int main(int argc, char *argv[])
-{
- return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
-}
+#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+# error LITTLE
+#endif
+int main(void) { return 0; }
EOF
-if compile_prog ; then
- if strings -a $TMPE | grep -q BiGeNdIaN ; then
- bigendian="yes"
- elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
- bigendian="no"
- else
- echo big/little test failed
- exit 1
- fi
+if ! compile_prog ; then
+ bigendian="no"
else
+ cat > $TMPC << EOF
+#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+# error BIG
+#endif
+int main(void) { return 0; }
+EOF
+
+ if ! compile_prog ; then
+ bigendian="yes"
+ else
echo big/little test failed
exit 1
+ fi
fi
##########################################
--
2.37.3
- [PULL 00/53] target/i386, scsi, build patches for 2022-10-18, Paolo Bonzini, 2022/10/18
- [PULL 01/53] virtio-scsi: Send "REPORTED LUNS CHANGED" sense data upon disk hotplug events, Paolo Bonzini, 2022/10/18
- [PULL 02/53] configure: don't enable firmware for targets that are not built, Paolo Bonzini, 2022/10/18
- [PULL 03/53] scsi: Use device_cold_reset() and bus_cold_reset(), Paolo Bonzini, 2022/10/18
- [PULL 05/53] hyperv: fix SynIC SINT assertion failure on guest reset, Paolo Bonzini, 2022/10/18
- [PULL 08/53] target/i386: Save and restore pc_save before tcg_remove_ops_after, Paolo Bonzini, 2022/10/18
- [PULL 07/53] target/i386: Use device_cold_reset() to reset the APIC, Paolo Bonzini, 2022/10/18
- [PULL 10/53] target/i386: Direct call get_hphys from mmu_translate, Paolo Bonzini, 2022/10/18
- [PULL 11/53] target/i386: Introduce structures for mmu_translate, Paolo Bonzini, 2022/10/18
- [PULL 06/53] configure: Avoid using strings binary,
Paolo Bonzini <=
- [PULL 04/53] hw/scsi/vmw_pvscsi.c: Use device_cold_reset() to reset SCSI devices, Paolo Bonzini, 2022/10/18
- [PULL 09/53] target/i386: Use MMUAccessType across excp_helper.c, Paolo Bonzini, 2022/10/18
- [PULL 12/53] target/i386: Reorg GET_HPHYS, Paolo Bonzini, 2022/10/18
- [PULL 13/53] target/i386: Add MMU_PHYS_IDX and MMU_NESTED_IDX, Paolo Bonzini, 2022/10/18
- [PULL 14/53] target/i386: Use MMU_NESTED_IDX for vmload/vmsave, Paolo Bonzini, 2022/10/18
- [PULL 15/53] target/i386: Combine 5 sets of variables in mmu_translate, Paolo Bonzini, 2022/10/18
- [PULL 16/53] target/i386: Use atomic operations for pte updates, Paolo Bonzini, 2022/10/18
- [PULL 17/53] target/i386: Use probe_access_full for final stage2 translation, Paolo Bonzini, 2022/10/18
- [PULL 18/53] target/i386: Define XMMReg and access macros, align ZMM registers, Paolo Bonzini, 2022/10/18
- [PULL 19/53] target/i386: make ldo/sto operations consistent with ldq, Paolo Bonzini, 2022/10/18