Re: MAP_SYNC troubles on MIPS platforms

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

 



Sorry for responding to myself here, of course right after sending this email I found again the CPP debugging options that I was looking for only to realize that the following happened:

io/mmap.c does include input.h which includes libfrog/projectsh which includes xfs.h which includes linux.h. Because linux.h has a header guard, the second inclusion *after* sys/mman.h had no chance of re-defining MAP_SYNC, I should be able to submit a patch addressing that.

On 7/20/22 12:49, Florian Fainelli wrote:
> Hi,
> 
> While testing musl-libc builds with MIPS-based platforms, I ran into the following build failure affecting the mmap.c file only:
> 
>     mmap.c: In function 'mmap_f':
>     mmap.c:196:12: error: 'MAP_SYNC' undeclared (first use in this function); did you mean 'MS_SYNC'?
>       196 |    flags = MAP_SYNC | MAP_SHARED_VALIDATE;
>           |            ^~~~~~~~
>           |            MS_SYNC
>     mmap.c:196:12: note: each undeclared identifier is reported only once for each function it appears in
>     make[4]: *** [../include/buildrules:81: mmap.o] Error 1
> 
> musl-libc does explicitly un-define MAP_SYNC since MIPS does not support it:
> 
> https://git.musl-libc.org/cgit/musl/tree/arch/mips/bits/mman.h#n21
> 
> however the include chain for io/mmap.c should still have the linux.h compatibility shim provide a suitable definition for MAP_SYNC so this did not really make sense to me:
> 
> #include <sys/mman.h>
> 	-> bits/mman.h	(where the undefined happens)
> #include "io.h"
> 	-> include/xfs.h
> 		-> include/linux.h
> 
> I have confirmed that at every stage of the inclusion chain the MAP_SYNC and HAVE_MAP_SYNC are defined or undefined as intended, up until the top-level inclusion of include/xfs.h in io/io.h where MAP_SYNC is not defined after we included xfs.h which does not quite make sense to me at all. The build command line for that file is:
> 
> mipsel-buildroot-linux-musl-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 -DDANGEROUS_COMMANDS_ENABLED -D_FILE_OFFSET_BITS=64 -Wno-address-of-packed-member -g -O2 -DDEBUG -DVERSION=\"5.14.2\" -DLOCALEDIR=\"/usr/share/locale\" -DPACKAGE=\"xfsprogs\" -I../include -I../libxfs -I.. -D_LGPL_SOURCE -D_GNU_SOURCE -funsigned-char -fno-strict-aliasing -Wall -DHAVE_MNTENT -DHAVE_FSETXATTR -DENABLE_BLKID -DHAVE_GETFSMAP -DHAVE_FALLOCATE -DHAVE_FADVISE -DHAVE_MADVISE -DHAVE_MINCORE -DHAVE_SENDFILE -DHAVE_FIEMAP -DHAVE_COPY_FILE_RANGE -DHAVE_SYNC_FILE_RANGE -DHAVE_SYNCFS -DHAVE_FALLOCATE -DHAVE_PREADV -DHAVE_PWRITEV -DHAVE_READDIR -DHAVE_MREMAP -DHAVE_STATFS_FLAGS -c mmap.c
> 
> People in other projects have attempted to fix it
> 
> https://github.com/openwrt/packages/blob/master/utils/xfsprogs/patches/140-mman.patch
> 
> but this feels just plain wrong. The only way that I could get it to build was to do the following, but this does not really work on my x86_64 glibc host:
> 
> diff --git a/include/linux.h b/include/linux.h
> index 3d9f4e3dca80..7ca9fab16705 100644
> --- a/include/linux.h
> +++ b/include/linux.h
> @@ -252,8 +252,11 @@ struct fsxattr {
>  #endif
> 
>  #ifndef HAVE_MAP_SYNC
> +#include <sys/mman.h>
>  #define MAP_SYNC 0
> +#ifndef MAP_SHARED_VALIDATE
>  #define MAP_SHARED_VALIDATE 0
> +#endif
>  #else
>  #include <asm-generic/mman.h>
>  #include <asm-generic/mman-common.h>
> 
> Any clues from the mmap.i attached filed what could be going wrong?
> 
> Thank you for reading me!


-- 
Florian



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux