diff mbox series

[RFC] package/qemu: fix build on mips* and powerpc*

Message ID 20230614152634.23608-1-romain.naour@smile.fr
State New
Headers show
Series [RFC] package/qemu: fix build on mips* and powerpc* | expand

Commit Message

Romain Naour June 14, 2023, 3:26 p.m. UTC
linux/mman.h define MAP_SYNC (0x0) as legacy / undefined architecture
specific flags to be ignored by mmap handling code [1].

But MAP_SYNC may be undef by musl toolchain arch/<arch>/bits/mman.h
header [2] when targets (mips*, powerpc*) are not using
asm-generic/mman.h to have MAP_SYNC defined.

Fixes:
http://autobuild.buildroot.org/results/dbd/dbdba73b0adeaeebb97da146e7df6c2cd0b48422
http://autobuild.buildroot.org/results/287/287b4e8e77914a6181cab2b632b7e3412c3b781b

[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b6fb293f2497a9841d94f6b57bd2bb2cd222da43
[2] https://git.musl-libc.org/cgit/musl/commit/?id=9b57db3f958d9adc3b1c7371b5c6723aaee448b7

Signed-off-by: Romain Naour <romain.naour@smile.fr>
---
I believe it may be a musl toolchain issue when MAP_SYNC is undef from musl's
bits/mman.h header. I'm not sure that qemu (upstream) should handle this issue
from util/mmap-alloc.c.
---
 ...-alloc-fix-build-on-mips-and-powerpc.patch | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 package/qemu/0003-util-mmap-alloc-fix-build-on-mips-and-powerpc.patch
diff mbox series

Patch

diff --git a/package/qemu/0003-util-mmap-alloc-fix-build-on-mips-and-powerpc.patch b/package/qemu/0003-util-mmap-alloc-fix-build-on-mips-and-powerpc.patch
new file mode 100644
index 0000000000..528ba3dc78
--- /dev/null
+++ b/package/qemu/0003-util-mmap-alloc-fix-build-on-mips-and-powerpc.patch
@@ -0,0 +1,52 @@ 
+From e244dbccc229c9973b900f1ca4b8c3b61f5305b4 Mon Sep 17 00:00:00 2001
+From: Romain Naour <romain.naour@smile.fr>
+Date: Tue, 13 Jun 2023 23:27:07 +0200
+Subject: [PATCH] util/mmap-alloc: fix build on mips* and powerpc*
+
+linux/mman.h define MAP_SYNC (0x0) as legacy / undefined architecture
+specific flags to be ignored by mmap handling code [1].
+
+But MAP_SYNC may be undef by musl toolchain arch/<arch>/bits/mman.h
+header [2] when targets (mips*, powerpc*) are not using
+asm-generic/mman.h to have MAP_SYNC defined.
+
+Fixes:
+http://autobuild.buildroot.org/results/dbd/dbdba73b0adeaeebb97da146e7df6c2cd0b48422
+http://autobuild.buildroot.org/results/287/287b4e8e77914a6181cab2b632b7e3412c3b781b
+
+[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b6fb293f2497a9841d94f6b57bd2bb2cd222da43
+[2] https://git.musl-libc.org/cgit/musl/commit/?id=9b57db3f958d9adc3b1c7371b5c6723aaee448b7
+
+Upstream: not submitted
+
+Signed-off-by: Romain Naour <romain.naour@smile.fr>
+---
+I believe it may be a musl toolchain issue when MAP_SYNC is undef from musl's
+bits/mman.h header. I'm not sure that qemu (upstream) should handle this issue
+from util/mmap-alloc.c.
+---
+ util/mmap-alloc.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
+index 5ed7d29183..a3994b8610 100644
+--- a/util/mmap-alloc.c
++++ b/util/mmap-alloc.c
+@@ -25,6 +25,14 @@
+ 
+ #define HUGETLBFS_MAGIC       0x958458f6
+ 
++/* MAP_SYNC may be undef by musl toolchain arch/<arch>/bits/mman.h
++ * header when targets (mips*, powerpc*) are not using
++ * asm-generic/mman.h to have MAP_SYNC defined.
++ */
++#ifndef MAP_SYNC
++#define MAP_SYNC 0x0
++#endif
++
+ #ifdef CONFIG_LINUX
+ #include <sys/vfs.h>
+ #endif
+-- 
+2.40.1
+