diff mbox series

[FFmpeg-devel,v2,2/2] configure: simplify bigendian check

Message ID 20240408131600.81682-2-jdek@itanimul.li
State New
Headers show
Series [FFmpeg-devel,v2,1/2] configure,etc: unify shebang usage | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

J. Dekker April 8, 2024, 1:16 p.m. UTC
The preferred way to use LTO is --enable-lto but often times packagers
still end up with -flto in cflags for various reasons. Using grep
on binary object files is brittle and relies on specific object
representation, which in the case of LLVM bitcode, debug-info or other
intermediary formats can fail silently.

This patch changes the check to a more commonly used define for
big-endian systems. More checks may need to be added in the future to
cover legacy machines.

Signed-off-by: J. Dekker <jdek@itanimul.li>
---
 configure | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Martin Storsjö April 9, 2024, 9:03 a.m. UTC | #1
On Mon, 8 Apr 2024, J. Dekker wrote:

> The preferred way to use LTO is --enable-lto but often times packagers
> still end up with -flto in cflags for various reasons. Using grep
> on binary object files is brittle and relies on specific object
> representation, which in the case of LLVM bitcode, debug-info or other
> intermediary formats can fail silently.
>
> This patch changes the check to a more commonly used define for
> big-endian systems.

It's not common only for big-endian systems, but for GCC-style compilers 
on all endians.

> More checks may need to be added in the future to cover legacy machines.

Don't use the word "legacy" here. This define is not standard, so it's 
perfectly plausible to have a modern, standards compliant compiler that 
just doesn't use this define.

With the commmit message you added here, the change is ok, but please do 
reword the last sentence above.

I'd suggest changing the last paragraph into this:

---
This patch changes the check to a more commonly used define for
GCC style compilers. More checks may be needed to cover other potential 
compilers that don't use the __BYTE_ORDER__ define.
---

// Martin
diff mbox series

Patch

diff --git a/configure b/configure
index 7b6f48e631..e787f13e0b 100755
--- a/configure
+++ b/configure
@@ -6120,11 +6120,7 @@  extern_prefix=${sym%%ff_extern*}
 
 check_cc pragma_deprecated "" '_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")'
 
-# The global variable ensures the bits appear unchanged in the object file.
-test_cc <<EOF || die "endian test failed"
-unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
-EOF
-od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
+test_cpp_condition stdlib.h "defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)" && enable bigendian
 
 check_cc const_nan math.h "struct { double d; } static const bar[] = { { NAN } }"