Ivan V has uploaded this change for review.

View Change

platform: Fix endianness detection for Apple Silicon Macs

Building flashrom on Apple Silicon Macs fails with
"Unable to determine endianness" error. It seems that current
endianness detection fails on macOS due to a combination of
three issues:
1. On macOS, neither GCC nor Clang have __ARMEL__ macros used
by architecture-specific detection;
2. Generic detection fails because Apple uses LITTLE_ENDIAN,
BIG_ENDIAN and BYTE_ORDER macros instead of __BYTE_ORDER and
__LITTLE_ENDIAN;
3. __LITTLE_ENDIAN__ and __BIG_ENDIAN__ macros are used only
for PowerPC architecture.

This error can be fixed by appending __LITTLE_ENDIAN__ and
__BIG_ENDIAN__ to conditions in IS_ARM branch. I've considered
multiple approaches, but this one seems the cleanest to me.

Signed-off-by: Ivan V <root@pcm720.me>
Change-Id: Ifdb1523ee2c7023e657cfd7b823b091d5deef513
---
M platform.h
1 file changed, 2 insertions(+), 2 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/64/54964/1
diff --git a/platform.h b/platform.h
index 751957c..04f1ab1 100644
--- a/platform.h
+++ b/platform.h
@@ -116,9 +116,9 @@
#elif IS_ARM

/* ARM can be either endian. */
-#if defined (__ARMEB__)
+#if defined (__ARMEB__) || defined (__BIG_ENDIAN__)
#define __FLASHROM_BIG_ENDIAN__ 1
-#elif defined (__ARMEL__)
+#elif defined (__ARMEL__) || defined (__LITTLE_ENDIAN__)
#define __FLASHROM_LITTLE_ENDIAN__ 1
#endif


To view, visit change 54964. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ifdb1523ee2c7023e657cfd7b823b091d5deef513
Gerrit-Change-Number: 54964
Gerrit-PatchSet: 1
Gerrit-Owner: Ivan V <root@pcm720.me>
Gerrit-MessageType: newchange