Re: [PATCH] MIPS: tools: fix build on macOS

From
Ryan Burns <hidden>
Date
2021-06-24 01:18:51
Reply to
H. Nikolaus Schaller, 2021-06-21
Hi Nikolaus,

Thanks for the response, I haven't gotten any other feedback on the patch. As far as I'm aware this is still an issue. Maybe this hasn't gotten much attention due to cross-compiling from macOS not being a common use case.

Ryan

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Monday, June 21st, 2021 at 7:59 AM, H. Nikolaus Schaller [off-list ref] wrote:
Hi Ryan,

what happened to that patch? I haven't found a discussion or that it was merged.

I have used it and it seems solve a cross-compilation issue (have to cross-chek if it is still the case with 5.13-rc7).

Maybe the maintainers did not become aware of?

BR and thanks,

Nikolaus Schaller

https://patchwork.kernel.org/project/linux-mips/patch/z_0h2JVlIGgyiySXEyOmFhJ5_rl_EmuXR7beRMunMZRivpcO0H7LqsGa6ePHdSTkF521jUnXMM9TZb5N9mM4fduiHAxpshUkCBd7Owo43tM=@protonmail.com/
quoted
Am 14.02.2021 um 06:01 schrieb Ryan Burns rtburns@protonmail.com:

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 <redacted>
------------------------------------------------

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>
Thread (3 messages) 3 messages, 2 authors, last reply 2021-06-24
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help