Skip to contentSkip to conversation

io/mmap.c: fix musl build on mips64

PATCH Superseded Fabrice Fontaine 2 participants 4 messages Apr 18, 2022 – Apr 28, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io/mmap.c: fix musl build on mips64

musl undefines MAP_SYNC on some architectures such as mips64 since version 1.1.20 and
https://github.com/ifduyue/musl/commit/9b57db3f958d9adc3b1c7371b5c6723aaee448b7
resulting in the following build failure:

mmap.c: In function 'mmap_f':
mmap.c:196:33: error: 'MAP_SYNC' undeclared (first use in this function); did you mean 'MS_SYNC'?

  196 |                         flags = MAP_SYNC | MAP_SHARED_VALIDATE;
      |                                 ^~~~~~~~
      |                                 MS_SYNC

To fix this build failure, include <sys/mman.h> before the other includes

Fixes:
- http://autobuild.buildroot.org/results/3296194907baf7d3fe039f59bcbf595aa8107a28

---
 io/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io/mmap.c +1 -1
index 8c048a0a..b8609295 100644
@@ -4,9 +4,9 @@
  * All Rights Reserved.
  */
 
+#include <sys/mman.h>
 #include "command.h"
 #include "input.h"
-#include <sys/mman.h>
 #include <signal.h>
 #include "init.h"
 #include "io.h"
Signature · 1 line
2.35.1
#1 lore raw
Quoted 27 lines · Fabrice Fontaine

musl undefines MAP_SYNC on some architectures such as mips64 since version 1.1.20 and
https://github.com/ifduyue/musl/commit/9b57db3f958d9adc3b1c7371b5c6723aaee448b7
resulting in the following build failure:

mmap.c: In function 'mmap_f':
mmap.c:196:33: error: 'MAP_SYNC' undeclared (first use in this function); did you mean 'MS_SYNC'?

  196 |                         flags = MAP_SYNC | MAP_SHARED_VALIDATE;
      |                                 ^~~~~~~~
      |                                 MS_SYNC

To fix this build failure, include <sys/mman.h> before the other includes

Fixes:
- http://autobuild.buildroot.org/results/3296194907baf7d3fe039f59bcbf595aa8107a28

---
 io/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io/mmap.c +0 -0
index 8c048a0a..b8609295 100644

io/mmap.c line 12

Quoted 10 lines
io/mmap.c +1 -1
@@ -4,9 +4,9 @@
  * All Rights Reserved.
  */
 
+#include <sys/mman.h>
 #include "command.h"
 #include "input.h"
-#include <sys/mman.h>
 #include <signal.h>
 #include "init.h"
 #include "io.h"

I can't see how this makes any difference to the problem, nor can I see why you are having this issues.

From the configure output:

....
checking for MAP_SYNC... no
....

It is clear that the build has detected that MAP_SYNC does not exist on this platform, and that means HAVE_MAP_SYNC will not be defined. That means when xfs_io is built, io/Makefile does not add -DHAVE_MAP_SYNC to the cflags, and so when io/mmap.c includes io/io.h -> xfs.h -> linux.h we hit this code:

#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 */

Given that this is the last include in the io/mmap.c file, it should not matter what musl is doing - this define should be overriding it completely.

Ooooh.

input.h -> libfrog/projects.h -> xfs.h -> linux.h.

Ok, we've tangled up header includes, and that's why moving the sys/mman.h header fixes the warning. Right, we need to untangle the headers.

.... and my build + test rack just had a total internal power failure of some kind, so that's as far as I can go right now...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw

Hi,

Were you able to go further in your tests?

Best Regards,

Fabrice

Quoted 84 lines · Dave Chinner
Quoted 27 lines · Fabrice Fontaine

musl undefines MAP_SYNC on some architectures such as mips64 since version 1.1.20 and
https://github.com/ifduyue/musl/commit/9b57db3f958d9adc3b1c7371b5c6723aaee448b7
resulting in the following build failure:

mmap.c: In function 'mmap_f':
mmap.c:196:33: error: 'MAP_SYNC' undeclared (first use in this function); did you mean 'MS_SYNC'?

  196 |                         flags = MAP_SYNC | MAP_SHARED_VALIDATE;
      |                                 ^~~~~~~~
      |                                 MS_SYNC

To fix this build failure, include <sys/mman.h> before the other includes

Fixes:
- http://autobuild.buildroot.org/results/3296194907baf7d3fe039f59bcbf595aa8107a28

---
 io/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io/mmap.c +0 -0
index 8c048a0a..b8609295 100644

io/mmap.c line 12

Quoted 10 lines
io/mmap.c +1 -1
@@ -4,9 +4,9 @@
  * All Rights Reserved.
  */
 
+#include <sys/mman.h>
 #include "command.h"
 #include "input.h"
-#include <sys/mman.h>
 #include <signal.h>
 #include "init.h"
 #include "io.h"

I can't see how this makes any difference to the problem, nor can I see why you are having this issues.

From the configure output:

....
checking for MAP_SYNC... no
....

It is clear that the build has detected that MAP_SYNC does not exist on this platform, and that means HAVE_MAP_SYNC will not be defined. That means when xfs_io is built, io/Makefile does not add -DHAVE_MAP_SYNC to the cflags, and so when io/mmap.c includes io/io.h -> xfs.h -> linux.h we hit this code:

#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 */

Given that this is the last include in the io/mmap.c file, it should not matter what musl is doing - this define should be overriding it completely.

Ooooh.

input.h -> libfrog/projects.h -> xfs.h -> linux.h.

Ok, we've tangled up header includes, and that's why moving the sys/mman.h header fixes the warning. Right, we need to untangle the headers.

.... and my build + test rack just had a total internal power failure of some kind, so that's as far as I can go right now...

Cheers,

Dave.
--
Dave Chinner
[email protected]

#3 lore raw
Quoted 3 lines · Fabrice Fontaine

Hi,

Were you able to go further in your tests?

I've looked into it a bit more, and this is a string that ends in a big tangled ball that I do not have time to untangle right now.

Can you please fix the commit message to indicate why moving the header file avoids the build issue so we have a record of the reason for the issue occuring in the commit history?

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]