Commit b0c083a3 authored by alpine-mips-patches's avatar alpine-mips-patches Committed by Leonardo Arena

main/xfsprogs: fix build on mips* and ppc64le

musl-1.1.20 implements support (or lack thereof) for the MAP_SYNC flag by #define'ing
it uncoditionally in generic <sys/mman.h> then #undef'ining optionally in arch-specific
<bits/mman.h> (e.g. for mips* and powerpc*). So io/mmap.c fails to compile since it
includes <sys/mman.h> (which undefines MAP_SYNC on mips* and powerpc*) after "linux.h"
(which either defines fallback MAP_SYNC values or pulls <asm-generic/mman{-common.h}>).

The proposes patch also fixes the flawed MAP_SYNC detection logic in the configure script
because io/mmap.c always uses the MAP_SYNC definition (either real one or zero fallback).
Otherwise xfsprogs wrongly detects the MAP_SYNC presence on mips* and ppc64le and the code
does not define MAP_SYNC fallback so io/mmap.c still fails to compile.

Note the last (2018-07-11) successful xfsprogs build for ppc64le was against musl-1.1.19
(without any support for MAP_SYNC).

The problem with MAP_SYNC detection is as follows. The configure script checks only
<asm-generic/mman{-common}.h> headers for the MAP_SYNC definition instead of using
the arch-specific <asm/mman.h>. But some architectures (mips, powerpc, parisc) do not
support the MAP_SYNC feature at all, do not use the <asm-generic/mman{-common.h}> files
and do not define the flag in the corresponding <asm/mman.h> header.
parent 64a969f0
......@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=xfsprogs
pkgver=4.19.0
pkgrel=0
pkgrel=1
pkgdesc="XFS filesystem utilities"
url="http://xfs.org/index.php/Main_Page"
arch="all"
......@@ -12,6 +12,7 @@ options="!check" # no test suite
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs $pkgname-extra"
source="https://www.kernel.org/pub/linux/utils/fs/xfs/$pkgname/$pkgname-$pkgver.tar.gz
fix-mmap.patch
musl-MAP_SYNC-fix.patch
"
builddir="$srcdir/$pkgname-$pkgver"
......@@ -51,4 +52,5 @@ extra() {
}
sha512sums="48ffcdb60a3bd332d5a5837824eb629759ec2d9015b94ac7ee7eef1dab507b2663f3223efc7885cbbe6ef6d721521953d32327688abd7d01f00c66ac5f5c9d29 xfsprogs-4.19.0.tar.gz
080161b211e20277e44f714961b36064536bb5cce72a6f93fef4996e296a3953d33c1a066ef371ccd5551622357105f9be9086ef917386f5d43f6a211b0bd7c9 fix-mmap.patch"
080161b211e20277e44f714961b36064536bb5cce72a6f93fef4996e296a3953d33c1a066ef371ccd5551622357105f9be9086ef917386f5d43f6a211b0bd7c9 fix-mmap.patch
bc7971207a296d8112f8993f6a266533135aae59a4438bb511f472931c37b8ce3033c597d67abbd3664f4405317aeb049e747c1811c9495c1a24d98935f799cc musl-MAP_SYNC-fix.patch"
--- a/configure
+++ b/configure
@@ -14507,8 +14507,7 @@
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include <asm-generic/mman.h>
-#include <asm-generic/mman-common.h>
+#include <asm/mman.h>
int
main ()
--- a/include/linux.h
+++ b/include/linux.h
@@ -327,12 +327,4 @@
#define HAVE_GETFSMAP
#endif /* HAVE_GETFSMAP */
-#ifndef HAVE_MAP_SYNC
-#define MAP_SYNC 0
-#define MAP_SHARED_VALIDATE 0
-#else
-#include <asm-generic/mman.h>
-#include <asm-generic/mman-common.h>
-#endif /* HAVE_MAP_SYNC */
-
#endif /* __XFS_LINUX_H__ */
--- a/io/mmap.c
+++ b/io/mmap.c
@@ -23,6 +23,11 @@
#include "init.h"
#include "io.h"
+#ifndef HAVE_MAP_SYNC
+#define MAP_SYNC 0
+#define MAP_SHARED_VALIDATE 0
+#endif
+
static cmdinfo_t mmap_cmd;
static cmdinfo_t mread_cmd;
static cmdinfo_t msync_cmd;
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -335,8 +335,7 @@
AC_DEFUN([AC_HAVE_MAP_SYNC],
[ AC_MSG_CHECKING([for MAP_SYNC])
AC_TRY_COMPILE([
-#include <asm-generic/mman.h>
-#include <asm-generic/mman-common.h>
+#include <asm/mman.h>
], [
int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
], have_map_sync=yes
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment