[PATCH] MIPS: tools: fix build on macOS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



macOS does not have byteswap.h, but we can use Apple's libkern/OSByteOrder.h instead.

This issue is encountered during cross-compilation from macOS to MIPS in nixpkgs.
You can view a log of the build failure here:
https://hydra.nixos.org/build/136015790/nixlog/1
   
Signed-off-by: Ryan Burns <rtburns@xxxxxxxxxxxxxx>
---
arch/mips/boot/tools/relocs.h      | 11 +++++++++--
arch/mips/boot/tools/relocs_main.c |  1 -
arch/mips/tools/elf-entry.c        | 11 +++++++++--
3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/mips/boot/tools/relocs.h b/arch/mips/boot/tools/relocs.h
index 607ff0103064..5de9bb7a7e09 100644
--- a/arch/mips/boot/tools/relocs.h
+++ b/arch/mips/boot/tools/relocs.h
@@ -11,9 +11,16 @@
#include <errno.h>
#include <unistd.h>
#include <elf.h>
-#include <byteswap.h>
#define USE_BSD
-#include <endian.h>
+#if defined(__APPLE__)
+# include <libkern/OSByteOrder.h>
+# define bswap_16 OSSwapInt16
+# define bswap_32 OSSwapInt32
+# define bswap_64 OSSwapInt64
+#else
+# include <byteswap.h>
+# include <endian.h>
+#endif
#include <regex.h>

void die(char *fmt, ...);
diff --git a/arch/mips/boot/tools/relocs_main.c b/arch/mips/boot/tools/relocs_main.c
index e2453a564b11..4ef51d1e6d0d 100644
--- a/arch/mips/boot/tools/relocs_main.c
+++ b/arch/mips/boot/tools/relocs_main.c
@@ -6,7 +6,6 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <endian.h>
#include <elf.h>

#include "relocs.h"
diff --git a/arch/mips/tools/elf-entry.c b/arch/mips/tools/elf-entry.c
index dbd14ff05b4c..5d2e2ab4b3b0 100644
--- a/arch/mips/tools/elf-entry.c
+++ b/arch/mips/tools/elf-entry.c
@@ -1,7 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
-#include <byteswap.h>
+#if defined(__APPLE__)
+# include <libkern/OSByteOrder.h>
+# define bswap_16 OSSwapInt16
+# define bswap_32 OSSwapInt32
+# define bswap_64 OSSwapInt64
+#else
+# include <byteswap.h>
+# include <endian.h>
+#endif
#include <elf.h>
-#include <endian.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>




[Index of Archives]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux