[GLIB] Fix linking error for systems not providing <sys/memfd.h>
Created attachment 410931 [details]
Created attachment 410934 [details]
Thanks for the review Carlos!.
Adrian suggested to do a compile check, so I'm attaching an alternative patch with some extra cmake changes.
Comment on attachment 410931 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=410931&action=review
I think there is a better approach, as outlined below.
> #include <sys/memfd.h>
It seems that there was a mistake in the manual pages for memfd_create,
and it was never intended for it to suggest using <sys/memfd.h>. There is
some discussion about that here.
> +#include <sys/mman.h>
The <sys/mman.h> header always exists, we do not need to check whether it's available.
What we can do is:
1. Always include <sys/mman.h>. This also works for other systems, for example
FreeBSD also has a memfd_create() function defined in this header:
2. If the MFD_* macros are not defined, include <linux/memfd.h> and use syscall2()
Note: Use this fall only for linux, e.g. with a __has_include(<linux/memfd.h>) guard.
On a second thought, I think we do not need the CMake compile check
when using the approach of always using <sys/mman.h> and the fallback
with <linux/memfd.h>+syscall2() only on Linux. That will also cover
the BSDs which implement a compatible memfd_create() function, without
adding complexity in CMake.
BTW, thanks Sergio for the patch, and sorry for the back and forth
about the CMake check O:-)
Does bubblewrap work on BSD at all? BubblewrapLauncher makes unconditional use of seccomp which is Linux-only.
OTOH, we have other usage of memfd in Platform/unix/SharedMemoryUnix.cpp, where it indeed could be checked in more cross-platform way.
(In reply to Konstantin Tokarev from comment #6)
> Does bubblewrap work on BSD at all?
No it is Linux specific.
Comment on attachment 410934 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=410934&action=review
> -WEBKIT_CHECK_HAVE_INCLUDE(HAVE_LINUX_MEMFD_H linux/memfd.h)
We use this in SharedMemoryUnix.cpp
Created attachment 411203 [details]
I think it would be more correct to add compilation tests for memfd_create and use its results in all places where memfd is used
Committed r268472: <https://trac.webkit.org/changeset/268472>
All reviewed patches have been landed. Closing bug and clearing flags on attachment 411203 [details].