Hmm... does it really make sense to add such Linux specific functions to 
Emscripten? From looking at the MUSL source, it does have an memfd_create 
entry point, but that just jumps into the Linux SYS_memfd_create syscall, 
so it doesn't work anywhere but on Linux. Suppporting a random collection 
of Linux-specific syscalls might be more confusing to Emscripten users than 
having a clear definition of what's supposed to work (for instance: only 
CRT functions, only POSIX functions up to version X, etc...).

For instance, OP's code doesn't compile on macOS either:

Undefined symbols for architecture arm64:
  "_memfd_create", referenced from:
      _main in test-26b3ed.o
ld: symbol(s) not found for architecture arm64

Cheers,
-Floh.
On Friday, 14 October 2022 at 23:39:55 UTC+2 s...@google.com wrote:

> Emscripten doesn't yet support the memfd_create API.  If you need to use 
> it you could look into adding support for it (or file a bug to get it 
> added).   I imagine that most codebased that use that API have some kind of 
> cross-platform fallback.  Perhaps you could use that instead?
>
> cheers,
> sam
>
> On Fri, Oct 14, 2022 at 3:19 AM Aitha Tarun <aitha...@gmail.com> wrote:
>
>> Hi, I am unable to use the memfd_create method while building the C 
>> script to emscripten.
>> Below I have given my references to reproduce the error.
>>
>> *Code :*
>>
>> #include <stdio.h>
>> #include <sys/mman.h>
>> #include <unistd.h>
>> #include <stdlib.h>
>> #define _GNU_SOURCE
>>
>> int memfd_create(const char *name, unsigned int flags);
>>
>> int main()
>> {
>>     int fd = memfd_create("temp", 0);
>>
>>     printf("Fd : %d\n", fd);
>>
>>     int wrote = write(fd, "Hello", 5);
>>
>>     printf("Wrote : %d\n", wrote);
>>
>>     char * buf = malloc(5);
>>
>>     int red = pread(fd, buf, 5, 0);
>>
>>     printf("Read : %d\n", red);
>>     printf("Content %s\n", buf);
>> }
>>
>> *Error :*
>>
>> *[image: 1.png]*
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to emscripten-disc...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/emscripten-discuss/ef9839a4-8f8c-47c5-8af7-782b05e58c10n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/emscripten-discuss/ef9839a4-8f8c-47c5-8af7-782b05e58c10n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/271eec36-f213-46b5-aa55-8ff13e9dfaf6n%40googlegroups.com.

Reply via email to